aboutsummaryrefslogtreecommitdiff
path: root/gdb/v850-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/v850-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/v850-tdep.c')
-rw-r--r--gdb/v850-tdep.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/gdb/v850-tdep.c b/gdb/v850-tdep.c
index f27c6ab..b7f3d8a 100644
--- a/gdb/v850-tdep.c
+++ b/gdb/v850-tdep.c
@@ -313,7 +313,7 @@ v850_register_name (struct gdbarch *gdbarch, int regnum)
"pc", "fp"
};
if (regnum < 0 || regnum > E_NUM_OF_V850_REGS)
- return NULL;
+ return "";
return v850_reg_names[regnum];
}
@@ -333,7 +333,7 @@ v850e_register_name (struct gdbarch *gdbarch, int regnum)
"pc", "fp"
};
if (regnum < 0 || regnum > E_NUM_OF_V850E_REGS)
- return NULL;
+ return "";
return v850e_reg_names[regnum];
}
@@ -377,7 +377,7 @@ v850e2_register_name (struct gdbarch *gdbarch, int regnum)
"", "", "", "fpspc"
};
if (regnum < 0 || regnum >= E_NUM_OF_V850E2_REGS)
- return NULL;
+ return "";
return v850e2_reg_names[regnum];
}
@@ -480,7 +480,7 @@ v850e3v5_register_name (struct gdbarch *gdbarch, int regnum)
};
if (regnum < 0 || regnum >= E_NUM_OF_V850E3V5_REGS)
- return NULL;
+ return "";
return v850e3v5_reg_names[regnum];
}