summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Marchi <simon.marchi@polymtl.ca>2020-01-13 13:59:18 -0500
committerSimon Marchi <simon.marchi@efficios.com>2020-01-13 13:59:18 -0500
commite2de1eec22358c64510dc18e755d0ff4cf91ad7a (patch)
treef93a2bfb6121f33de34a1347a29e5c2e3a30b0e4
parent4025fa094d2420134acc4fea2049e707df8ecd01 (diff)
downloadbinutils-gdb-e2de1eec22358c64510dc18e755d0ff4cf91ad7a.tar.gz
gdb: make regformats output a declaration for the init function
When compiling gdbserver for an architecture that uses the regdat.sh script (such as m68k) and the -Wmissing-declarations compiler flag, I get: REGDAT reg-m68k-generated.c CXX reg-m68k.o reg-m68k-generated.c:30:1: error: no previous declaration for 'void init_registers_m68k()' [-Werror=missing-declarations] 30 | init_registers_m68k (void) | ^~~~~~~~~~~~~~~~~~~ The same happens with other architectures, such as s390, but I'll be using 68k as an example. The init_registers_m68k function is defined in reg-m68k-generated.c, which is produced by the regformats/regdat.sh script. This script reads the regformats/reg-m68k.dat file, containing a register description, and produces C code that creates a corresponding target description at runtime. The init_registers_m68k function is invoked at initialization time in linux-m68k-low.c. The function must therefore be non-static, but does not have a declaration at the moment. The real clean way of fixing this would be to make regdat.sh generate a .h file (in addition to the .c file) with declarations for whatever is in the .c file. The generated .c file would include the .h file, and therefore the definition would have a corresponding declaration. The linux-m68k-low.c file would also include this .h file, instead of having its own declaration of init_registers_m68k, like it does now. However, this would be a quite big change for not much gain. As far as I understand, some common architectures (i386, x86-64, ARM, AArch64) have been moved to dynamically building target descriptions based on features (the linux-*-tdesc.c files in gdbserver) and don't use regdat.sh anymore. Logically (and given infinite development resources), the other architectures would be migrated to this system too and the regdat.sh script would be dropped. A new architecture would probably not use regdat.sh either. So I therefore propose this simpler patch instead, which just adds a local declaration in the generated file. gdb/ChangeLog: * regformats/regdat.sh: Generate declaration for init function.
-rw-r--r--gdb/ChangeLog4
-rwxr-xr-xgdb/regformats/regdat.sh4
2 files changed, 8 insertions, 0 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 64b64fb242d..78387ff010a 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,9 @@
2020-01-13 Simon Marchi <simon.marchi@polymtl.ca>
+ * regformats/regdat.sh: Generate declaration for init function.
+
+2020-01-13 Simon Marchi <simon.marchi@polymtl.ca>
+
* remote-sim.c (next_pid, INITIAL_PID, sim_inferior_data): Move
up.
(gdbsim_target) <get_inferior_data_by_ptid, resume_one_inferior,
diff --git a/gdb/regformats/regdat.sh b/gdb/regformats/regdat.sh
index 1839a881213..a40f2336484 100755
--- a/gdb/regformats/regdat.sh
+++ b/gdb/regformats/regdat.sh
@@ -127,6 +127,10 @@ do
echo "const struct target_desc *tdesc_${name};"
echo ""
+
+ # This is necessary for -Wmissing-declarations.
+ echo "void init_registers_${name} (void);"
+
echo "void"
echo "init_registers_${name} (void)"
echo "{"