From bccb2e7f89c67edc89322284e3f06f23278983d0 Mon Sep 17 00:00:00 2001 From: Andrew Cagney Date: Tue, 17 Feb 1998 04:28:00 +0000 Subject: [PATCH] Pass REGISTER_RAW_SIZE to sim_{fetch,store}_register. Verify returned register size. --- gdb/ChangeLog | 6 ++++++ gdb/remote-sim.c | 18 ++++++++++++------ 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index c59ba9d3dee..80e7ec7b3fd 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,9 @@ +Tue Feb 17 14:32:18 1998 Andrew Cagney + + * remote-sim.c (gdbsim_fetch_register, gdbsim_store_register): + Pass register size to sim_{fetch,store}_register. Check nr of + register bytes transfered is correct. + Mon Feb 16 14:05:54 1998 Andrew Cagney * remote-d10v.c (remote_d10v_open): Call push_remote_target diff --git a/gdb/remote-sim.c b/gdb/remote-sim.c index 69c474aa41c..70f32215188 100644 --- a/gdb/remote-sim.c +++ b/gdb/remote-sim.c @@ -337,7 +337,7 @@ gdb_os_error (p, va_alist) static void gdbsim_fetch_register (regno) -int regno; + int regno; { if (regno == -1) { @@ -347,8 +347,12 @@ int regno; else if (reg_names[regno] != NULL && *reg_names[regno] != '\0') { char buf[MAX_REGISTER_RAW_SIZE]; - - sim_fetch_register (gdbsim_desc, regno, buf); + int nr_bytes = sim_fetch_register (gdbsim_desc, regno, buf, REGISTER_RAW_SIZE (regno)); + if (nr_bytes == 0) + /* register not applicable, supply zero's */ + memset (buf, 0, MAX_REGISTER_RAW_SIZE); + else if (nr_bytes > 0 && nr_bytes != REGISTER_RAW_SIZE (regno)) + fatal ("Register size different to expected"); supply_register (regno, buf); if (sr_get_debug ()) { @@ -362,7 +366,7 @@ int regno; static void gdbsim_store_register (regno) -int regno; + int regno; { if (regno == -1) { @@ -371,10 +375,12 @@ int regno; } else if (reg_names[regno] != NULL && *reg_names[regno] != '\0') { - /* FIXME: Until read_register() returns LONGEST, we have this. */ char tmp[MAX_REGISTER_RAW_SIZE]; + int nr_bytes; read_register_gen (regno, tmp); - sim_store_register (gdbsim_desc, regno, tmp); + nr_bytes = sim_store_register (gdbsim_desc, regno, tmp, REGISTER_RAW_SIZE (regno)); + if (nr_bytes > 0 && nr_bytes != REGISTER_RAW_SIZE (regno)) + fatal ("Register size different to expected"); if (sr_get_debug ()) { printf_filtered ("gdbsim_store_register: %d", regno); -- 2.30.2