Do not accidentally include in-tree readline headers

Message ID 20180926125834.8845-1-tom@tromey.com
State New, archived
Headers

Commit Message

Tom Tromey Sept. 26, 2018, 12:58 p.m. UTC
  PR build/17077 points out that when --with-system-readline is given,
gdb will still pick up the in-tree readline headers.  Normally this is
not a big problem, because readline is very stable and so the ABI does
not change much; but it is clearly a bug to do this, and could bite at
some point.

The basic problem is that OPCODES_CFLAGS uses -I$(OPCODES_SRC)/..  so
that #include "opcodes/..." works.  However, this also makes it so
the srcdir.

This patch fixes the problem in a mildly hacky way: remove the
offending -I option, and change gdb to use #include "../opcodes/..."
instead.  This continues to make it clear where the header comes from,
without allowing incorrect behavior.

Tested by rebuilding and then looking at the *.Po files.

gdb/ChangeLog
2018-09-26  Tom Tromey  <tom@tromey.com>

	PR build/17077:
	* Makefile.in (OPCODES_CFLAGS): Remove "-I$(OPCODES_SRC)/..".
	* gdb/aarch64-tdep.c, gdb/amd64-tdep.c, gdb/arc-tdep.c,
	gdb/cris-tdep.c, gdb/csky-tdep.c, gdb/frv-tdep.c, gdb/ft32-tdep.c,
	gdb/i386-tdep.c, gdb/lm32-tdep.c, gdb/m68hc11-tdep.c,
	gdb/mep-tdep.c, gdb/microblaze-tdep.c, gdb/mips-tdep.c,
	gdb/msp430-tdep.c, gdb/nds32-tdep.c, gdb/nios2-tdep.h,
	gdb/or1k-tdep.h, gdb/riscv-tdep.c, gdb/riscv-tdep.h,
	gdb/rl78-tdep.c, gdb/rx-tdep.c, gdb/tilegx-tdep.c: Use ../opcode,
	not opcode, in #include.
---
 gdb/ChangeLog         | 13 +++++++++++++
 gdb/Makefile.in       |  3 +--
 gdb/aarch64-tdep.c    |  2 +-
 gdb/amd64-tdep.c      |  2 +-
 gdb/arc-tdep.c        |  4 ++--
 gdb/cris-tdep.c       |  2 +-
 gdb/csky-tdep.c       |  2 +-
 gdb/frv-tdep.c        |  2 +-
 gdb/ft32-tdep.c       |  2 +-
 gdb/i386-tdep.c       |  2 +-
 gdb/lm32-tdep.c       |  2 +-
 gdb/m68hc11-tdep.c    |  2 +-
 gdb/mep-tdep.c        |  4 ++--
 gdb/microblaze-tdep.c |  4 ++--
 gdb/mips-tdep.c       |  2 +-
 gdb/msp430-tdep.c     |  2 +-
 gdb/nds32-tdep.c      |  2 +-
 gdb/nios2-tdep.h      |  2 +-
 gdb/or1k-tdep.h       |  4 ++--
 gdb/riscv-tdep.c      |  8 ++++----
 gdb/riscv-tdep.h      |  2 +-
 gdb/rl78-tdep.c       |  2 +-
 gdb/rx-tdep.c         |  2 +-
 gdb/tilegx-tdep.c     |  2 +-
 24 files changed, 43 insertions(+), 31 deletions(-)
  

Comments

Andreas Schwab Sept. 26, 2018, 1:12 p.m. UTC | #1
On Sep 26 2018, Tom Tromey <tom@tromey.com> wrote:

> This patch fixes the problem in a mildly hacky way: remove the
> offending -I option, and change gdb to use #include "../opcodes/..."
> instead.  This continues to make it clear where the header comes from,
> without allowing incorrect behavior.

Most of these headers are "opcode/...", not "opcodes/...".

Andreas.
  
Tom Tromey Oct. 7, 2018, 4:46 a.m. UTC | #2
Tom> gdb/ChangeLog
Tom> 2018-09-26  Tom Tromey  <tom@tromey.com>

Tom> 	PR build/17077:
Tom> 	* Makefile.in (OPCODES_CFLAGS): Remove "-I$(OPCODES_SRC)/..".
Tom> 	* gdb/aarch64-tdep.c, gdb/amd64-tdep.c, gdb/arc-tdep.c,
Tom> 	gdb/cris-tdep.c, gdb/csky-tdep.c, gdb/frv-tdep.c, gdb/ft32-tdep.c,
Tom> 	gdb/i386-tdep.c, gdb/lm32-tdep.c, gdb/m68hc11-tdep.c,
Tom> 	gdb/mep-tdep.c, gdb/microblaze-tdep.c, gdb/mips-tdep.c,
Tom> 	gdb/msp430-tdep.c, gdb/nds32-tdep.c, gdb/nios2-tdep.h,
Tom> 	gdb/or1k-tdep.h, gdb/riscv-tdep.c, gdb/riscv-tdep.h,
Tom> 	gdb/rl78-tdep.c, gdb/rx-tdep.c, gdb/tilegx-tdep.c: Use ../opcode,
Tom> 	not opcode, in #include.

I'm checking this in now.

Tom
  

Patch

diff --git a/gdb/Makefile.in b/gdb/Makefile.in
index 3b158fa1db..3d28120fb8 100644
--- a/gdb/Makefile.in
+++ b/gdb/Makefile.in
@@ -446,8 +446,7 @@  OPCODES = $(OPCODES_DIR)/libopcodes.a
 # Where are the other opcode tables which only have header file
 # versions?
 OP_INCLUDE = $(INCLUDE_DIR)/opcode
-# Some source files like to use #include "opcodes/file.h"
-OPCODES_CFLAGS = -I$(OP_INCLUDE) -I$(OPCODES_SRC)/..
+OPCODES_CFLAGS = -I$(OP_INCLUDE)
 
 # The simulator is usually nonexistent; targets that include one
 # should set this to list all the .o or .a files to be linked in.
diff --git a/gdb/aarch64-tdep.c b/gdb/aarch64-tdep.c
index 90b6deb0ea..d73c37a356 100644
--- a/gdb/aarch64-tdep.c
+++ b/gdb/aarch64-tdep.c
@@ -56,7 +56,7 @@ 
 #include "record-full.h"
 #include "arch/aarch64-insn.h"
 
-#include "opcode/aarch64.h"
+#include "../opcode/aarch64.h"
 #include <algorithm>
 
 #define submask(x) ((1L << ((x) + 1)) - 1)
diff --git a/gdb/amd64-tdep.c b/gdb/amd64-tdep.c
index 088542d72b..096cf54793 100644
--- a/gdb/amd64-tdep.c
+++ b/gdb/amd64-tdep.c
@@ -20,7 +20,7 @@ 
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 #include "defs.h"
-#include "opcode/i386.h"
+#include "../opcode/i386.h"
 #include "dis-asm.h"
 #include "arch-utils.h"
 #include "block.h"
diff --git a/gdb/arc-tdep.c b/gdb/arc-tdep.c
index fad9170978..8db5518386 100644
--- a/gdb/arc-tdep.c
+++ b/gdb/arc-tdep.c
@@ -32,8 +32,8 @@ 
 #include "trad-frame.h"
 
 /* ARC header files.  */
-#include "opcode/arc.h"
-#include "opcodes/arc-dis.h"
+#include "../opcode/arc.h"
+#include "../opcodes/arc-dis.h"
 #include "arc-tdep.h"
 
 /* Standard headers.  */
diff --git a/gdb/cris-tdep.c b/gdb/cris-tdep.c
index e0371a2a28..ce5d5c0bc3 100644
--- a/gdb/cris-tdep.c
+++ b/gdb/cris-tdep.c
@@ -33,7 +33,7 @@ 
 #include "gdbcmd.h"
 #include "target.h"
 #include "value.h"
-#include "opcode/cris.h"
+#include "../opcode/cris.h"
 #include "osabi.h"
 #include "arch-utils.h"
 #include "regcache.h"
diff --git a/gdb/csky-tdep.c b/gdb/csky-tdep.c
index 95bcead877..fae46fb3ab 100644
--- a/gdb/csky-tdep.c
+++ b/gdb/csky-tdep.c
@@ -56,7 +56,7 @@ 
 #include "csky-tdep.h"
 #include "regset.h"
 #include "block.h"
-#include "opcode/csky.h"
+#include "../opcode/csky.h"
 #include <algorithm>
 #include <vector>
 
diff --git a/gdb/frv-tdep.c b/gdb/frv-tdep.c
index 1eed441f2b..dafab75654 100644
--- a/gdb/frv-tdep.c
+++ b/gdb/frv-tdep.c
@@ -29,7 +29,7 @@ 
 #include "dis-asm.h"
 #include "sim-regno.h"
 #include "gdb/sim-frv.h"
-#include "opcodes/frv-desc.h"	/* for the H_SPR_... enums */
+#include "../opcodes/frv-desc.h"	/* for the H_SPR_... enums */
 #include "symtab.h"
 #include "elf-bfd.h"
 #include "elf/frv.h"
diff --git a/gdb/ft32-tdep.c b/gdb/ft32-tdep.c
index 7198b84aca..e9667dca09 100644
--- a/gdb/ft32-tdep.c
+++ b/gdb/ft32-tdep.c
@@ -37,7 +37,7 @@ 
 #include "dis-asm.h"
 #include "record.h"
 
-#include "opcode/ft32.h"
+#include "../opcode/ft32.h"
 
 #include "ft32-tdep.h"
 #include "gdb/sim-ft32.h"
diff --git a/gdb/i386-tdep.c b/gdb/i386-tdep.c
index a6994aaf12..5b6646a996 100644
--- a/gdb/i386-tdep.c
+++ b/gdb/i386-tdep.c
@@ -18,7 +18,7 @@ 
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 #include "defs.h"
-#include "opcode/i386.h"
+#include "../opcode/i386.h"
 #include "arch-utils.h"
 #include "command.h"
 #include "dummy-frame.h"
diff --git a/gdb/lm32-tdep.c b/gdb/lm32-tdep.c
index 942852140d..694d30ee1c 100644
--- a/gdb/lm32-tdep.c
+++ b/gdb/lm32-tdep.c
@@ -35,7 +35,7 @@ 
 #include "regcache.h"
 #include "trad-frame.h"
 #include "reggroups.h"
-#include "opcodes/lm32-desc.h"
+#include "../opcodes/lm32-desc.h"
 #include <algorithm>
 
 /* Macros to extract fields from an instruction.  */
diff --git a/gdb/m68hc11-tdep.c b/gdb/m68hc11-tdep.c
index 1490ee2866..5d39d3ebdf 100644
--- a/gdb/m68hc11-tdep.c
+++ b/gdb/m68hc11-tdep.c
@@ -40,7 +40,7 @@ 
 #include "reggroups.h"
 
 #include "target.h"
-#include "opcode/m68hc11.h"
+#include "../opcode/m68hc11.h"
 #include "elf/m68hc11.h"
 #include "elf-bfd.h"
 
diff --git a/gdb/mep-tdep.c b/gdb/mep-tdep.c
index 69e7fdda59..e8ceec9288 100644
--- a/gdb/mep-tdep.c
+++ b/gdb/mep-tdep.c
@@ -48,8 +48,8 @@ 
 
 /* Get the user's customized MeP coprocessor register names from
    libopcodes.  */
-#include "opcodes/mep-desc.h"
-#include "opcodes/mep-opc.h"
+#include "../opcodes/mep-desc.h"
+#include "../opcodes/mep-opc.h"
 
 
 /* The gdbarch_tdep structure.  */
diff --git a/gdb/microblaze-tdep.c b/gdb/microblaze-tdep.c
index 9bac8643c4..63095d3ede 100644
--- a/gdb/microblaze-tdep.c
+++ b/gdb/microblaze-tdep.c
@@ -34,8 +34,8 @@ 
 #include "dwarf2-frame.h"
 #include "osabi.h"
 #include "target-descriptions.h"
-#include "opcodes/microblaze-opcm.h"
-#include "opcodes/microblaze-dis.h"
+#include "../opcodes/microblaze-opcm.h"
+#include "../opcodes/microblaze-dis.h"
 #include "microblaze-tdep.h"
 #include "remote.h"
 
diff --git a/gdb/mips-tdep.c b/gdb/mips-tdep.c
index 5e0a60625b..4031436ef1 100644
--- a/gdb/mips-tdep.c
+++ b/gdb/mips-tdep.c
@@ -38,7 +38,7 @@ 
 #include "mips-tdep.h"
 #include "block.h"
 #include "reggroups.h"
-#include "opcode/mips.h"
+#include "../opcode/mips.h"
 #include "elf/mips.h"
 #include "elf-bfd.h"
 #include "symcat.h"
diff --git a/gdb/msp430-tdep.c b/gdb/msp430-tdep.c
index b6e062a380..5931e36d2d 100644
--- a/gdb/msp430-tdep.c
+++ b/gdb/msp430-tdep.c
@@ -36,7 +36,7 @@ 
 #include "reggroups.h"
 
 #include "elf/msp430.h"
-#include "opcode/msp430-decode.h"
+#include "../opcode/msp430-decode.h"
 #include "elf-bfd.h"
 
 /* Register Numbers.  */
diff --git a/gdb/nds32-tdep.c b/gdb/nds32-tdep.c
index b616cc9b2c..65312b3f8e 100644
--- a/gdb/nds32-tdep.c
+++ b/gdb/nds32-tdep.c
@@ -40,7 +40,7 @@ 
 
 #include "nds32-tdep.h"
 #include "elf/nds32.h"
-#include "opcode/nds32.h"
+#include "../opcode/nds32.h"
 #include <algorithm>
 
 #include "features/nds32.c"
diff --git a/gdb/nios2-tdep.h b/gdb/nios2-tdep.h
index 097975ea30..0bee428eeb 100644
--- a/gdb/nios2-tdep.h
+++ b/gdb/nios2-tdep.h
@@ -21,7 +21,7 @@ 
 #define NIOS2_TDEP_H
 
 /* Nios II ISA specific encodings and macros.  */
-#include "opcode/nios2.h"
+#include "../opcode/nios2.h"
 
 /* Registers.  */
 #define NIOS2_Z_REGNUM 0     /* Zero */
diff --git a/gdb/or1k-tdep.h b/gdb/or1k-tdep.h
index 4a93540c3a..b630c77053 100644
--- a/gdb/or1k-tdep.h
+++ b/gdb/or1k-tdep.h
@@ -24,8 +24,8 @@ 
 #define TARGET_OR1K
 #endif
 
-#include "opcodes/or1k-desc.h"
-#include "opcodes/or1k-opc.h"
+#include "../opcodes/or1k-desc.h"
+#include "../opcodes/or1k-opc.h"
 
 /* General Purpose Registers */
 #define OR1K_ZERO_REGNUM          0
diff --git a/gdb/riscv-tdep.c b/gdb/riscv-tdep.c
index 254914c9c7..db3b64d2be 100644
--- a/gdb/riscv-tdep.c
+++ b/gdb/riscv-tdep.c
@@ -35,7 +35,7 @@ 
 #include "riscv-tdep.h"
 #include "block.h"
 #include "reggroups.h"
-#include "opcode/riscv.h"
+#include "../opcode/riscv.h"
 #include "elf/riscv.h"
 #include "elf-bfd.h"
 #include "symcat.h"
@@ -51,7 +51,7 @@ 
 #include "user-regs.h"
 #include "valprint.h"
 #include "common-defs.h"
-#include "opcode/riscv-opc.h"
+#include "../opcode/riscv-opc.h"
 #include "cli/cli-decode.h"
 #include "observable.h"
 #include "prologue-value.h"
@@ -69,7 +69,7 @@  static inline bool is_ ## INSN_NAME ## _insn (long insn) \
 { \
   return (insn & INSN_MASK) == INSN_MATCH; \
 }
-#include "opcode/riscv-opc.h"
+#include "../opcode/riscv-opc.h"
 #undef DECLARE_INSN
 
 /* Cached information about a frame.  */
@@ -193,7 +193,7 @@  static const struct register_alias riscv_register_aliases[] =
   { "ft10", 63 },
   { "ft11", 64 },
 #define DECLARE_CSR(name, num) { #name, (num) + 65 },
-#include "opcode/riscv-opc.h"
+#include "../opcode/riscv-opc.h"
 #undef DECLARE_CSR
 };
 
diff --git a/gdb/riscv-tdep.h b/gdb/riscv-tdep.h
index 8a2454eb66..30de167bd6 100644
--- a/gdb/riscv-tdep.h
+++ b/gdb/riscv-tdep.h
@@ -44,7 +44,7 @@  enum
   RISCV_FIRST_CSR_REGNUM = 65,  /* First CSR */
 #define DECLARE_CSR(name, num) \
   RISCV_ ## num ## _REGNUM = RISCV_FIRST_CSR_REGNUM + num,
-#include "opcode/riscv-opc.h"
+#include "../opcode/riscv-opc.h"
 #undef DECLARE_CSR
   RISCV_LAST_CSR_REGNUM = 4160,
   RISCV_CSR_LEGACY_MISA_REGNUM = 0xf10 + RISCV_FIRST_CSR_REGNUM,
diff --git a/gdb/rl78-tdep.c b/gdb/rl78-tdep.c
index ace01b1171..0cf1e8ccae 100644
--- a/gdb/rl78-tdep.c
+++ b/gdb/rl78-tdep.c
@@ -24,7 +24,7 @@ 
 #include "prologue-value.h"
 #include "target.h"
 #include "regcache.h"
-#include "opcode/rl78.h"
+#include "../opcode/rl78.h"
 #include "dis-asm.h"
 #include "gdbtypes.h"
 #include "frame.h"
diff --git a/gdb/rx-tdep.c b/gdb/rx-tdep.c
index 94d57913a3..4e964b000a 100644
--- a/gdb/rx-tdep.c
+++ b/gdb/rx-tdep.c
@@ -24,7 +24,7 @@ 
 #include "prologue-value.h"
 #include "target.h"
 #include "regcache.h"
-#include "opcode/rx.h"
+#include "../opcode/rx.h"
 #include "dis-asm.h"
 #include "gdbtypes.h"
 #include "frame.h"
diff --git a/gdb/tilegx-tdep.c b/gdb/tilegx-tdep.c
index 9ed696630e..f9864f78da 100644
--- a/gdb/tilegx-tdep.c
+++ b/gdb/tilegx-tdep.c
@@ -38,7 +38,7 @@ 
 #include "objfiles.h"
 #include "solib-svr4.h"
 #include "tilegx-tdep.h"
-#include "opcode/tilegx.h"
+#include "../opcode/tilegx.h"
 #include <algorithm>
 #include "common/byte-vector.h"