gdb: final cleanup of various gdbarch_register_name methods
Building on the previous commits, this commit goes through the various gdbarch_register_name methods and removes all the remaining 'return NULL' cases, I claim that these either couldn't be hit, or should be returning the empty string. In all cases the return of NULL was used if the register number being passed to gdbarch_register_name was "invalid", i.e. negative, or greater than the total number of declared registers. I don't believe either of these cases can occur, and the previous commit asserts that this is the case. As a result we can simplify the code by removing these checks. In many cases, where the register names are held in an array, I was able to add a static assert that the array contains the correct number of strings, after that, a direct access into the array is fine. I don't have any means of testing these changes.
This commit is contained in:
parent
7ac20d65a8
commit
9b9e61c7cf
29 changed files with 66 additions and 146 deletions
|
@ -87,10 +87,8 @@ lm32_register_name (struct gdbarch *gdbarch, int reg_nr)
|
|||
"PC", "EID", "EBA", "DEBA", "IE", "IM", "IP"
|
||||
};
|
||||
|
||||
if ((reg_nr < 0) || (reg_nr >= ARRAY_SIZE (register_names)))
|
||||
return NULL;
|
||||
else
|
||||
return register_names[reg_nr];
|
||||
gdb_static_assert (ARRAY_SIZE (register_names) == SIM_LM32_NUM_REGS);
|
||||
return register_names[reg_nr];
|
||||
}
|
||||
|
||||
/* Return type of register. */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue