From c8154ce0d6942e5988076edd674036ff384ab433 Mon Sep 17 00:00:00 2001 From: Andrew Burgess Date: Mon, 4 Apr 2022 21:07:54 +0100 Subject: [PATCH] gdb: move gdb_disassembly_flag into a new disasm-flags.h file While working on the disassembler I was getting frustrated. Every time I touched disasm.h it seemed like every file in GDB would need to be rebuilt. Surely the disassembler can't be required by that many parts of GDB, right? Turns out that disasm.h is included in target.h, so pretty much every file was being rebuilt! The only thing from disasm.h that target.h needed is the gdb_disassembly_flag enum, as this is part of the target_ops api. In this commit I move gdb_disassembly_flag into its own file. This is then included in target.h and disasm.h, after which, the number of files that depend on disasm.h is much reduced. I also audited all the other includes of disasm.h and found that the includes in mep-tdep.c and python/py-registers.c are no longer needed, so I've removed these. Now, after changing disasm.h, GDB rebuilds much quicker. There should be no user visible changes after this commit. --- gdb/Makefile.in | 1 + gdb/arc-linux-tdep.c | 1 + gdb/disasm-flags.h | 40 +++++++++++++++++++++++++++++++++++++++ gdb/disasm.h | 14 +------------- gdb/mep-tdep.c | 1 - gdb/python/py-registers.c | 1 - gdb/s12z-tdep.c | 1 + gdb/target.h | 2 +- 8 files changed, 45 insertions(+), 16 deletions(-) create mode 100644 gdb/disasm-flags.h diff --git a/gdb/Makefile.in b/gdb/Makefile.in index a775b2f4d19..647f012ad4f 100644 --- a/gdb/Makefile.in +++ b/gdb/Makefile.in @@ -1289,6 +1289,7 @@ HFILES_NO_SRCDIR = \ defs.h \ dicos-tdep.h \ dictionary.h \ + disasm-flags.h \ disasm.h \ dummy-frame.h \ dwarf2/cu.h \ diff --git a/gdb/arc-linux-tdep.c b/gdb/arc-linux-tdep.c index e895b72ce71..1744b7544cd 100644 --- a/gdb/arc-linux-tdep.c +++ b/gdb/arc-linux-tdep.c @@ -24,6 +24,7 @@ #include "opcode/arc.h" #include "osabi.h" #include "solib-svr4.h" +#include "disasm.h" /* ARC header files. */ #include "opcodes/arc-dis.h" diff --git a/gdb/disasm-flags.h b/gdb/disasm-flags.h new file mode 100644 index 00000000000..025b6893941 --- /dev/null +++ b/gdb/disasm-flags.h @@ -0,0 +1,40 @@ +/* Disassemble flags for GDB. + + Copyright (C) 2002-2022 Free Software Foundation, Inc. + + This file is part of GDB. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +#ifndef DISASM_FLAGS_H +#define DISASM_FLAGS_H + +#include "gdbsupport/enum-flags.h" + +/* Flags used to control how GDB's disassembler behaves. */ + +enum gdb_disassembly_flag + { + DISASSEMBLY_SOURCE_DEPRECATED = (0x1 << 0), + DISASSEMBLY_RAW_INSN = (0x1 << 1), + DISASSEMBLY_OMIT_FNAME = (0x1 << 2), + DISASSEMBLY_FILENAME = (0x1 << 3), + DISASSEMBLY_OMIT_PC = (0x1 << 4), + DISASSEMBLY_SOURCE = (0x1 << 5), + DISASSEMBLY_SPECULATIVE = (0x1 << 6), + }; +DEF_ENUM_FLAGS_TYPE (enum gdb_disassembly_flag, gdb_disassembly_flags); + +#endif /* DISASM_FLAGS_H */ + diff --git a/gdb/disasm.h b/gdb/disasm.h index b71cd097a16..7efab7db46c 100644 --- a/gdb/disasm.h +++ b/gdb/disasm.h @@ -20,19 +20,7 @@ #define DISASM_H #include "dis-asm.h" -#include "gdbsupport/enum-flags.h" - -enum gdb_disassembly_flag - { - DISASSEMBLY_SOURCE_DEPRECATED = (0x1 << 0), - DISASSEMBLY_RAW_INSN = (0x1 << 1), - DISASSEMBLY_OMIT_FNAME = (0x1 << 2), - DISASSEMBLY_FILENAME = (0x1 << 3), - DISASSEMBLY_OMIT_PC = (0x1 << 4), - DISASSEMBLY_SOURCE = (0x1 << 5), - DISASSEMBLY_SPECULATIVE = (0x1 << 6), - }; -DEF_ENUM_FLAGS_TYPE (enum gdb_disassembly_flag, gdb_disassembly_flags); +#include "disasm-flags.h" struct gdbarch; struct ui_out; diff --git a/gdb/mep-tdep.c b/gdb/mep-tdep.c index 696d9c63bce..d16c68e6fb6 100644 --- a/gdb/mep-tdep.c +++ b/gdb/mep-tdep.c @@ -37,7 +37,6 @@ #include "regcache.h" #include "remote.h" #include "sim-regno.h" -#include "disasm.h" #include "trad-frame.h" #include "reggroups.h" #include "elf-bfd.h" diff --git a/gdb/python/py-registers.c b/gdb/python/py-registers.c index eab88a30b3b..975eb2ca72d 100644 --- a/gdb/python/py-registers.c +++ b/gdb/python/py-registers.c @@ -20,7 +20,6 @@ #include "defs.h" #include "gdbarch.h" #include "arch-utils.h" -#include "disasm.h" #include "reggroups.h" #include "python-internal.h" #include "user-regs.h" diff --git a/gdb/s12z-tdep.c b/gdb/s12z-tdep.c index bf6a71c7f7f..5394c1bbf5e 100644 --- a/gdb/s12z-tdep.c +++ b/gdb/s12z-tdep.c @@ -32,6 +32,7 @@ #include "remote.h" #include "opcodes/s12z-opc.h" #include "gdbarch.h" +#include "disasm.h" /* Two of the registers included in S12Z_N_REGISTERS are the CCH and CCL "registers" which are just views into diff --git a/gdb/target.h b/gdb/target.h index 4cc79df05b4..c9791e850ac 100644 --- a/gdb/target.h +++ b/gdb/target.h @@ -79,7 +79,7 @@ struct inferior; #include "btrace.h" #include "record.h" #include "command.h" -#include "disasm.h" +#include "disasm-flags.h" #include "tracepoint.h" #include "gdbsupport/break-common.h" /* For enum target_hw_bp_type. */ -- 2.30.2