24 #ifdef HAVE_SYS_FILE_H 40 #include "readline/readline.h" 42 #include "filenames.h" 117 result = (bfd_get_flavour (abfd) == our_fns -> core_flavour);
147 warning (
_(
"\"%s\": ambiguous core format, %d handlers match"),
148 bfd_get_filename (abfd), matches);
150 else if (matches == 0)
151 error (
_(
"\"%s\": no core file handler recognizes format"),
152 bfd_get_filename (abfd));
231 asection *reg_sect = (asection *) reg_sect_arg;
235 if (!
startswith (bfd_section_name (abfd, asect),
".reg/"))
238 core_tid = atoi (bfd_section_name (abfd, asect) + 5);
263 && asect->filepos == reg_sect->filepos)
282 error (
_(
"No core file specified. (Use `detach' " 283 "to stop debugging a core file.)"));
285 error (
_(
"No core file specified."));
289 if (!IS_ABSOLUTE_PATH (filename.get ()))
291 filename.get (), (
char *) NULL));
299 if (scratch_chan < 0)
305 if (temp_bfd == NULL)
308 if (!bfd_check_format (temp_bfd.get (), bfd_core)
315 error (
_(
"\"%s\" is not a core dump: %s"),
316 filename.get (), bfd_errmsg (bfd_get_error ()));
339 error (
_(
"\"%s\": Can't find sections: %s"),
340 bfd_get_filename (
core_bfd), bfd_errmsg (bfd_get_error ()));
372 bfd_get_section_by_name (
core_bfd,
".reg"));
411 p = bfd_core_file_failing_command (
core_bfd);
418 siggy = bfd_core_file_failing_signal (
core_bfd);
470 error (
_(
"Too many arguments"));
500 const char *human_name,
503 struct bfd_section *section;
506 bool variable_size_section = (
regset != NULL
511 section = bfd_get_section_by_name (
core_bfd, section_name.c_str ());
515 warning (
_(
"Couldn't find %s registers in core file."),
523 warning (
_(
"Section `%s' in core file too small."),
524 section_name.c_str ());
527 if (
size != min_size && !variable_size_section)
529 warning (
_(
"Unexpected size of section `%s' in core file."),
530 section_name.c_str ());
533 contents = (
char *) alloca (
size);
534 if (! bfd_get_section_contents (
core_bfd, section, contents,
537 warning (
_(
"Couldn't read %s registers from `%s' section in core file."),
538 human_name, section_name.c_str ());
551 bfd_section_vma (
core_bfd, section)));
560 const char *human_name,
void *cb_data)
565 if (strcmp (sect_name,
".reg") == 0)
568 if (human_name == NULL)
569 human_name =
"general-purpose";
571 else if (strcmp (sect_name,
".reg2") == 0)
573 if (human_name == NULL)
574 human_name =
"floating-point";
580 size, -1, human_name, required);
601 "Can't fetch registers from this type of core file\n");
613 ".reg", 0, 0,
"general-purpose", 1);
615 ".reg2", 0, 2,
"floating-point", 0);
643 enum bfd_endian byte_order
644 = bfd_big_endian (abfd) ? BFD_ENDIAN_BIG : BFD_ENDIAN_LITTLE;
647 sscanf (bfd_section_name (abfd, asect),
"SPU/%d/regs%n", &fd, &
pos);
662 const char *annex,
gdb_byte *readbuf,
681 struct bfd_section *section;
684 section = bfd_get_section_by_name (
core_bfd,
".auxv");
697 if (!bfd_get_section_contents (
core_bfd, section, readbuf,
700 warning (
_(
"Couldn't read NT_AUXV note in core file."));
716 struct bfd_section *section;
719 section = bfd_get_section_by_name (
core_bfd,
".wcookie");
732 if (!bfd_get_section_contents (
core_bfd, section, readbuf,
735 warning (
_(
"Couldn't read StackGhost cookie in core file."));
757 if (*xfered_len == 0)
778 if (*xfered_len == 0)
787 if (readbuf && annex)
793 struct bfd_section *section;
795 char sectionstr[100];
797 xsnprintf (sectionstr,
sizeof sectionstr,
"SPU/%s", annex);
799 section = bfd_get_section_by_name (
core_bfd, sectionstr);
812 if (!bfd_get_section_contents (
core_bfd, section, readbuf,
815 warning (
_(
"Couldn't read SPU section in core file."));
953 if (
inf != NULL && !
inf->fake_pid_p)
957 xsnprintf (buf,
sizeof buf,
"<main task>");
1010 "Use a core file as a target. Specify the filename of the core file.";
1032 _(
"init_core_ops: core target already exists (\"%s\")."),
int default_check_format(bfd *abfd)
struct thread_info * add_thread(ptid_t ptid)
const struct target_desc *(* to_read_description)(struct target_ops *ops) TARGET_DEFAULT_RETURN(NULL)
struct frame_info * get_selected_frame(const char *message)
void(* core_read_registers)(struct regcache *regcache, char *core_reg_sect, unsigned core_reg_size, int which, CORE_ADDR reg_addr)
void post_create_inferior(struct target_ops *target, int from_tty)
int gdbarch_core_xfer_shared_libraries_p(struct gdbarch *gdbarch)
int ptid_get_pid(const ptid_t &ptid)
mach_port_t mach_port_t name mach_port_t mach_port_t name kern_return_t int int rusage_t pid_t pid
void clear_exit_convenience_vars(void)
struct target_section * sections_end
int(* to_has_memory)(struct target_ops *)
void warning(const char *fmt,...)
static void core_close_cleanup(void *ignore)
int(* to_has_stack)(struct target_ops *)
void push_target(struct target_ops *t)
static struct target_section_table * core_data
int(* to_insert_breakpoint)(struct target_ops *, struct gdbarch *, struct bp_target_info *) TARGET_DEFAULT_FUNC(memory_insert_breakpoint)
int build_section_table(struct bfd *some_bfd, struct target_section **start, struct target_section **end)
int unpush_target(struct target_ops *t)
void internal_error(const char *file, int line, const char *fmt,...)
const struct target_desc * gdbarch_core_read_description(struct gdbarch *gdbarch, struct target_ops *target, bfd *abfd)
static struct core_fns * sniff_core_bfd(bfd *)
ULONGEST gdbarch_core_xfer_shared_libraries_aix(struct gdbarch *gdbarch, gdb_byte *readbuf, ULONGEST offset, ULONGEST len)
void(* to_close)(struct target_ops *)
const char *(* to_pid_to_str)(struct target_ops *, ptid_t) TARGET_DEFAULT_FUNC(default_pid_to_str)
void _initialize_corelow(void)
void filename_completer(struct cmd_list_element *ignore, completion_tracker &tracker, const char *text, const char *word)
int gdbarch_core_xfer_shared_libraries_aix_p(struct gdbarch *gdbarch)
struct inferior * find_inferior_ptid(ptid_t ptid)
struct thread_info * first_thread_of_process(int pid)
int gdbarch_num_regs(struct gdbarch *gdbarch)
void target_fetch_registers(struct regcache *regcache, int regno)
struct internalvar * lookup_internalvar(const char *name)
ULONGEST gdbarch_core_xfer_shared_libraries(struct gdbarch *gdbarch, gdb_byte *readbuf, ULONGEST offset, ULONGEST len)
static void get_core_register_section(struct regcache *regcache, const struct regset *regset, const char *name, int min_size, int which, const char *human_name, int required)
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 int core_remove_breakpoint(struct target_ops *ops, struct gdbarch *gdbarch, struct bp_target_info *bp_tgt, enum remove_bp_reason reason)
struct regcache * get_current_regcache(void)
void printf_filtered(const char *format,...)
static void core_info_proc(struct target_ops *ops, const char *args, enum info_proc_what request)
ptid_t ptid_build(int pid, long lwp, long tid)
void(* to_files_info)(struct target_ops *) TARGET_DEFAULT_IGNORE()
mach_port_t kern_return_t mach_port_t msgports mach_port_t kern_return_t pid_t pid mach_port_t kern_return_t mach_port_t task mach_port_t kern_return_t int flags
const char * normal_pid_to_str(ptid_t ptid)
void switch_to_thread(ptid_t ptid)
int gdbarch_iterate_over_regset_sections_p(struct gdbarch *gdbarch)
#define CATCH(EXCEPTION, MASK)
static const char * core_pid_to_str(struct target_ops *ops, ptid_t ptid)
std::unique_ptr< T, xfree_deleter< T > > unique_xmalloc_ptr
void gdb_bfd_unref(struct bfd *abfd)
void set_gdbarch_from_file(bfd *abfd)
gdb_bfd_ref_ptr gdb_bfd_fopen(const char *filename, const char *target, const char *mode, int fd)
void fprintf_filtered(struct ui_file *stream, const char *format,...)
static void add_to_spuid_list(bfd *abfd, asection *asect, void *list_p)
static void add_to_thread_list(bfd *, asection *, void *)
int gdbarch_core_info_proc_p(struct gdbarch *gdbarch)
static struct target_ops core_ops
void exception_print(struct ui_file *file, struct gdb_exception e)
int gdbarch_core_pid_to_str_p(struct gdbarch *gdbarch)
ptid_t pid_to_ptid(int pid)
struct cleanup * make_cleanup(make_cleanup_ftype *function, void *arg)
int(* core_sniffer)(struct core_fns *, bfd *)
struct target_section * sections
void add_target_with_completer(struct target_ops *t, completer_ftype *completer)
enum gdb_signal gdb_signal_from_host(int)
#define REGSET_VARIABLE_SIZE
static int core_has_memory(struct target_ops *ops)
struct gdbarch * get_current_arch(void)
const char * gdbarch_core_thread_name(struct gdbarch *gdbarch, struct thread_info *thr)
static int startswith(const char *string, const char *pattern)
int gdbarch_gdb_signal_from_target_p(struct gdbarch *gdbarch)
struct thread_info * add_thread_silent(ptid_t ptid)
const char * gdb_signal_to_name(enum gdb_signal)
void deprecated_add_core_fns(struct core_fns *cf)
enum target_xfer_status(* to_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) TARGET_DEFAULT_RETURN(TARGET_XFER_E_IO)
static enum target_xfer_status core_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(* to_detach)(struct target_ops *ops, const char *, int) TARGET_DEFAULT_IGNORE()
supply_regset_ftype * supply_regset
int gdbarch_core_thread_name_p(struct gdbarch *gdbarch)
static void core_open(const char *arg, int from_tty)
long ptid_get_lwp(const ptid_t &ptid)
void gdbarch_core_info_proc(struct gdbarch *gdbarch, const char *args, enum info_proc_what what)
int(* check_format)(bfd *)
struct target_ops * core_target
static void core_detach(struct target_ops *ops, const char *args, int from_tty)
void thread_command(const char *tidstr, int from_tty)
void print_stack_frame(struct frame_info *, int print_level, enum print_what print_what, int set_current_sal)
static const char * core_thread_name(struct target_ops *self, struct thread_info *thr)
void target_update_thread_list(void)
struct gdbarch * gdbarch_from_bfd(bfd *abfd)
void discard_cleanups(struct cleanup *old_chain)
void(* to_fetch_registers)(struct target_ops *, struct regcache *, int) TARGET_DEFAULT_IGNORE()
void void void void void void void void void perror_with_name(const char *string) ATTRIBUTE_NORETURN
static struct core_fns * core_vec
enum register_status regcache_register_status(const struct regcache *regcache, int regnum)
static struct core_fns * core_file_fns
int xsnprintf(char *str, size_t size, const char *format,...)
enum gdb_signal gdbarch_gdb_signal_from_target(struct gdbarch *gdbarch, int signo)
void set_internalvar_integer(struct internalvar *var, LONGEST l)
static void get_core_registers_cb(const char *sect_name, int size, const struct regset *regset, const char *human_name, void *cb_data)
void(* to_open)(const char *, int)
void registers_changed(void)
static void init_core_ops(void)
void validate_files(void)
static void core_close(struct target_ops *self)
int(* to_remove_breakpoint)(struct target_ops *, struct gdbarch *, struct bp_target_info *, enum remove_bp_reason) TARGET_DEFAULT_FUNC(memory_remove_breakpoint)
int gdbarch_core_xfer_siginfo_p(struct gdbarch *gdbarch)
static int gdb_check_format(bfd *)
LONGEST gdbarch_core_xfer_siginfo(struct gdbarch *gdbarch, gdb_byte *readbuf, ULONGEST offset, ULONGEST len)
int gdb_open_cloexec(const char *filename, int flags, unsigned long mode)
int ptid_equal(const ptid_t &ptid1, const ptid_t &ptid2)
struct inferior * current_inferior(void)
void regcache_raw_supply(struct regcache *regcache, int regnum, const void *buf)
const char * to_shortname
unsigned long long ULONGEST
const char * gdbarch_core_pid_to_str(struct gdbarch *gdbarch, ptid_t ptid)
void exit_inferior_silent(int pid)
static int ignore(struct target_ops *ops, struct gdbarch *gdbarch, struct bp_target_info *bp_tgt)
static int core_has_stack(struct target_ops *ops)
static int core_thread_alive(struct target_ops *ops, ptid_t ptid)
const char * gdb_signal_to_string(enum gdb_signal)
static const struct target_desc * core_read_description(struct target_ops *target)
int(* to_thread_alive)(struct target_ops *, ptid_t ptid) TARGET_DEFAULT_RETURN(0)
void(* to_info_proc)(struct target_ops *, const char *, enum info_proc_what)
void target_preopen(int from_tty)
void reinit_frame_cache(void)
static void core_files_info(struct target_ops *)
int(* to_has_registers)(struct target_ops *)
int default_core_sniffer(struct core_fns *our_fns, bfd *abfd)
void error(const char *fmt,...)
const char *(* to_thread_name)(struct target_ops *, struct thread_info *) TARGET_DEFAULT_RETURN(NULL)
int gdbarch_core_read_description_p(struct gdbarch *gdbarch)
struct target_ops * beneath
static void get_core_registers(struct target_ops *ops, struct regcache *regcache, int regno)
void inferior_appeared(struct inferior *inf, int pid)
void print_section_info(struct target_section_table *t, bfd *abfd)
void init_thread_list(void)
static void store_unsigned_integer(gdb_byte *addr, int len, enum bfd_endian byte_order, ULONGEST val)
static struct gdbarch * core_gdbarch
void gdbarch_iterate_over_regset_sections(struct gdbarch *gdbarch, iterate_over_regset_sections_cb *cb, void *cb_data, const struct regcache *regcache)
static int core_has_registers(struct target_ops *ops)