GDB (xrefs)

Functions | Variables
/tmp/gdb-8.1/gdb/exec.c File Reference
`#include "defs.h"`
`#include "frame.h"`
`#include "inferior.h"`
`#include "target.h"`
`#include "gdbcmd.h"`
`#include "language.h"`
`#include "filenames.h"`
`#include "symfile.h"`
`#include "objfiles.h"`
`#include "completer.h"`
`#include "value.h"`
`#include "exec.h"`
`#include "observer.h"`
`#include "arch-utils.h"`
`#include "gdbthread.h"`
`#include "progspace.h"`
`#include "gdb_bfd.h"`
`#include "gcore.h"`
`#include <fcntl.h>`
`#include "readline/readline.h"`
`#include "gdbcore.h"`
`#include <ctype.h>`
`#include <sys/stat.h>`
`#include "solist.h"`
`#include <algorithm>`

Go to the source code of this file.

## Functions
static void | exec_files_info (struct target_ops *)
static void | init_exec_ops (void)
static void | show_write_files (struct ui_file *file, int from_tty, struct cmd_list_element *c, const char *value)
static void | exec_open (const char *args, int from_tty)
void | exec_close (void)
static void | exec_close_1 (struct target_ops *self)
void | exec_file_clear (int from_tty)
void | try_open_exec_file (const char *exec_file_host, struct inferior *inf, symfile_add_flags add_flags)
void | exec_file_locate_attach (int pid, int defer_bp_reset, int from_tty)
void | exec_file_attach (const char *filename, int from_tty)
static void | exec_file_command (const char *args, int from_tty)
static void | file_command (const char *arg, int from_tty)
static void | add_to_section_table (bfd *abfd, struct bfd_section *asect, void *table_pp_char)
void | clear_section_table (struct target_section_table *table)
static int | resize_section_table (struct target_section_table *table, int adjustment)
int | build_section_table (struct bfd *some_bfd, struct target_section **start, struct target_section **end)
void | add_target_sections (void *owner, struct target_section *sections, struct target_section *sections_end)
void | add_target_sections_of_objfile (struct objfile *objfile)
void | remove_target_sections (void *owner)
enum target_xfer_status | exec_read_partial_read_only (gdb_byte *readbuf, ULONGEST offset, ULONGEST len, ULONGEST *xfered_len)
static std::vector< mem_range > | section_table_available_memory (CORE_ADDR memaddr, ULONGEST len, struct target_section *sections, struct target_section *sections_end)
enum target_xfer_status | section_table_read_available_memory (gdb_byte *readbuf, ULONGEST offset, ULONGEST len, ULONGEST *xfered_len)
enum target_xfer_status | section_table_xfer_memory_partial (gdb_byte *readbuf, const gdb_byte *writebuf, ULONGEST offset, ULONGEST len, ULONGEST *xfered_len, struct target_section *sections, struct target_section *sections_end, const char *section_name)
static struct target_section_table * | exec_get_section_table (struct target_ops *ops)
static enum target_xfer_status | exec_xfer_partial (struct target_ops *ops, enum target_object object, const char *annex, gdb_byte *readbuf, const gdb_byte *writebuf, ULONGEST offset, ULONGEST len, ULONGEST *xfered_len)
void | print_section_info (struct target_section_table *t, bfd *abfd)
static void | set_section_command (const char *args, int from_tty)
void | exec_set_section_address (const char *filename, int index, CORE_ADDR address)
static int | ignore (struct target_ops *ops, struct gdbarch *gdbarch, struct bp_target_info *bp_tgt)
static int | exec_remove_breakpoint (struct target_ops *ops, struct gdbarch *gdbarch, struct bp_target_info *bp_tgt, enum remove_bp_reason reason)
static int | exec_has_memory (struct target_ops *ops)
static char * | exec_make_note_section (struct target_ops *self, bfd *obfd, int *note_size)
void | _initialize_exec (void)

## Variables
void(* | deprecated_file_changed_hook )(const char *)
static struct target_ops | exec_ops
int | write_files = 0

## Function Documentation

## ◆ _initialize_exec()

void _initialize_exec | ( | void |  | ) |

Definition at line 1080 of file exec.c.

References _, add_cmd(), add_com(), add_setshow_boolean_cmd(), add_target_with_completer(), class_files, class_support, cmdlist, dbx_commands, exec_file_command(), exec_ops, file_command(), filename_completer(), init_exec_ops(), set_cmd_completer(), set_section_command(), setlist, show_write_files(), showlist, and write_files.

## ◆ add_target_sections()

void add_target_sections | ( | void * | owner,
|  | struct target_section * | sections,
|  | struct target_section * | sections_end
| ) |  |

Definition at line 531 of file exec.c.

References current_target_sections, exec_ops, target_section::owner, push_target(), resize_section_table(), target_section_table::sections, target_section_table::sections_end, and target_is_pushed().

Referenced by exec_file_attach(), and solib_map_sections().

## ◆ add_target_sections_of_objfile()

void add_target_sections_of_objfile | ( | struct objfile * | objfile | ) |

Definition at line 561 of file exec.c.

References target_section::addr, ALL_OBJFILE_OSECTIONS, current_target_sections, target_section::endaddr, gdb_assert, obj_section_addr, obj_section_endaddr, target_section::owner, resize_section_table(), target_section_table::sections, obj_section::the_bfd_section, and target_section::the_bfd_section.

Referenced by add_symbol_file_command(), and symbol_file_add_from_memory().

## ◆ add_to_section_table()

static void add_to_section_table | ( | bfd * | abfd,
|  | struct bfd_section * | asect,
|  | void * | table_pp_char
| ) |  |
| static

Definition at line 445 of file exec.c.

References gdb_assert.

Referenced by build_section_table().

## ◆ build_section_table()

int build_section_table | ( | struct bfd * | some_bfd,
|  | struct target_section ** | start,
|  | struct target_section ** | end
| ) |  |

Definition at line 509 of file exec.c.

References _, add_to_section_table(), internal_error(), xfree(), and XNEWVEC.

Referenced by core_open(), exec_file_attach(), record_full_core_open_1(), solib_map_sections(), and target_bfd_reopen().

## ◆ clear_section_table()

void clear_section_table | ( | struct target_section_table * | table | ) |

Definition at line 472 of file exec.c.

References target_section_table::sections, target_section_table::sections_end, and xfree().

Referenced by exec_close_1(), release_program_space(), and resize_section_table().

## ◆ exec_close()

void exec_close | ( | void |  | ) |

Definition at line 83 of file exec.c.

References exec_bfd, exec_bfd_mtime, exec_filename, gdb_bfd_unref(), remove_target_sections(), and xfree().

Referenced by exec_close_1(), exec_file_attach(), exec_file_clear(), and release_program_space().

## ◆ exec_close_1()

static void exec_close_1 | ( | struct target_ops * | self | ) |
| static

Definition at line 107 of file exec.c.

References ALL_PSPACES, clear_section_table(), current_target_sections, exec_close(), and set_current_program_space().

Referenced by init_exec_ops().

## ◆ exec_file_attach()

void exec_file_attach | ( | const char * | filename,
|  | int | from_tty
| ) |  |

Definition at line 244 of file exec.c.

References _, add_target_sections(), build_section_table(), deprecated_exec_file_display_hook, error(), exec_bfd, exec_bfd_mtime, exec_close(), exec_filename, gdb_assert, gdb_bfd_errmsg(), gdb_bfd_fopen(), gdb_bfd_open(), gdb_realpath(), gdb_realpath_keepfile(), gnutarget, is_target_filename(), new_bfd_ref(), O_BINARY, observer_notify_executable_changed(), openp(), OPF_TRY_CWD_FIRST, perror_with_name(), printf_unfiltered(), gdb::ref_ptr< T, Policy >::release(), set_gdbarch_from_file(), target_filesystem_is_local, TARGET_SYSROOT_PREFIX, validate_files(), warning(), write_files, and xfree().

Referenced by add_inferior_command(), captured_main_1(), clone_program_space(), exec_file_command(), exec_open(), reopen_exec_file(), reread_symbols(), and try_open_exec_file().

## ◆ exec_file_clear()

void exec_file_clear | ( | int | from_tty | ) |

Definition at line 121 of file exec.c.

References _, exec_close(), and printf_unfiltered().

## ◆ exec_file_command()

static void exec_file_command | ( | const char * | args,
|  | int | from_tty
| ) |  |
| static

Definition at line 396 of file exec.c.

References _, gdb::argv, error(), exec_file_attach(), gdb_argv::get(), query(), and target_has_execution.

Referenced by _initialize_exec(), and file_command().

## ◆ exec_file_locate_attach()

void exec_file_locate_attach | ( | int | pid,
|  | int | defer_bp_reset,
|  | int | from_tty
| ) |  |

Definition at line 191 of file exec.c.

References _, current_inferior(), do_cleanups(), exec_file_find(), get_exec_file(), make_cleanup(), pid, SYMFILE_DEFER_BP_RESET, SYMFILE_VERBOSE, target_pid_to_exec_file, try_open_exec_file(), warning(), and xfree().

Referenced by remote_add_inferior(), and setup_inferior().

## ◆ exec_files_info()

static void exec_files_info | ( | struct target_ops * | t | ) |
| static

Definition at line 947 of file exec.c.

References _, current_target_sections, exec_bfd, print_section_info(), and puts_filtered().

Referenced by init_exec_ops(), and set_section_command().

## ◆ exec_get_section_table()

static struct target_section_table* exec_get_section_table | ( | struct target_ops * | ops | ) |
| static

Definition at line 853 of file exec.c.

References current_target_sections.

Referenced by init_exec_ops().

## ◆ exec_has_memory()

static int exec_has_memory | ( | struct target_ops * | ops | ) |
| static

Definition at line 1041 of file exec.c.

References current_target_sections.

Referenced by init_exec_ops().

## ◆ exec_make_note_section()

static char* exec_make_note_section | ( | struct target_ops * | self,
|  | bfd * | obfd,
|  | int * | note_size
| ) |  |
| static

Definition at line 1050 of file exec.c.

References _, and error().

Referenced by init_exec_ops().

## ◆ exec_open()

static void exec_open | ( | const char * | args,
|  | int | from_tty
| ) |  |
| static

Definition at line 73 of file exec.c.

References exec_file_attach(), and target_preopen().

Referenced by init_exec_ops().

## ◆ exec_read_partial_read_only()

enum target_xfer_status exec_read_partial_read_only | ( | gdb_byte * | readbuf,
|  | ULONGEST | offset,
|  | ULONGEST | len,
|  | ULONGEST * | xfered_len
| ) |  |

Definition at line 650 of file exec.c.

References exec_bfd, offset, size, TARGET_XFER_E_IO, TARGET_XFER_EOF, and TARGET_XFER_OK.

Referenced by section_table_read_available_memory(), and tfile_xfer_partial().

## ◆ exec_remove_breakpoint()

static int exec_remove_breakpoint | ( | struct target_ops * | ops,
|  | struct gdbarch * | gdbarch,
|  | struct bp_target_info * | bp_tgt,
|  | enum remove_bp_reason | reason
| ) |  |
| static

Definition at line 1033 of file exec.c.

Referenced by init_exec_ops().

## ◆ exec_set_section_address()

void exec_set_section_address | ( | const char * | filename,
|  | int | index,
|  | CORE_ADDR | address
| ) |  |

Definition at line 1002 of file exec.c.

References target_section::addr, current_target_sections, target_section::endaddr, target_section_table::sections, target_section_table::sections_end, and target_section::the_bfd_section.

Referenced by default_symfile_offsets(), objfile_relocate1(), and svr4_relocate_main_executable().

## ◆ exec_xfer_partial()

static enum target_xfer_status exec_xfer_partial | ( | struct target_ops * | ops,
|  | enum target_object | object,
|  | const char * | annex,
|  | gdb_byte * | readbuf,
|  | const gdb_byte * | writebuf,
|  | ULONGEST | offset,
|  | ULONGEST | len,
|  | ULONGEST * | xfered_len
| ) |  |
| static

Definition at line 859 of file exec.c.

References offset, section_table_xfer_memory_partial(), target_section_table::sections, target_section_table::sections_end, target_get_section_table(), TARGET_OBJECT_MEMORY, and TARGET_XFER_E_IO.

Referenced by init_exec_ops().

## ◆ file_command()

static void file_command | ( | const char * | arg,
|  | int | from_tty
| ) |  |
| static

Definition at line 429 of file exec.c.

References deprecated_file_changed_hook, exec_file_command(), and symbol_file_command().

Referenced by _initialize_exec().

## ◆ ignore()

static int ignore | ( | struct target_ops * | ops,
|  | struct gdbarch * | gdbarch,
|  | struct bp_target_info * | bp_tgt
| ) |  |
| static

Definition at line 1024 of file exec.c.

Referenced by init_exec_ops().

## ◆ init_exec_ops()

static void init_exec_ops | ( | void |  | ) |
| static

Definition at line 1059 of file exec.c.

References exec_close_1(), exec_files_info(), exec_get_section_table(), exec_has_memory(), exec_make_note_section(), exec_open(), exec_ops, exec_remove_breakpoint(), exec_xfer_partial(), file_stratum, ignore(), objfile_find_memory_regions(), OPS_MAGIC, target_ops::to_close, target_ops::to_doc, target_ops::to_files_info, target_ops::to_find_memory_regions, target_ops::to_get_section_table, target_ops::to_has_memory, target_ops::to_insert_breakpoint, target_ops::to_longname, target_ops::to_magic, target_ops::to_make_corefile_notes, target_ops::to_open, target_ops::to_remove_breakpoint, target_ops::to_shortname, target_ops::to_stratum, and target_ops::to_xfer_partial.

Referenced by _initialize_exec().

## ◆ print_section_info()

void print_section_info | ( | struct target_section_table * | t,
|  | bfd * | abfd
| ) |  |

Definition at line 878 of file exec.c.

References _, target_section::addr, target_section::endaddr, exec_bfd, gdbarch_addr_bit(), gdbarch_addr_bits_remove(), gdbarch_from_bfd(), hex_string_custom(), info_verbose, paddress(), printf_filtered(), target_section_table::sections, target_section_table::sections_end, target_section::the_bfd_section, warning(), and wrap_here().

Referenced by core_files_info(), and exec_files_info().

## ◆ remove_target_sections()

void remove_target_sections | ( | void * | owner | ) |

Definition at line 607 of file exec.c.

References ALL_PSPACES, current_target_sections, exec_ops, gdb_assert, target_section::owner, resize_section_table(), target_section_table::sections, target_section_table::sections_end, program_space::target_sections, and unpush_target().

Referenced by clear_solib(), exec_close(), reload_shared_libraries_1(), symfile_free_objfile(), and update_solib_list().

## ◆ resize_section_table()

static int resize_section_table | ( | struct target_section_table * | table,
|  | int | adjustment
| ) |  |
| static

Definition at line 484 of file exec.c.

References clear_section_table(), target_section_table::sections, target_section_table::sections_end, and XRESIZEVEC.

Referenced by add_target_sections(), add_target_sections_of_objfile(), and remove_target_sections().

## ◆ section_table_available_memory()

static std::vector<mem_range> section_table_available_memory | ( | CORE_ADDR | memaddr,
|  | ULONGEST | len,
|  | struct target_section * | sections,
|  | struct target_section * | sections_end
| ) |  |
| static

Definition at line 701 of file exec.c.

References mem_ranges_overlap().

Referenced by section_table_read_available_memory().

## ◆ section_table_read_available_memory()

enum target_xfer_status section_table_read_available_memory | ( | gdb_byte * | readbuf,
|  | ULONGEST | offset,
|  | ULONGEST | len,
|  | ULONGEST * | xfered_len
| ) |  |

Definition at line 736 of file exec.c.

References exec_ops, exec_read_partial_read_only(), gdb_assert, mem_ranges_overlap(), normalize_mem_ranges(), offset, section_table_available_memory(), target_section_table::sections, target_section_table::sections_end, status, target_get_section_table(), and TARGET_XFER_UNAVAILABLE.

Referenced by tfile_xfer_partial().

## ◆ section_table_xfer_memory_partial()

enum target_xfer_status section_table_xfer_memory_partial | ( | gdb_byte * | readbuf,
|  | const gdb_byte * | writebuf,
|  | ULONGEST | offset,
|  | ULONGEST | len,
|  | ULONGEST * | xfered_len,
|  | struct target_section * | sections,
|  | struct target_section * | sections_end,
|  | const char * | section_name
| ) |  |

Definition at line 776 of file exec.c.

References _, target_section::addr, target_section::endaddr, internal_error(), offset, TARGET_XFER_EOF, TARGET_XFER_OK, and target_section::the_bfd_section.

Referenced by core_xfer_partial(), exec_xfer_partial(), memory_xfer_partial_1(), and target_bfd_xfer_partial().

## ◆ set_section_command()

static void set_section_command | ( | const char * | args,
|  | int | from_tty
| ) |  |
| static

Definition at line 956 of file exec.c.

References _, target_section::addr, current_target_sections, target_section::endaddr, error(), exec_files_info(), exec_ops, offset, parse_and_eval_address(), target_section_table::sections, target_section_table::sections_end, and target_section::the_bfd_section.

Referenced by _initialize_exec().

## ◆ show_write_files()

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

Definition at line 64 of file exec.c.

References _, and fprintf_filtered().

Referenced by _initialize_exec().

## ◆ try_open_exec_file()

void try_open_exec_file | ( | const char * | exec_file_host,
|  | struct inferior * | inf,
|  | symfile_add_flags | add_flags
| ) |  |

Definition at line 133 of file exec.c.

References CATCH, do_cleanups(), END_CATCH, err, exception_none, exception_print_same(), exec_file_attach(), free_current_contents(), make_cleanup(), gdb_exception::message, RETURN_MASK_ERROR, symbol_file_add_main(), SYMFILE_VERBOSE, TRY, and warning().

Referenced by exec_file_locate_attach(), and follow_exec().

## Variable Documentation

## ◆ deprecated_file_changed_hook

void(* deprecated_file_changed_hook) (const char *)

Definition at line 48 of file exec.c.

Referenced by file_command().

## ◆ exec_ops

struct target_ops exec_ops
| static

Definition at line 58 of file exec.c.

Referenced by _initialize_exec(), add_target_sections(), init_exec_ops(), remove_target_sections(), section_table_read_available_memory(), and set_section_command().

## ◆ write_files

int write_files = 0

Definition at line 62 of file exec.c.

Referenced by _initialize_exec(), bsd_kvm_open(), captured_main_1(), core_open(), and exec_file_attach().