GDB (xrefs)
Loading...
Searching...
No Matches
Classes | Macros | Functions | Variables
gdb_bfd.c File Reference
#include "defs.h"
#include "gdb_bfd.h"
#include "ui-out.h"
#include "gdbcmd.h"
#include "hashtab.h"
#include "gdbsupport/filestuff.h"
#include "target.h"
#include "gdbsupport/fileio.h"
#include "inferior.h"
#include "cli/cli-style.h"
#include <unordered_map>

Go to the source code of this file.

Classes

struct  gdb_bfd_section_data
 
struct  gdb_bfd_data
 
struct  gdb_bfd_cache_search
 
struct  target_buffer
 
struct  gdb_bfd_open_closure
 
struct  bfd_inferior_data
 

Macros

#define bfd_cache_debug_printf(fmt, ...)    debug_prefixed_printf_cond (debug_bfd_cache, "bfd-cache", fmt, ##__VA_ARGS__)
 
#define AMBIGUOUS_MESS1   ".\nMatching formats:"
 
#define AMBIGUOUS_MESS2    ".\nUse \"set gnutarget format-name\" to specify the format."
 

Functions

static void show_bfd_sharing (struct ui_file *file, int from_tty, struct cmd_list_element *c, const char *value)
 
static void show_bfd_cache_debug (struct ui_file *file, int from_tty, struct cmd_list_element *c, const char *value)
 
static hashval_t hash_bfd (const void *b)
 
static int eq_bfd (const void *a, const void *b)
 
int is_target_filename (const char *name)
 
int gdb_bfd_has_target_filename (struct bfd *abfd)
 
static void * mem_bfd_iovec_open (struct bfd *abfd, void *open_closure)
 
static int mem_bfd_iovec_close (struct bfd *abfd, void *stream)
 
static file_ptr mem_bfd_iovec_pread (struct bfd *abfd, void *stream, void *buf, file_ptr nbytes, file_ptr offset)
 
static int mem_bfd_iovec_stat (struct bfd *abfd, void *stream, struct stat *sb)
 
gdb_bfd_ref_ptr gdb_bfd_open_from_target_memory (CORE_ADDR addr, ULONGEST size, const char *target)
 
static void * gdb_bfd_iovec_fileio_open (struct bfd *abfd, void *open_closure)
 
static file_ptr gdb_bfd_iovec_fileio_pread (struct bfd *abfd, void *stream, void *buf, file_ptr nbytes, file_ptr offset)
 
static void gdb_bfd_close_warning (const char *name, const char *reason)
 
static int gdb_bfd_iovec_fileio_close (struct bfd *abfd, void *stream)
 
static int gdb_bfd_iovec_fileio_fstat (struct bfd *abfd, void *stream, struct stat *sb)
 
static void gdb_bfd_init_data (struct bfd *abfd, struct stat *st)
 
gdb_bfd_ref_ptr gdb_bfd_open (const char *name, const char *target, int fd, bool warn_if_slow)
 
static void free_one_bfd_section (asection *sectp)
 
static int gdb_bfd_close_or_warn (struct bfd *abfd)
 
void gdb_bfd_ref (struct bfd *abfd)
 
void gdb_bfd_unref (struct bfd *abfd)
 
static struct gdb_bfd_section_dataget_section_descriptor (asection *section)
 
const gdb_byte * gdb_bfd_map_section (asection *sectp, bfd_size_type *size)
 
static int get_file_crc (bfd *abfd, unsigned long *file_crc_return)
 
int gdb_bfd_crc (struct bfd *abfd, unsigned long *crc_out)
 
gdb_bfd_ref_ptr gdb_bfd_fopen (const char *filename, const char *target, const char *mode, int fd)
 
gdb_bfd_ref_ptr gdb_bfd_openr (const char *filename, const char *target)
 
gdb_bfd_ref_ptr gdb_bfd_openw (const char *filename, const char *target)
 
gdb_bfd_ref_ptr gdb_bfd_openr_iovec (const char *filename, const char *target, void *(*open_func)(struct bfd *nbfd, void *open_closure), void *open_closure, file_ptr(*pread_func)(struct bfd *nbfd, void *stream, void *buf, file_ptr nbytes, file_ptr offset), int(*close_func)(struct bfd *nbfd, void *stream), int(*stat_func)(struct bfd *abfd, void *stream, struct stat *sb))
 
void gdb_bfd_mark_parent (bfd *child, bfd *parent)
 
gdb_bfd_ref_ptr gdb_bfd_openr_next_archived_file (bfd *archive, bfd *previous)
 
void gdb_bfd_record_inclusion (bfd *includer, bfd *includee)
 
 gdb_static_assert (ARRAY_SIZE(_bfd_std_section)==4)
 
int gdb_bfd_section_index (bfd *abfd, asection *section)
 
int gdb_bfd_count_sections (bfd *abfd)
 
int gdb_bfd_requires_relocations (bfd *abfd)
 
bool gdb_bfd_get_full_section_contents (bfd *abfd, asection *section, gdb::byte_vector *contents)
 
std::string gdb_bfd_errmsg (bfd_error_type error_tag, char **matching)
 
static int print_one_bfd (void **slot, void *data)
 
static void maintenance_info_bfds (const char *arg, int from_tty)
 
static struct bfd_inferior_dataget_bfd_inferior_data (struct inferior *inf)
 
static unsigned long increment_bfd_error_count (std::string str)
 
static void ATTRIBUTE_PRINTF (1, 0)
 
void _initialize_gdb_bfd ()
 

Variables

static htab_t all_bfds
 
static htab_t gdb_bfd_cache
 
static bool bfd_sharing = true
 
static bool debug_bfd_cache
 
static const registry< inferior >::key< bfd_inferior_databfd_inferior_data_key
 
static bfd_error_handler_type default_bfd_error_handler
 

Macro Definition Documentation

◆ AMBIGUOUS_MESS1

#define AMBIGUOUS_MESS1   ".\nMatching formats:"

Definition at line 1041 of file gdb_bfd.c.

◆ AMBIGUOUS_MESS2

#define AMBIGUOUS_MESS2    ".\nUse \"set gnutarget format-name\" to specify the format."

Definition at line 1042 of file gdb_bfd.c.

◆ bfd_cache_debug_printf

#define bfd_cache_debug_printf (   fmt,
  ... 
)     debug_prefixed_printf_cond (debug_bfd_cache, "bfd-cache", fmt, ##__VA_ARGS__)

Definition at line 147 of file gdb_bfd.c.

Function Documentation

◆ _initialize_gdb_bfd()

void _initialize_gdb_bfd ( )

Definition at line 1171 of file gdb_bfd.c.

Referenced by initialize_all_files().

◆ ATTRIBUTE_PRINTF()

static void ATTRIBUTE_PRINTF ( ,
 
)
static

Definition at line 1150 of file gdb_bfd.c.

References increment_bfd_error_count().

◆ eq_bfd()

static int eq_bfd ( const void *  a,
const void *  b 
)
static

◆ free_one_bfd_section()

static void free_one_bfd_section ( asection *  sectp)
static

◆ gdb_bfd_close_or_warn()

static int gdb_bfd_close_or_warn ( struct bfd *  abfd)
static

Definition at line 616 of file gdb_bfd.c.

References free_one_bfd_section(), gdb_bfd_close_warning(), gdb_bfd_sections(), and name.

Referenced by gdb_bfd_unref().

◆ gdb_bfd_close_warning()

static void gdb_bfd_close_warning ( const char *  name,
const char *  reason 
)
static

Definition at line 411 of file gdb_bfd.c.

References name.

Referenced by gdb_bfd_close_or_warn(), and gdb_bfd_iovec_fileio_close().

◆ gdb_bfd_count_sections()

int gdb_bfd_count_sections ( bfd *  abfd)

◆ gdb_bfd_crc()

int gdb_bfd_crc ( struct bfd *  abfd,
unsigned long *  crc_out 
)

Definition at line 858 of file gdb_bfd.c.

References gdb_bfd_data::crc, gdb_bfd_data::crc_computed, and get_file_crc().

Referenced by separate_debug_file_exists().

◆ gdb_bfd_errmsg()

std::string gdb_bfd_errmsg ( bfd_error_type  error_tag,
char **  matching 
)

◆ gdb_bfd_fopen()

gdb_bfd_ref_ptr gdb_bfd_fopen ( const char *  filename,
const char *  target,
const char *  mode,
int  fd 
)

Definition at line 875 of file gdb_bfd.c.

Referenced by core_target_open(), and exec_file_attach().

◆ gdb_bfd_get_full_section_contents()

bool gdb_bfd_get_full_section_contents ( bfd *  abfd,
asection *  section,
gdb::byte_vector *  contents 
)

Definition at line 1030 of file gdb_bfd.c.

Referenced by gdb_bfd_read_elf_soname(), and is_linked_with_cygwin_dll().

◆ gdb_bfd_has_target_filename()

int gdb_bfd_has_target_filename ( struct bfd *  abfd)

Definition at line 215 of file gdb_bfd.c.

References is_target_filename().

Referenced by solib_bfd_fopen(), and symfile_bfd_open().

◆ gdb_bfd_init_data()

static void gdb_bfd_init_data ( struct bfd *  abfd,
struct stat *  st 
)
static

Definition at line 469 of file gdb_bfd.c.

References all_bfds.

Referenced by gdb_bfd_open(), and gdb_bfd_ref().

◆ gdb_bfd_iovec_fileio_close()

static int gdb_bfd_iovec_fileio_close ( struct bfd *  abfd,
void *  stream 
)
static

Definition at line 420 of file gdb_bfd.c.

References gdb_bfd_close_warning(), target_fileio_close(), and xfree().

Referenced by gdb_bfd_open().

◆ gdb_bfd_iovec_fileio_fstat()

static int gdb_bfd_iovec_fileio_fstat ( struct bfd *  abfd,
void *  stream,
struct stat *  sb 
)
static

Definition at line 448 of file gdb_bfd.c.

References target_fileio_fstat().

Referenced by gdb_bfd_open().

◆ gdb_bfd_iovec_fileio_open()

static void * gdb_bfd_iovec_fileio_open ( struct bfd *  abfd,
void *  open_closure 
)
static

◆ gdb_bfd_iovec_fileio_pread()

static file_ptr gdb_bfd_iovec_fileio_pread ( struct bfd *  abfd,
void *  stream,
void *  buf,
file_ptr  nbytes,
file_ptr  offset 
)
static

Definition at line 376 of file gdb_bfd.c.

References QUIT, and target_fileio_pread().

Referenced by gdb_bfd_open().

◆ gdb_bfd_map_section()

const gdb_byte * gdb_bfd_map_section ( asection *  sectp,
bfd_size_type *  size 
)

◆ gdb_bfd_mark_parent()

void gdb_bfd_mark_parent ( bfd *  child,
bfd *  parent 
)

◆ gdb_bfd_open()

gdb_bfd_ref_ptr gdb_bfd_open ( const char *  name,
const char *  target,
int  fd,
bool  warn_if_slow 
)

◆ gdb_bfd_open_from_target_memory()

gdb_bfd_ref_ptr gdb_bfd_open_from_target_memory ( CORE_ADDR  addr,
ULONGEST  size,
const char *  target 
)

◆ gdb_bfd_openr()

gdb_bfd_ref_ptr gdb_bfd_openr ( const char *  filename,
const char *  target 
)

Definition at line 886 of file gdb_bfd.c.

Referenced by bfd_openr_or_error(), and macho_check_dsym().

◆ gdb_bfd_openr_iovec()

gdb_bfd_ref_ptr gdb_bfd_openr_iovec ( const char *  filename,
const char *  target,
void *(*)(struct bfd *nbfd, void *open_closure)  open_func,
void *  open_closure,
file_ptr(*)(struct bfd *nbfd, void *stream, void *buf, file_ptr nbytes, file_ptr offset)  pread_func,
int(*)(struct bfd *nbfd, void *stream)  close_func,
int(*)(struct bfd *abfd, void *stream, struct stat *sb)  stat_func 
)

◆ gdb_bfd_openr_next_archived_file()

gdb_bfd_ref_ptr gdb_bfd_openr_next_archived_file ( bfd *  archive,
bfd *  previous 
)

Definition at line 952 of file gdb_bfd.c.

References gdb_bfd_mark_parent().

Referenced by macho_symfile_read_all_oso(), and solib_aix_bfd_open().

◆ gdb_bfd_openw()

gdb_bfd_ref_ptr gdb_bfd_openw ( const char *  filename,
const char *  target 
)

Definition at line 896 of file gdb_bfd.c.

Referenced by bfd_openw_or_error(), and create_gcore_bfd().

◆ gdb_bfd_record_inclusion()

void gdb_bfd_record_inclusion ( bfd *  includer,
bfd *  includee 
)

◆ gdb_bfd_ref()

void gdb_bfd_ref ( struct bfd *  abfd)

◆ gdb_bfd_requires_relocations()

int gdb_bfd_requires_relocations ( bfd *  abfd)

◆ gdb_bfd_section_index()

int gdb_bfd_section_index ( bfd *  abfd,
asection *  section 
)

◆ gdb_bfd_unref()

void gdb_bfd_unref ( struct bfd *  abfd)

◆ gdb_static_assert()

gdb_static_assert ( ARRAY_SIZE(_bfd_std_section)  = =4)

◆ get_bfd_inferior_data()

static struct bfd_inferior_data * get_bfd_inferior_data ( struct inferior inf)
static

Definition at line 1121 of file gdb_bfd.c.

References bfd_inferior_data_key, and registry< T >::get().

Referenced by increment_bfd_error_count().

◆ get_file_crc()

static int get_file_crc ( bfd *  abfd,
unsigned long *  file_crc_return 
)
static

Definition at line 823 of file gdb_bfd.c.

References SEEK_SET.

Referenced by gdb_bfd_crc().

◆ get_section_descriptor()

static struct gdb_bfd_section_data * get_section_descriptor ( asection *  section)
static

Definition at line 722 of file gdb_bfd.c.

Referenced by gdb_bfd_map_section().

◆ hash_bfd()

static hashval_t hash_bfd ( const void *  b)
static

Definition at line 178 of file gdb_bfd.c.

Referenced by gdb_bfd_open().

◆ increment_bfd_error_count()

static unsigned long increment_bfd_error_count ( std::string  str)
static

◆ is_target_filename()

int is_target_filename ( const char *  name)

◆ maintenance_info_bfds()

static void maintenance_info_bfds ( const char *  arg,
int  from_tty 
)
static

◆ mem_bfd_iovec_close()

static int mem_bfd_iovec_close ( struct bfd *  abfd,
void *  stream 
)
static

Definition at line 271 of file gdb_bfd.c.

Referenced by gdb_bfd_open_from_target_memory().

◆ mem_bfd_iovec_open()

static void * mem_bfd_iovec_open ( struct bfd *  abfd,
void *  open_closure 
)
static

Definition at line 262 of file gdb_bfd.c.

Referenced by gdb_bfd_open_from_target_memory().

◆ mem_bfd_iovec_pread()

static file_ptr mem_bfd_iovec_pread ( struct bfd *  abfd,
void *  stream,
void *  buf,
file_ptr  nbytes,
file_ptr  offset 
)
static

◆ mem_bfd_iovec_stat()

static int mem_bfd_iovec_stat ( struct bfd *  abfd,
void *  stream,
struct stat *  sb 
)
static

Definition at line 310 of file gdb_bfd.c.

References target_buffer::size().

Referenced by gdb_bfd_open_from_target_memory().

◆ print_one_bfd()

static int print_one_bfd ( void **  slot,
void *  data 
)
static

◆ show_bfd_cache_debug()

static void show_bfd_cache_debug ( struct ui_file file,
int  from_tty,
struct cmd_list_element c,
const char *  value 
)
static

Definition at line 151 of file gdb_bfd.c.

References gdb_printf().

◆ show_bfd_sharing()

static void show_bfd_sharing ( struct ui_file file,
int  from_tty,
struct cmd_list_element c,
const char *  value 
)
static

Definition at line 135 of file gdb_bfd.c.

References gdb_printf().

Variable Documentation

◆ all_bfds

htab_t all_bfds
static

Definition at line 58 of file gdb_bfd.c.

Referenced by gdb_bfd_init_data(), gdb_bfd_unref(), and maintenance_info_bfds().

◆ bfd_inferior_data_key

const registry<inferior>::key<bfd_inferior_data> bfd_inferior_data_key
static

Definition at line 1115 of file gdb_bfd.c.

Referenced by get_bfd_inferior_data().

◆ bfd_sharing

bool bfd_sharing = true
static

Definition at line 133 of file gdb_bfd.c.

Referenced by gdb_bfd_open().

◆ debug_bfd_cache

bool debug_bfd_cache
static

Definition at line 143 of file gdb_bfd.c.

◆ default_bfd_error_handler

bfd_error_handler_type default_bfd_error_handler
static

Definition at line 1144 of file gdb_bfd.c.

◆ gdb_bfd_cache

htab_t gdb_bfd_cache
static

Definition at line 128 of file gdb_bfd.c.

Referenced by gdb_bfd_open(), and gdb_bfd_unref().