X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=gdb%2Fcorelow.c;h=dc22f2ba038d38e4b7689419937d0a8178d43d26;hb=012d8ebc4bd1a1afb95d902604007b04762207f0;hp=699fd2726b87c1d0e3946027f89bfa3ab6db1154;hpb=dccbb60975cdbcd6a906a79d0c4308b040fdac1b;p=platform%2Fupstream%2Fbinutils.git diff --git a/gdb/corelow.c b/gdb/corelow.c index 699fd27..dc22f2b 100644 --- a/gdb/corelow.c +++ b/gdb/corelow.c @@ -19,8 +19,6 @@ #include "defs.h" #include "arch-utils.h" -#include -#include #include #include #ifdef HAVE_SYS_FILE_H @@ -40,7 +38,6 @@ #include "symfile.h" #include "exec.h" #include "readline/readline.h" -#include "exceptions.h" #include "solib.h" #include "filenames.h" #include "progspace.h" @@ -136,7 +133,7 @@ sniff_core_bfd (bfd *abfd) /* Don't sniff if we have support for register sets in CORE_GDBARCH. */ - if (core_gdbarch && gdbarch_regset_from_core_section_p (core_gdbarch)) + if (core_gdbarch && gdbarch_iterate_over_regset_sections_p (core_gdbarch)) return NULL; for (cf = core_file_fns; cf != NULL; cf = cf->next) @@ -491,7 +488,9 @@ core_detach (struct target_ops *ops, const char *args, int from_tty) 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) @@ -519,6 +518,12 @@ get_core_register_section (struct regcache *regcache, } size = bfd_section_size (core_bfd, section); + if (size < min_size) + { + warning (_("Section `%s' in core file too small."), section_name); + return; + } + contents = alloca (size); if (! bfd_get_section_contents (core_bfd, section, contents, (file_ptr) 0, size)) @@ -528,20 +533,8 @@ get_core_register_section (struct regcache *regcache, return; } - if (core_gdbarch && gdbarch_regset_from_core_section_p (core_gdbarch)) + if (regset != NULL) { - const struct regset *regset; - - regset = gdbarch_regset_from_core_section (core_gdbarch, - name, size); - if (regset == NULL) - { - if (required) - warning (_("Couldn't recognize %s registers in core file."), - human_name); - return; - } - regset->supply_regset (regset, regcache, -1, contents, size); return; } @@ -552,6 +545,34 @@ get_core_register_section (struct regcache *regcache, bfd_section_vma (core_bfd, section))); } +/* Callback for get_core_registers that handles a single core file + register note section. */ + +static void +get_core_registers_cb (const char *sect_name, int size, + const struct regset *regset, + const char *human_name, void *cb_data) +{ + struct regcache *regcache = (struct regcache *) cb_data; + int required = 0; + + if (strcmp (sect_name, ".reg") == 0) + { + required = 1; + if (human_name == NULL) + human_name = "general-purpose"; + } + else if (strcmp (sect_name, ".reg2") == 0) + { + if (human_name == NULL) + human_name = "floating-point"; + } + + /* The 'which' parameter is only used when no regset is provided. + Thus we just set it to -1. */ + get_core_register_section (regcache, regset, sect_name, + size, -1, human_name, required); +} /* Get the registers out of a core file. This is the machine- independent part. Fetch_core_registers is the machine-dependent @@ -564,10 +585,10 @@ static void get_core_registers (struct target_ops *ops, struct regcache *regcache, int regno) { - struct core_regset_section *sect_list; int i; + struct gdbarch *gdbarch; - if (!(core_gdbarch && gdbarch_regset_from_core_section_p (core_gdbarch)) + if (!(core_gdbarch && gdbarch_iterate_over_regset_sections_p (core_gdbarch)) && (core_vec == NULL || core_vec->core_read_registers == NULL)) { fprintf_filtered (gdb_stderr, @@ -575,29 +596,17 @@ get_core_registers (struct target_ops *ops, return; } - sect_list = gdbarch_core_regset_sections (get_regcache_arch (regcache)); - if (sect_list) - while (sect_list->sect_name != NULL) - { - if (strcmp (sect_list->sect_name, ".reg") == 0) - get_core_register_section (regcache, sect_list->sect_name, - 0, sect_list->human_name, 1); - else if (strcmp (sect_list->sect_name, ".reg2") == 0) - get_core_register_section (regcache, sect_list->sect_name, - 2, sect_list->human_name, 0); - else - get_core_register_section (regcache, sect_list->sect_name, - 3, sect_list->human_name, 0); - - sect_list++; - } - + gdbarch = get_regcache_arch (regcache); + if (gdbarch_iterate_over_regset_sections_p (gdbarch)) + gdbarch_iterate_over_regset_sections (gdbarch, + get_core_registers_cb, + (void *) regcache, NULL); else { - get_core_register_section (regcache, - ".reg", 0, "general-purpose", 1); - get_core_register_section (regcache, - ".reg2", 2, "floating-point", 0); + get_core_register_section (regcache, NULL, + ".reg", 0, 0, "general-purpose", 1); + get_core_register_section (regcache, NULL, + ".reg2", 0, 2, "floating-point", 0); } /* Mark all registers not found in the core as unavailable. */ @@ -736,7 +745,7 @@ core_xfer_partial (struct target_ops *ops, enum target_object object, size = bfd_section_size (core_bfd, section); if (offset >= size) - return 0; + return TARGET_XFER_EOF; size -= offset; if (size > len) size = len;