aboutsummaryrefslogtreecommitdiff
path: root/gdb/corelow.c
diff options
context:
space:
mode:
authorAndreas Arnez <arnez@linux.vnet.ibm.com>2014-09-12 08:42:48 +0000
committerAndreas Krebbel <krebbel@linux.vnet.ibm.com>2014-09-30 09:14:33 +0200
commit8f0435f75e3c9676d2e177ce055fed3155fd9476 (patch)
tree08032004cab3c1c432651500560db02af97b86bc /gdb/corelow.c
parent5aa82d050d61784823767fe3c982b6862fa47391 (diff)
downloadgdb-8f0435f75e3c9676d2e177ce055fed3155fd9476.zip
gdb-8f0435f75e3c9676d2e177ce055fed3155fd9476.tar.gz
gdb-8f0435f75e3c9676d2e177ce055fed3155fd9476.tar.bz2
Add 'regset' parameter to 'iterate_over_regset_sections_cb'
This adds the 'regset' parameter to the iterator callback. Consequently the 'regset_from_core_section' method is dropped for all targets that provide the iterator method. This change prepares for replacing regset_from_core_section everywhere, thereby eliminating one gdbarch interface. Since the iterator is usually no more complex than regset_from_core_section alone, targets that previously didn't define core_regset_sections will then gain multi-arch capable core file generation support without increased complexity. gdb/ChangeLog: * gdbarch.sh (iterate_over_regset_sections_cb): Add regset parameter. * gdbarch.h: Regenerate. * corelow.c (sniff_core_bfd): Don't sniff if gdbarch has a regset iterator. (get_core_register_section): Add parameter 'regset' and use it, if set. Add parameter 'min_size' and verify the bfd section size against it. (get_core_registers_cb): Add parameter 'regset' and pass it to get_core_register section. For the "standard" register sections ".reg" and ".reg2", set an appropriate default for human_name. (get_core_registers): Don't abort when the gdbarch has an iterator but no regset_from_core_section. Add NULL/0 for parameters 'regset'/'min_size' in calls to get_core_register_section. * linux-tdep.c (linux_collect_regset_section_cb): Add parameter 'regset' and use it instead of calling the regset_from_core_section gdbarch method. * i386-tdep.h (struct gdbarch_tdep): Add field 'fpregset'. * i386-tdep.c (i386_supply_xstateregset) (i386_collect_xstateregset, i386_xstateregset): Moved to i386-linux-tdep.c. (i386_regset_from_core_section): Drop handling for .reg-xfp and .reg-xstate. (i386_gdbarch_init): Set tdep field 'fpregset'. Enable generic core file support only if the regset iterator hasn't been set. * i386-linux-tdep.c (i386_linux_supply_xstateregset) (i386_linux_collect_xstateregset, i386_linux_xstateregset): New. Moved from i386-tdep.c and renamed to *_linux*. (i386_linux_iterate_over_regset_sections): Add regset parameter to each callback invocation. Allow any .reg-xstate size when reading from a core file. * amd64-tdep.c (amd64_supply_xstateregset) (amd64_collect_xstateregset, amd64_xstateregset): Moved to amd64-linux-tdep.c. (amd64_regset_from_core_section): Remove. (amd64_init_abi): Set new tdep field 'fpregset'. No longer install an amd64-specific regset_from_core_section gdbarch method. * amd64-linux-tdep.c (amd64_linux_supply_xstateregset) (amd64_linux_collect_xstateregset, amd64_linux_xstateregset): New. Moved from amd64-tdep.c and renamed to *_linux*. (amd64_linux_iterate_over_regset_sections): Add regset parameter to each callback invocation. Allow any .reg-xstate size when reading from a core file. * arm-linux-tdep.c (arm_linux_regset_from_core_section): Remove. (arm_linux_iterate_over_regset_sections): Add regset parameter to each callback invocation. (arm_linux_init_abi): No longer set the regset_from_core_section gdbarch method. * ppc-linux-tdep.c (ppc_linux_regset_from_core_section): Remove. (ppc_linux_iterate_over_regset_sections): Add regset parameter to each callback invocation. (ppc_linux_init_abi): No longer set the regset_from_core_section gdbarch method. * s390-linux-tdep.c (struct gdbarch_tdep): Remove the fields gregset, sizeof_gregset, fpregset, and sizeof_fpregset. (s390_regset_from_core_section): Remove. (s390_iterate_over_regset_sections): Add regset parameter to each callback invocation. (s390_gdbarch_init): No longer set the regset_from_core_section gdbarch method. Drop initialization of deleted tdep fields.
Diffstat (limited to 'gdb/corelow.c')
-rw-r--r--gdb/corelow.c52
1 files changed, 39 insertions, 13 deletions
diff --git a/gdb/corelow.c b/gdb/corelow.c
index 7e64e1d..42af7f4 100644
--- a/gdb/corelow.c
+++ b/gdb/corelow.c
@@ -134,7 +134,9 @@ 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)
+ || gdbarch_regset_from_core_section_p (core_gdbarch)))
return NULL;
for (cf = core_file_fns; cf != NULL; cf = cf->next)
@@ -489,7 +491,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)
@@ -517,6 +521,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))
@@ -526,10 +536,9 @@ get_core_register_section (struct regcache *regcache,
return;
}
- if (core_gdbarch && gdbarch_regset_from_core_section_p (core_gdbarch))
+ if (regset == NULL
+ && core_gdbarch && gdbarch_regset_from_core_section_p (core_gdbarch))
{
- const struct regset *regset;
-
regset = gdbarch_regset_from_core_section (core_gdbarch,
name, size);
if (regset == NULL)
@@ -539,7 +548,10 @@ get_core_register_section (struct regcache *regcache,
human_name);
return;
}
+ }
+ if (regset != NULL)
+ {
regset->supply_regset (regset, regcache, -1, contents, size);
return;
}
@@ -555,16 +567,28 @@ get_core_register_section (struct regcache *regcache,
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)
- get_core_register_section (regcache, sect_name, 0, human_name, 1);
+ {
+ required = 1;
+ if (human_name == NULL)
+ human_name = "general-purpose";
+ }
else if (strcmp (sect_name, ".reg2") == 0)
- get_core_register_section (regcache, sect_name, 2, human_name, 0);
- else
- get_core_register_section (regcache, sect_name, 3, human_name, 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-
@@ -581,7 +605,9 @@ get_core_registers (struct target_ops *ops,
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)
+ || gdbarch_regset_from_core_section_p (core_gdbarch)))
&& (core_vec == NULL || core_vec->core_read_registers == NULL))
{
fprintf_filtered (gdb_stderr,
@@ -596,10 +622,10 @@ get_core_registers (struct target_ops *ops,
(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. */