aboutsummaryrefslogtreecommitdiff
path: root/gdb/loongarch-linux-tdep.c
diff options
context:
space:
mode:
authorJohn Baldwin <jhb@FreeBSD.org>2022-05-23 10:59:13 -0700
committerJohn Baldwin <jhb@FreeBSD.org>2022-05-23 10:59:13 -0700
commitd9b6e047f60ce2129eff28ad1c6690949293366b (patch)
tree9229222f5825b12c511978d404bc754319b5a14b /gdb/loongarch-linux-tdep.c
parenta6b446b22270b52dd4739e9ab094e11b307ff0b5 (diff)
downloadbinutils-d9b6e047f60ce2129eff28ad1c6690949293366b.zip
binutils-d9b6e047f60ce2129eff28ad1c6690949293366b.tar.gz
binutils-d9b6e047f60ce2129eff28ad1c6690949293366b.tar.bz2
Fix loongarch_iterate_over_regset_sections for non-native targets.
Define a constant for the number of registers stored in a register set and use this with register_size to compute the size of the general-purpose register set in core dumps. This also fixes the build on hosts such as FreeBSD that do not define an elf_gregset_t type.
Diffstat (limited to 'gdb/loongarch-linux-tdep.c')
-rw-r--r--gdb/loongarch-linux-tdep.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/gdb/loongarch-linux-tdep.c b/gdb/loongarch-linux-tdep.c
index f13756d..bbb43ab 100644
--- a/gdb/loongarch-linux-tdep.c
+++ b/gdb/loongarch-linux-tdep.c
@@ -29,6 +29,11 @@
#include "trad-frame.h"
#include "tramp-frame.h"
+/* The general-purpose regset consists of 32 R registers, plus PC,
+ and BADV registers. */
+
+#define LOONGARCH_LINUX_NUM_GREGSET (34)
+
/* Unpack an elf_gregset_t into GDB's register cache. */
static void
@@ -172,8 +177,13 @@ loongarch_iterate_over_regset_sections (struct gdbarch *gdbarch,
void *cb_data,
const struct regcache *regcache)
{
- cb (".reg", sizeof (elf_gregset_t), sizeof (elf_gregset_t),
- &loongarch_gregset, NULL, cb_data);
+ loongarch_gdbarch_tdep *tdep
+ = (loongarch_gdbarch_tdep *) gdbarch_tdep (gdbarch);
+ auto regs = tdep->regs;
+ int regsize = register_size (gdbarch, regs.r);
+
+ cb (".reg", LOONGARCH_LINUX_NUM_GREGSET * regsize,
+ LOONGARCH_LINUX_NUM_GREGSET * regsize, &loongarch_gregset, NULL, cb_data);
}
/* Initialize LoongArch Linux ABI info. */