From 9a103324fee16bf4d0bc4fa7b19f5d937d47b881 Mon Sep 17 00:00:00 2001 From: Andrew Burgess Date: Wed, 31 Aug 2022 11:40:16 +0100 Subject: gdb: check for duplicate register names in selftest Building on the previous commit, this commit extends the register_name selftest to check for duplicate register names. If two registers in the cooked register set (real + pseudo registers) have the same name, then this will show up as duplicate registers in the 'info all-registers' output, but the user will only be able to interact with one copy of the register. In this commit I extend the selftest that I added in the previous commit to check for duplicate register names, I didn't include this functionality in the previous commit because one architecture needed fixing, and I wanted to keep those fixes separate from the fixes in the previous commit. The problematic architecture(s) are powerpc:750 and powerpc:604. In both of these cases the 'dabr' register appears twice, there's a definition of dabr in power-oea.xml which is included into both powerpc-604.xml and powerpc-750.xml. Both of these later two xml files also define the dabr register. I'm hopeful that this change shouldn't break anything, but I don't have the ability to actually test this change, however: On the gdbserver side, neither powerpc-604.xml nor powerpc-750.xml are mentioned in gdbserver/configure.srv, which I think means that gdbserver will never use these descriptions, and, Within GDB the problematic descriptions are held in the variables tdesc_powerpc_604 and tdesc_powerpc_750, which are only mentioned in the variants array in rs6000-tdep.c, this is used when looking up a description based on the architecture. For a native Linux target however, this will not be used as ppc_linux_nat_target::read_description exists, which calls ppc_linux_match_description, which I don't believe can return either of the problematic descriptions. This leaves the other native targets, FreeBSD, AIX, etc. These don't appear to override the ::read_description method, so will potentially return the problematic descriptions, but, in each case I think the ::fetch_registers and ::store_registers methods will ignore the dabr register, which will leave the register as . So, my proposed solution is to just remove the duplicate register from each of powerpc-604.xml and powerpc-750.xml, then regenerate the corresponding C++ source file. With this change made, the selftest now passes for all architectures. --- gdb/features/rs6000/powerpc-604.c | 13 ++++++------- gdb/features/rs6000/powerpc-604.xml | 1 - gdb/features/rs6000/powerpc-750.c | 1 - gdb/features/rs6000/powerpc-750.xml | 1 - 4 files changed, 6 insertions(+), 10 deletions(-) (limited to 'gdb/features') diff --git a/gdb/features/rs6000/powerpc-604.c b/gdb/features/rs6000/powerpc-604.c index 09cbb50..16e6c12 100644 --- a/gdb/features/rs6000/powerpc-604.c +++ b/gdb/features/rs6000/powerpc-604.c @@ -141,13 +141,12 @@ initialize_tdesc_powerpc_604 (void) tdesc_create_reg (feature, "hid0", 119, 1, NULL, 32, "int"); tdesc_create_reg (feature, "hid1", 120, 1, NULL, 32, "int"); tdesc_create_reg (feature, "iabr", 121, 1, NULL, 32, "int"); - tdesc_create_reg (feature, "dabr", 122, 1, NULL, 32, "int"); - tdesc_create_reg (feature, "pir", 123, 1, NULL, 32, "int"); - tdesc_create_reg (feature, "mmcr0", 124, 1, NULL, 32, "int"); - tdesc_create_reg (feature, "pmc1", 125, 1, NULL, 32, "int"); - tdesc_create_reg (feature, "pmc2", 126, 1, NULL, 32, "int"); - tdesc_create_reg (feature, "sia", 127, 1, NULL, 32, "int"); - tdesc_create_reg (feature, "sda", 128, 1, NULL, 32, "int"); + tdesc_create_reg (feature, "pir", 122, 1, NULL, 32, "int"); + tdesc_create_reg (feature, "mmcr0", 123, 1, NULL, 32, "int"); + tdesc_create_reg (feature, "pmc1", 124, 1, NULL, 32, "int"); + tdesc_create_reg (feature, "pmc2", 125, 1, NULL, 32, "int"); + tdesc_create_reg (feature, "sia", 126, 1, NULL, 32, "int"); + tdesc_create_reg (feature, "sda", 127, 1, NULL, 32, "int"); tdesc_powerpc_604 = result.release (); } diff --git a/gdb/features/rs6000/powerpc-604.xml b/gdb/features/rs6000/powerpc-604.xml index fbc9e94..052cfbb 100644 --- a/gdb/features/rs6000/powerpc-604.xml +++ b/gdb/features/rs6000/powerpc-604.xml @@ -17,7 +17,6 @@ - diff --git a/gdb/features/rs6000/powerpc-750.c b/gdb/features/rs6000/powerpc-750.c index 60a7b41..3c9e7e1 100644 --- a/gdb/features/rs6000/powerpc-750.c +++ b/gdb/features/rs6000/powerpc-750.c @@ -141,7 +141,6 @@ initialize_tdesc_powerpc_750 (void) tdesc_create_reg (feature, "hid0", 119, 1, NULL, 32, "int"); tdesc_create_reg (feature, "hid1", 120, 1, NULL, 32, "int"); tdesc_create_reg (feature, "iabr", 121, 1, NULL, 32, "int"); - tdesc_create_reg (feature, "dabr", 122, 1, NULL, 32, "int"); tdesc_create_reg (feature, "ummcr0", 124, 1, NULL, 32, "int"); tdesc_create_reg (feature, "upmc1", 125, 1, NULL, 32, "int"); tdesc_create_reg (feature, "upmc2", 126, 1, NULL, 32, "int"); diff --git a/gdb/features/rs6000/powerpc-750.xml b/gdb/features/rs6000/powerpc-750.xml index 908ecbd..dfc5a87 100644 --- a/gdb/features/rs6000/powerpc-750.xml +++ b/gdb/features/rs6000/powerpc-750.xml @@ -17,7 +17,6 @@ - -- cgit v1.1