aboutsummaryrefslogtreecommitdiff
path: root/gdb/m68hc11-tdep.c
diff options
context:
space:
mode:
authorAndrew Burgess <aburgess@redhat.com>2022-08-30 15:21:47 +0100
committerAndrew Burgess <aburgess@redhat.com>2022-10-02 14:21:24 +0100
commit9a972b54040c6791a163b65a27d24d1acad7c397 (patch)
tree839d94225a4640966b5c1bba18479a7d4f1a465c /gdb/m68hc11-tdep.c
parent89e601ac3a2e29da46275a3dcb83855e662fb0c9 (diff)
downloadgdb-9a972b54040c6791a163b65a27d24d1acad7c397.zip
gdb-9a972b54040c6791a163b65a27d24d1acad7c397.tar.gz
gdb-9a972b54040c6791a163b65a27d24d1acad7c397.tar.bz2
gdb: add a gdbarch_register_name self test, and fix some architectures
This commit adds a self-test that checks that gdbarch_register_name never returns nullptr for any valid register number. Most architectures already met this requirement, there were just 6 that failed the new selftest, and are updated in this commit. Beyond the self-tests I don't have any facilities to test that the architectures I've adjusted still work correctly. If you review all the various gdbarch_register_name implementations then you will see that there are far more architectures that seem like they might return nullptr in some situations, e.g. alpha, avr, bpf, etc. This commit doesn't attempt to address these cases as non of them are hit during the selftest. Many of these cases can never be hit, for example, in alpha_register_name GDB checks for a register number less than zero, this case can't happen and could be changed into an assert. A later commit in this series will have a general cleanup of all the various register_name methods, and remove all references to NULL from their code, however, as that commit will be mostly adjusting code that is never hit, I want to keep those changes separate. The selftest has been tested on x86-64, but I don't have access to suitable systems to fully test any of the *-tdep.c code I've changed in this commit.
Diffstat (limited to 'gdb/m68hc11-tdep.c')
-rw-r--r--gdb/m68hc11-tdep.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/gdb/m68hc11-tdep.c b/gdb/m68hc11-tdep.c
index f22f818..64e82cf 100644
--- a/gdb/m68hc11-tdep.c
+++ b/gdb/m68hc11-tdep.c
@@ -400,7 +400,7 @@ m68hc11_register_name (struct gdbarch *gdbarch, int reg_nr)
/* If we don't know the address of a soft register, pretend it
does not exist. */
if (reg_nr > M68HC11_LAST_HARD_REG && soft_regs[reg_nr].name == 0)
- return NULL;
+ return "";
return m68hc11_register_names[reg_nr];
}