aboutsummaryrefslogtreecommitdiff
path: root/gdb/gdbarch.c
diff options
context:
space:
mode:
authorSimon Marchi <simon.marchi@efficios.com>2023-12-01 11:27:30 -0500
committerSimon Marchi <simon.marchi@efficios.com>2023-12-14 16:04:49 +0000
commit1f624181f8a1b47710b6eda3934f1a74b1821657 (patch)
tree466bfc7e6e9d4d956911b6bacc39f4b8ee7c1e60 /gdb/gdbarch.c
parent7f0f3b0f5659f21815ef87e1e9e120213a4f347b (diff)
downloadbinutils-1f624181f8a1b47710b6eda3934f1a74b1821657.zip
binutils-1f624181f8a1b47710b6eda3934f1a74b1821657.tar.gz
binutils-1f624181f8a1b47710b6eda3934f1a74b1821657.tar.bz2
gdb: add gdbarch_pseudo_register_write that takes a frame
Add a new variant of gdbarch_pseudo_register_write that takes a frame_info in order to write raw registers. Use this new method when available: - in put_frame_register, when trying to write a pseudo register to a given frame - in regcache::cooked_write No implementation is migrated to use this new method (that will come in subsequent patches), so no behavior change is expected here. The objective is to fix writing pseudo registers to non-current frames. See previous commit "gdb: read pseudo register through frame" for a more detailed explanation. Change-Id: Ie7fe364a15a4d86c2ecb09de2b4baa08c45555ac Reviewed-By: John Baldwin <jhb@FreeBSD.org>
Diffstat (limited to 'gdb/gdbarch.c')
-rw-r--r--gdb/gdbarch.c32
1 files changed, 32 insertions, 0 deletions
diff --git a/gdb/gdbarch.c b/gdb/gdbarch.c
index e198d33..d584305 100644
--- a/gdb/gdbarch.c
+++ b/gdb/gdbarch.c
@@ -74,6 +74,7 @@ struct gdbarch
gdbarch_virtual_frame_pointer_ftype *virtual_frame_pointer = legacy_virtual_frame_pointer;
gdbarch_pseudo_register_read_ftype *pseudo_register_read = nullptr;
gdbarch_pseudo_register_read_value_ftype *pseudo_register_read_value = nullptr;
+ gdbarch_pseudo_register_write_ftype *pseudo_register_write = nullptr;
gdbarch_deprecated_pseudo_register_write_ftype *deprecated_pseudo_register_write = nullptr;
int num_regs = -1;
int num_pseudo_regs = 0;
@@ -330,6 +331,7 @@ verify_gdbarch (struct gdbarch *gdbarch)
/* Skip verify of virtual_frame_pointer, invalid_p == 0 */
/* Skip verify of pseudo_register_read, has predicate. */
/* Skip verify of pseudo_register_read_value, has predicate. */
+ /* Skip verify of pseudo_register_write, has predicate. */
/* Skip verify of deprecated_pseudo_register_write, has predicate. */
if (gdbarch->num_regs == -1)
log.puts ("\n\tnum_regs");
@@ -650,6 +652,12 @@ gdbarch_dump (struct gdbarch *gdbarch, struct ui_file *file)
"gdbarch_dump: pseudo_register_read_value = <%s>\n",
host_address_to_string (gdbarch->pseudo_register_read_value));
gdb_printf (file,
+ "gdbarch_dump: gdbarch_pseudo_register_write_p() = %d\n",
+ gdbarch_pseudo_register_write_p (gdbarch));
+ gdb_printf (file,
+ "gdbarch_dump: pseudo_register_write = <%s>\n",
+ host_address_to_string (gdbarch->pseudo_register_write));
+ gdb_printf (file,
"gdbarch_dump: gdbarch_deprecated_pseudo_register_write_p() = %d\n",
gdbarch_deprecated_pseudo_register_write_p (gdbarch));
gdb_printf (file,
@@ -1903,6 +1911,30 @@ set_gdbarch_pseudo_register_read_value (struct gdbarch *gdbarch,
}
bool
+gdbarch_pseudo_register_write_p (struct gdbarch *gdbarch)
+{
+ gdb_assert (gdbarch != NULL);
+ return gdbarch->pseudo_register_write != NULL;
+}
+
+void
+gdbarch_pseudo_register_write (struct gdbarch *gdbarch, frame_info_ptr next_frame, int pseudo_reg_num, gdb::array_view<const gdb_byte> buf)
+{
+ gdb_assert (gdbarch != NULL);
+ gdb_assert (gdbarch->pseudo_register_write != NULL);
+ if (gdbarch_debug >= 2)
+ gdb_printf (gdb_stdlog, "gdbarch_pseudo_register_write called\n");
+ gdbarch->pseudo_register_write (gdbarch, next_frame, pseudo_reg_num, buf);
+}
+
+void
+set_gdbarch_pseudo_register_write (struct gdbarch *gdbarch,
+ gdbarch_pseudo_register_write_ftype pseudo_register_write)
+{
+ gdbarch->pseudo_register_write = pseudo_register_write;
+}
+
+bool
gdbarch_deprecated_pseudo_register_write_p (struct gdbarch *gdbarch)
{
gdb_assert (gdbarch != NULL);