diff options
author | Alan Hayward <alan.hayward@arm.com> | 2018-08-13 10:04:11 +0100 |
---|---|---|
committer | Alan Hayward <alan.hayward@arm.com> | 2018-08-13 10:16:41 +0100 |
commit | a616bb94509c22c96ae8bf1432ec28a7f3e31778 (patch) | |
tree | cec4cbdc93deaceb249df32a4914668d7d48ef45 /gdb/linux-tdep.c | |
parent | facbd8bd3d6d51c907494a269dc13a2a0a75bc4e (diff) | |
download | gdb-a616bb94509c22c96ae8bf1432ec28a7f3e31778.zip gdb-a616bb94509c22c96ae8bf1432ec28a7f3e31778.tar.gz gdb-a616bb94509c22c96ae8bf1432ec28a7f3e31778.tar.bz2 |
Split size in regset section iterators
In the existing code, when using the regset section iteration functions, the
size parameter is used in different ways.
With collect, size is used to create the buffer in which to write the regset.
(see linux-tdep.c::linux_collect_regset_section_cb).
With supply, size is used to confirm the existing regset is the correct size.
If REGSET_VARIABLE_SIZE is set then the regset can be bigger than size.
Effectively, size is the minimum possible size of the regset.
(see corelow.c::get_core_register_section).
There are currently no targets with both REGSET_VARIABLE_SIZE and a collect
function.
In SVE, a corefile can contain one of two formats after the header, both of
which are different sizes. However, when writing a core file, we always want
to write out the full bigger size.
To allow support of collects for REGSET_VARIABLE_SIZE we need two sizes.
This is done by adding supply_size and collect_size.
gdb/
* aarch64-fbsd-tdep.c
(aarch64_fbsd_iterate_over_regset_sections): Add supply_size and
collect_size.
* aarch64-linux-tdep.c
(aarch64_linux_iterate_over_regset_sections): Likewise.
* alpha-linux-tdep.c
(alpha_linux_iterate_over_regset_sections):
* alpha-nbsd-tdep.c
(alphanbsd_iterate_over_regset_sections): Likewise.
* amd64-fbsd-tdep.c
(amd64fbsd_iterate_over_regset_sections): Likewise.
* amd64-linux-tdep.c
(amd64_linux_iterate_over_regset_sections): Likewise.
* arm-bsd-tdep.c
(armbsd_iterate_over_regset_sections): Likewise.
* arm-fbsd-tdep.c
(arm_fbsd_iterate_over_regset_sections): Likewise.
* arm-linux-tdep.c
(arm_linux_iterate_over_regset_sections): Likewise.
* corelow.c (get_core_registers_cb): Likewise.
(core_target::fetch_registers): Likewise.
* fbsd-tdep.c (fbsd_collect_regset_section_cb): Likewise.
* frv-linux-tdep.c (frv_linux_iterate_over_regset_sections): Likewise.
* gdbarch.h (void): Regenerate.
* gdbarch.sh: Add supply_size and collect_size.
* hppa-linux-tdep.c (hppa_linux_iterate_over_regset_sections): Likewise.
* hppa-nbsd-tdep.c (hppanbsd_iterate_over_regset_sections): Likewise.
* hppa-obsd-tdep.c (hppaobsd_iterate_over_regset_sections): Likewise.
* i386-fbsd-tdep.c (i386fbsd_iterate_over_regset_sections): Likewise.
* i386-linux-tdep.c (i386_linux_iterate_over_regset_sections): Likewise.
* i386-tdep.c (i386_iterate_over_regset_sections): Likewise.
* ia64-linux-tdep.c (ia64_linux_iterate_over_regset_sections): Likewise.
* linux-tdep.c (linux_collect_regset_section_cb): Likewise.
* m32r-linux-tdep.c (m32r_linux_iterate_over_regset_sections): Likewise.
* m68k-bsd-tdep.c (m68kbsd_iterate_over_regset_sections): Likewise.
* m68k-linux-tdep.c (m68k_linux_iterate_over_regset_sections): Likewise.
* mips-fbsd-tdep.c (mips_fbsd_iterate_over_regset_sections): Likewise.
* mips-linux-tdep.c (mips_linux_iterate_over_regset_sections): Likewise.
* mips-nbsd-tdep.c (mipsnbsd_iterate_over_regset_sections): Likewise.
* mips64-obsd-tdep.c (mips64obsd_iterate_over_regset_sections): Likewise.
* mn10300-linux-tdep.c (am33_iterate_over_regset_sections): Likewise.
* nios2-linux-tdep.c (nios2_iterate_over_regset_sections): Likewise.
* ppc-fbsd-tdep.c (ppcfbsd_iterate_over_regset_sections): Likewise.
* ppc-linux-tdep.c (ppc_linux_iterate_over_regset_sections): Likewise.
* ppc-nbsd-tdep.c (ppcnbsd_iterate_over_regset_sections): Likewise.
* ppc-obsd-tdep.c (ppcobsd_iterate_over_regset_sections): Likewise.
* riscv-linux-tdep.c (riscv_linux_iterate_over_regset_sections): Likewise.
* rs6000-aix-tdep.c (rs6000_aix_iterate_over_regset_sections): Likewise.
* s390-linux-tdep.c (s390_iterate_over_regset_sections): Likewise.
* score-tdep.c (score7_linux_iterate_over_regset_sections): Likewise.
* sh-tdep.c (sh_iterate_over_regset_sections): Likewise.
* sparc-tdep.c (sparc_iterate_over_regset_sections): Likewise.
* tilegx-linux-tdep.c (tilegx_iterate_over_regset_sections): Likewise.
* vax-tdep.c (vax_iterate_over_regset_sections): Likewise.
* xtensa-tdep.c (xtensa_iterate_over_regset_sections): Likewise.
Diffstat (limited to 'gdb/linux-tdep.c')
-rw-r--r-- | gdb/linux-tdep.c | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/gdb/linux-tdep.c b/gdb/linux-tdep.c index 3cfa2a5..5801ab5 100644 --- a/gdb/linux-tdep.c +++ b/gdb/linux-tdep.c @@ -1579,21 +1579,26 @@ struct linux_collect_regset_section_cb_data regset in the corefile note section. */ static void -linux_collect_regset_section_cb (const char *sect_name, int size, - const struct regset *regset, +linux_collect_regset_section_cb (const char *sect_name, int supply_size, + int collect_size, const struct regset *regset, const char *human_name, void *cb_data) { char *buf; struct linux_collect_regset_section_cb_data *data = (struct linux_collect_regset_section_cb_data *) cb_data; + bool variable_size_section = (regset != NULL + && regset->flags & REGSET_VARIABLE_SIZE); + + if (!variable_size_section) + gdb_assert (supply_size == collect_size); if (data->abort_iteration) return; gdb_assert (regset && regset->collect_regset); - buf = (char *) xmalloc (size); - regset->collect_regset (regset, data->regcache, -1, buf, size); + buf = (char *) xmalloc (collect_size); + regset->collect_regset (regset, data->regcache, -1, buf, collect_size); /* PRSTATUS still needs to be treated specially. */ if (strcmp (sect_name, ".reg") == 0) @@ -1603,7 +1608,7 @@ linux_collect_regset_section_cb (const char *sect_name, int size, else data->note_data = (char *) elfcore_write_register_note (data->obfd, data->note_data, data->note_size, - sect_name, buf, size); + sect_name, buf, collect_size); xfree (buf); if (data->note_data == NULL) |