24 #ifdef HAVE_SYS_FILE_H
40 #include "readline/readline.h"
42 #include "filenames.h"
67 static struct gdbarch *core_gdbarch = NULL;
119 result = (bfd_get_flavour (abfd) == our_fns -> core_flavour);
139 for (cf = core_file_fns; cf != NULL; cf = cf->
next)
149 warning (
_(
"\"%s\": ambiguous core format, %d handlers match"),
150 bfd_get_filename (abfd), matches);
152 else if (matches == 0)
153 error (
_(
"\"%s\": no core file handler recognizes format"),
154 bfd_get_filename (abfd));
176 for (cf = core_file_fns; cf != NULL; cf = cf->
next)
233 asection *reg_sect = (asection *) reg_sect_arg;
237 if (!
startswith (bfd_section_name (abfd, asect),
".reg/"))
240 core_tid = atoi (bfd_section_name (abfd, asect) + 5);
265 && asect->filepos == reg_sect->filepos)
287 error (
_(
"No core file specified. (Use `detach' "
288 "to stop debugging a core file.)"));
290 error (
_(
"No core file specified."));
293 filename = tilde_expand (arg);
294 if (!IS_ABSOLUTE_PATH (filename))
297 filename, (
char *) NULL);
310 if (scratch_chan < 0)
316 if (temp_bfd == NULL)
319 if (!bfd_check_format (temp_bfd, bfd_core)
327 error (
_(
"\"%s\" is not a core dump: %s"),
328 filename, bfd_errmsg (bfd_get_error ()));
352 error (
_(
"\"%s\": Can't find sections: %s"),
353 bfd_get_filename (
core_bfd), bfd_errmsg (bfd_get_error ()));
385 bfd_get_section_by_name (
core_bfd,
".reg"));
424 p = bfd_core_file_failing_command (
core_bfd);
431 siggy = bfd_core_file_failing_signal (
core_bfd);
440 enum gdb_signal sig = (core_gdbarch != NULL
483 error (
_(
"Too many arguments"));
513 const char *human_name,
516 static char *section_name = NULL;
517 struct bfd_section *section;
521 xfree (section_name);
527 section_name = xstrdup (name);
529 section = bfd_get_section_by_name (
core_bfd, section_name);
533 warning (
_(
"Couldn't find %s registers in core file."),
538 size = bfd_section_size (
core_bfd, section);
541 warning (
_(
"Section `%s' in core file too small."), section_name);
546 warning (
_(
"Unexpected size of section `%s' in core file."),
550 contents = alloca (size);
551 if (! bfd_get_section_contents (
core_bfd, section, contents,
554 warning (
_(
"Couldn't read %s registers from `%s' section in core file."),
561 regset->
supply_regset (regset, regcache, -1, contents, size);
568 bfd_section_vma (
core_bfd, section)));
577 const char *human_name,
void *cb_data)
582 if (strcmp (sect_name,
".reg") == 0)
585 if (human_name == NULL)
586 human_name =
"general-purpose";
588 else if (strcmp (sect_name,
".reg2") == 0)
590 if (human_name == NULL)
591 human_name =
"floating-point";
597 size, -1, human_name, required);
618 "Can't fetch registers from this type of core file\n");
626 (
void *) regcache, NULL);
630 ".reg", 0, 0,
"general-purpose", 1);
632 ".reg2", 0, 2,
"floating-point", 0);
660 enum bfd_endian byte_order
661 = bfd_big_endian (abfd) ? BFD_ENDIAN_BIG : BFD_ENDIAN_LITTLE;
664 sscanf (bfd_section_name (abfd, asect),
"SPU/%d/regs%n", &fd, &pos);
687 const char *
name =
".note.linuxcore.siginfo";
693 section_name = xstrdup (name);
695 section = bfd_get_section_by_name (abfd, section_name);
696 xfree (section_name);
700 if (!bfd_get_section_contents (abfd, section, readbuf, offset, len))
708 const char *annex,
gdb_byte *readbuf,
716 offset, len, xfered_len,
727 struct bfd_section *section;
730 section = bfd_get_section_by_name (
core_bfd,
".auxv");
734 size = bfd_section_size (
core_bfd, section);
743 if (!bfd_get_section_contents (
core_bfd, section, readbuf,
744 (file_ptr) offset, size))
746 warning (
_(
"Couldn't read NT_AUXV note in core file."));
762 struct bfd_section *section;
765 section = bfd_get_section_by_name (
core_bfd,
".wcookie");
769 size = bfd_section_size (
core_bfd, section);
778 if (!bfd_get_section_contents (
core_bfd, section, readbuf,
779 (file_ptr) offset, size))
781 warning (
_(
"Couldn't read StackGhost cookie in core file."));
803 if (*xfered_len == 0)
824 if (*xfered_len == 0)
833 if (readbuf && annex)
839 struct bfd_section *section;
841 char sectionstr[100];
843 xsnprintf (sectionstr,
sizeof sectionstr,
"SPU/%s", annex);
845 section = bfd_get_section_by_name (
core_bfd, sectionstr);
849 size = bfd_section_size (
core_bfd, section);
858 if (!bfd_get_section_contents (
core_bfd, section, readbuf,
859 (file_ptr) offset, size))
861 warning (
_(
"Couldn't read SPU section in core file."));
906 writebuf, offset, len,
985 xsnprintf (buf,
sizeof buf,
"<main task>");
1029 "Use a core file as a target. Specify the filename of the core file.";
1050 _(
"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 ptid_equal(ptid_t ptid1, ptid_t ptid2)
int gdbarch_core_xfer_shared_libraries_p(struct gdbarch *gdbarch)
void clear_exit_convenience_vars(void)
struct target_section * sections_end
struct gdbarch * get_regcache_arch(const struct regcache *regcache)
int(* to_has_memory)(struct target_ops *)
void warning(const char *fmt,...)
char *(* to_pid_to_str)(struct target_ops *, ptid_t) TARGET_DEFAULT_FUNC(default_pid_to_str)
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 *)
void switch_to_thread(ptid_t ptid)
void _initialize_corelow(void)
static char * core_pid_to_str(struct target_ops *ops, ptid_t ptid)
int gdbarch_core_xfer_shared_libraries_aix_p(struct gdbarch *gdbarch)
struct inferior * find_inferior_ptid(ptid_t ptid)
int(* to_remove_breakpoint)(struct target_ops *, struct gdbarch *, struct bp_target_info *) TARGET_DEFAULT_FUNC(memory_remove_breakpoint)
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)
struct regcache * get_current_regcache(void)
void store_unsigned_integer(gdb_byte *, int, enum bfd_endian, ULONGEST)
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
char * gdbarch_core_pid_to_str(struct gdbarch *gdbarch, ptid_t ptid)
int gdbarch_iterate_over_regset_sections_p(struct gdbarch *gdbarch)
#define CATCH(EXCEPTION, MASK)
void gdb_bfd_unref(struct bfd *abfd)
void set_gdbarch_from_file(bfd *abfd)
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
bfd * gdb_bfd_fopen(const char *filename, const char *target, const char *mode, int fd)
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)
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)
char * xstrprintf(const char *format,...)
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
struct cleanup * make_cleanup_bfd_unref(bfd *abfd)
static void core_open(const char *arg, int from_tty)
char * normal_pid_to_str(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
int ptid_get_pid(ptid_t ptid)
static void core_detach(struct target_ops *ops, const char *args, int from_tty)
void print_stack_frame(struct frame_info *, int print_level, enum print_what print_what, int set_current_sal)
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
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)
struct ui_file * gdb_stderr
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 thread_command(char *tidstr, int from_tty)
void registers_changed(void)
static void init_core_ops(void)
void validate_files(void)
static void core_close(struct target_ops *self)
static int gdb_check_format(bfd *)
int gdb_open_cloexec(const char *filename, int flags, unsigned long mode)
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
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)
long ptid_get_lwp(ptid_t ptid)
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 *)
static LONGEST get_core_siginfo(bfd *abfd, gdb_byte *readbuf, ULONGEST offset, ULONGEST len)
int(* to_has_registers)(struct target_ops *)
int default_core_sniffer(struct core_fns *our_fns, bfd *abfd)
void error(const char *fmt,...)
int gdbarch_core_read_description_p(struct gdbarch *gdbarch)
mach_port_t mach_port_t name mach_port_t mach_port_t name error_t int int rusage_t pid_t pid
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 do_cleanups(struct cleanup *old_chain)
void init_thread_list(void)
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)
const ULONGEST const LONGEST len