diff options
author | Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> | 2025-01-09 09:06:00 +0100 |
---|---|---|
committer | Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> | 2025-01-09 09:06:00 +0100 |
commit | 60d95017ec97801b96181a29d1554e2ec69905cf (patch) | |
tree | 8d064876140332aa24e6b1d0d4e4efae0f12d8fb | |
parent | 42bcf692abd52ec1cb9d4bf3eca545e3b33fe536 (diff) | |
download | binutils-60d95017ec97801b96181a29d1554e2ec69905cf.zip binutils-60d95017ec97801b96181a29d1554e2ec69905cf.tar.gz binutils-60d95017ec97801b96181a29d1554e2ec69905cf.tar.bz2 |
gdbserver: dump 'xx...x' in collect_register_as_string for unavailable register
Fix 'collect_register_as_string' so that unavailable registers are
dumped as 'xx...x' instead of arbitrary values, in particular when
reporting expedited registers in a resume reply packet. This change
gives the opportunity that we can reuse 'collect_register_as_string'
in 'registers_to_string' for additional code simplification.
Reviewed-By: Luis Machado <luis.machado@arm.com>
Approved-By: Simon Marchi <simon.marchi@efficios.com>
-rw-r--r-- | gdbserver/regcache.cc | 25 |
1 files changed, 11 insertions, 14 deletions
diff --git a/gdbserver/regcache.cc b/gdbserver/regcache.cc index 0be9c5b..516ecab 100644 --- a/gdbserver/regcache.cc +++ b/gdbserver/regcache.cc @@ -209,24 +209,13 @@ find_register_by_number (const struct target_desc *tdesc, int n) void registers_to_string (struct regcache *regcache, char *buf) { - unsigned char *registers = regcache->registers; const struct target_desc *tdesc = regcache->tdesc; for (int i = 0; i < tdesc->reg_defs.size (); ++i) { - if (regcache->register_status[i] == REG_VALID) - { - bin2hex (registers, buf, register_size (tdesc, i)); - buf += register_size (tdesc, i) * 2; - } - else - { - memset (buf, 'x', register_size (tdesc, i) * 2); - buf += register_size (tdesc, i) * 2; - } - registers += register_size (tdesc, i); + collect_register_as_string (regcache, i, buf); + buf += register_size (tdesc, i) * 2; } - *buf = '\0'; } void @@ -491,7 +480,15 @@ regcache_raw_get_unsigned_by_name (struct regcache *regcache, void collect_register_as_string (struct regcache *regcache, int n, char *buf) { - bin2hex (register_data (regcache, n), buf); + int reg_size = register_size (regcache->tdesc, n); + + if (regcache->get_register_status (n) == REG_VALID) + bin2hex (register_data (regcache, n), buf); + else + memset (buf, 'x', reg_size * 2); + + buf += reg_size * 2; + *buf = '\0'; } void |