mirror of
https://sourceware.org/git/binutils-gdb.git
synced 2024-12-27 04:52:05 +08:00
dda83cd783
Many spots incorrectly use only spaces for indentation (for example, there are a lot of spots in ada-lang.c). I've always found it awkward when I needed to edit one of these spots: do I keep the original wrong indentation, or do I fix it? What if the lines around it are also wrong, do I fix them too? I probably don't want to fix them in the same patch, to avoid adding noise to my patch. So I propose to fix as much as possible once and for all (hopefully). One typical counter argument for this is that it makes code archeology more difficult, because git-blame will show this commit as the last change for these lines. My counter counter argument is: when git-blaming, you often need to do "blame the file at the parent commit" anyway, to go past some other refactor that touched the line you are interested in, but is not the change you are looking for. So you already need a somewhat efficient way to do this. Using some interactive tool, rather than plain git-blame, makes this trivial. For example, I use "tig blame <file>", where going back past the commit that changed the currently selected line is one keystroke. It looks like Magit in Emacs does it too (though I've never used it). Web viewers of Github and Gitlab do it too. My point is that it won't really make archeology more difficult. The other typical counter argument is that it will cause conflicts with existing patches. That's true... but it's a one time cost, and those are not conflicts that are difficult to resolve. I have also tried "git rebase --ignore-whitespace", it seems to work well. Although that will re-introduce the faulty indentation, so one needs to take care of fixing the indentation in the patch after that (which is easy). gdb/ChangeLog: * aarch64-linux-tdep.c: Fix indentation. * aarch64-ravenscar-thread.c: Fix indentation. * aarch64-tdep.c: Fix indentation. * aarch64-tdep.h: Fix indentation. * ada-lang.c: Fix indentation. * ada-lang.h: Fix indentation. * ada-tasks.c: Fix indentation. * ada-typeprint.c: Fix indentation. * ada-valprint.c: Fix indentation. * ada-varobj.c: Fix indentation. * addrmap.c: Fix indentation. * addrmap.h: Fix indentation. * agent.c: Fix indentation. * aix-thread.c: Fix indentation. * alpha-bsd-nat.c: Fix indentation. * alpha-linux-tdep.c: Fix indentation. * alpha-mdebug-tdep.c: Fix indentation. * alpha-nbsd-tdep.c: Fix indentation. * alpha-obsd-tdep.c: Fix indentation. * alpha-tdep.c: Fix indentation. * amd64-bsd-nat.c: Fix indentation. * amd64-darwin-tdep.c: Fix indentation. * amd64-linux-nat.c: Fix indentation. * amd64-linux-tdep.c: Fix indentation. * amd64-nat.c: Fix indentation. * amd64-obsd-tdep.c: Fix indentation. * amd64-tdep.c: Fix indentation. * amd64-windows-tdep.c: Fix indentation. * annotate.c: Fix indentation. * arc-tdep.c: Fix indentation. * arch-utils.c: Fix indentation. * arch/arm-get-next-pcs.c: Fix indentation. * arch/arm.c: Fix indentation. * arm-linux-nat.c: Fix indentation. * arm-linux-tdep.c: Fix indentation. * arm-nbsd-tdep.c: Fix indentation. * arm-pikeos-tdep.c: Fix indentation. * arm-tdep.c: Fix indentation. * arm-tdep.h: Fix indentation. * arm-wince-tdep.c: Fix indentation. * auto-load.c: Fix indentation. * auxv.c: Fix indentation. * avr-tdep.c: Fix indentation. * ax-gdb.c: Fix indentation. * ax-general.c: Fix indentation. * bfin-linux-tdep.c: Fix indentation. * block.c: Fix indentation. * block.h: Fix indentation. * blockframe.c: Fix indentation. * bpf-tdep.c: Fix indentation. * break-catch-sig.c: Fix indentation. * break-catch-syscall.c: Fix indentation. * break-catch-throw.c: Fix indentation. * breakpoint.c: Fix indentation. * breakpoint.h: Fix indentation. * bsd-uthread.c: Fix indentation. * btrace.c: Fix indentation. * build-id.c: Fix indentation. * buildsym-legacy.h: Fix indentation. * buildsym.c: Fix indentation. * c-typeprint.c: Fix indentation. * c-valprint.c: Fix indentation. * c-varobj.c: Fix indentation. * charset.c: Fix indentation. * cli/cli-cmds.c: Fix indentation. * cli/cli-decode.c: Fix indentation. * cli/cli-decode.h: Fix indentation. * cli/cli-script.c: Fix indentation. * cli/cli-setshow.c: Fix indentation. * coff-pe-read.c: Fix indentation. * coffread.c: Fix indentation. * compile/compile-cplus-types.c: Fix indentation. * compile/compile-object-load.c: Fix indentation. * compile/compile-object-run.c: Fix indentation. * completer.c: Fix indentation. * corefile.c: Fix indentation. * corelow.c: Fix indentation. * cp-abi.h: Fix indentation. * cp-namespace.c: Fix indentation. * cp-support.c: Fix indentation. * cp-valprint.c: Fix indentation. * cris-linux-tdep.c: Fix indentation. * cris-tdep.c: Fix indentation. * darwin-nat-info.c: Fix indentation. * darwin-nat.c: Fix indentation. * darwin-nat.h: Fix indentation. * dbxread.c: Fix indentation. * dcache.c: Fix indentation. * disasm.c: Fix indentation. * dtrace-probe.c: Fix indentation. * dwarf2/abbrev.c: Fix indentation. * dwarf2/attribute.c: Fix indentation. * dwarf2/expr.c: Fix indentation. * dwarf2/frame.c: Fix indentation. * dwarf2/index-cache.c: Fix indentation. * dwarf2/index-write.c: Fix indentation. * dwarf2/line-header.c: Fix indentation. * dwarf2/loc.c: Fix indentation. * dwarf2/macro.c: Fix indentation. * dwarf2/read.c: Fix indentation. * dwarf2/read.h: Fix indentation. * elfread.c: Fix indentation. * eval.c: Fix indentation. * event-top.c: Fix indentation. * exec.c: Fix indentation. * exec.h: Fix indentation. * expprint.c: Fix indentation. * f-lang.c: Fix indentation. * f-typeprint.c: Fix indentation. * f-valprint.c: Fix indentation. * fbsd-nat.c: Fix indentation. * fbsd-tdep.c: Fix indentation. * findvar.c: Fix indentation. * fork-child.c: Fix indentation. * frame-unwind.c: Fix indentation. * frame-unwind.h: Fix indentation. * frame.c: Fix indentation. * frv-linux-tdep.c: Fix indentation. * frv-tdep.c: Fix indentation. * frv-tdep.h: Fix indentation. * ft32-tdep.c: Fix indentation. * gcore.c: Fix indentation. * gdb_bfd.c: Fix indentation. * gdbarch.sh: Fix indentation. * gdbarch.c: Re-generate * gdbarch.h: Re-generate. * gdbcore.h: Fix indentation. * gdbthread.h: Fix indentation. * gdbtypes.c: Fix indentation. * gdbtypes.h: Fix indentation. * glibc-tdep.c: Fix indentation. * gnu-nat.c: Fix indentation. * gnu-nat.h: Fix indentation. * gnu-v2-abi.c: Fix indentation. * gnu-v3-abi.c: Fix indentation. * go32-nat.c: Fix indentation. * guile/guile-internal.h: Fix indentation. * guile/scm-cmd.c: Fix indentation. * guile/scm-frame.c: Fix indentation. * guile/scm-iterator.c: Fix indentation. * guile/scm-math.c: Fix indentation. * guile/scm-ports.c: Fix indentation. * guile/scm-pretty-print.c: Fix indentation. * guile/scm-value.c: Fix indentation. * h8300-tdep.c: Fix indentation. * hppa-linux-nat.c: Fix indentation. * hppa-linux-tdep.c: Fix indentation. * hppa-nbsd-nat.c: Fix indentation. * hppa-nbsd-tdep.c: Fix indentation. * hppa-obsd-nat.c: Fix indentation. * hppa-tdep.c: Fix indentation. * hppa-tdep.h: Fix indentation. * i386-bsd-nat.c: Fix indentation. * i386-darwin-nat.c: Fix indentation. * i386-darwin-tdep.c: Fix indentation. * i386-dicos-tdep.c: Fix indentation. * i386-gnu-nat.c: Fix indentation. * i386-linux-nat.c: Fix indentation. * i386-linux-tdep.c: Fix indentation. * i386-nto-tdep.c: Fix indentation. * i386-obsd-tdep.c: Fix indentation. * i386-sol2-nat.c: Fix indentation. * i386-tdep.c: Fix indentation. * i386-tdep.h: Fix indentation. * i386-windows-tdep.c: Fix indentation. * i387-tdep.c: Fix indentation. * i387-tdep.h: Fix indentation. * ia64-libunwind-tdep.c: Fix indentation. * ia64-libunwind-tdep.h: Fix indentation. * ia64-linux-nat.c: Fix indentation. * ia64-linux-tdep.c: Fix indentation. * ia64-tdep.c: Fix indentation. * ia64-tdep.h: Fix indentation. * ia64-vms-tdep.c: Fix indentation. * infcall.c: Fix indentation. * infcmd.c: Fix indentation. * inferior.c: Fix indentation. * infrun.c: Fix indentation. * iq2000-tdep.c: Fix indentation. * language.c: Fix indentation. * linespec.c: Fix indentation. * linux-fork.c: Fix indentation. * linux-nat.c: Fix indentation. * linux-tdep.c: Fix indentation. * linux-thread-db.c: Fix indentation. * lm32-tdep.c: Fix indentation. * m2-lang.c: Fix indentation. * m2-typeprint.c: Fix indentation. * m2-valprint.c: Fix indentation. * m32c-tdep.c: Fix indentation. * m32r-linux-tdep.c: Fix indentation. * m32r-tdep.c: Fix indentation. * m68hc11-tdep.c: Fix indentation. * m68k-bsd-nat.c: Fix indentation. * m68k-linux-nat.c: Fix indentation. * m68k-linux-tdep.c: Fix indentation. * m68k-tdep.c: Fix indentation. * machoread.c: Fix indentation. * macrocmd.c: Fix indentation. * macroexp.c: Fix indentation. * macroscope.c: Fix indentation. * macrotab.c: Fix indentation. * macrotab.h: Fix indentation. * main.c: Fix indentation. * mdebugread.c: Fix indentation. * mep-tdep.c: Fix indentation. * mi/mi-cmd-catch.c: Fix indentation. * mi/mi-cmd-disas.c: Fix indentation. * mi/mi-cmd-env.c: Fix indentation. * mi/mi-cmd-stack.c: Fix indentation. * mi/mi-cmd-var.c: Fix indentation. * mi/mi-cmds.c: Fix indentation. * mi/mi-main.c: Fix indentation. * mi/mi-parse.c: Fix indentation. * microblaze-tdep.c: Fix indentation. * minidebug.c: Fix indentation. * minsyms.c: Fix indentation. * mips-linux-nat.c: Fix indentation. * mips-linux-tdep.c: Fix indentation. * mips-nbsd-tdep.c: Fix indentation. * mips-tdep.c: Fix indentation. * mn10300-linux-tdep.c: Fix indentation. * mn10300-tdep.c: Fix indentation. * moxie-tdep.c: Fix indentation. * msp430-tdep.c: Fix indentation. * namespace.h: Fix indentation. * nat/fork-inferior.c: Fix indentation. * nat/gdb_ptrace.h: Fix indentation. * nat/linux-namespaces.c: Fix indentation. * nat/linux-osdata.c: Fix indentation. * nat/netbsd-nat.c: Fix indentation. * nat/x86-dregs.c: Fix indentation. * nbsd-nat.c: Fix indentation. * nbsd-tdep.c: Fix indentation. * nios2-linux-tdep.c: Fix indentation. * nios2-tdep.c: Fix indentation. * nto-procfs.c: Fix indentation. * nto-tdep.c: Fix indentation. * objfiles.c: Fix indentation. * objfiles.h: Fix indentation. * opencl-lang.c: Fix indentation. * or1k-tdep.c: Fix indentation. * osabi.c: Fix indentation. * osabi.h: Fix indentation. * osdata.c: Fix indentation. * p-lang.c: Fix indentation. * p-typeprint.c: Fix indentation. * p-valprint.c: Fix indentation. * parse.c: Fix indentation. * ppc-linux-nat.c: Fix indentation. * ppc-linux-tdep.c: Fix indentation. * ppc-nbsd-nat.c: Fix indentation. * ppc-nbsd-tdep.c: Fix indentation. * ppc-obsd-nat.c: Fix indentation. * ppc-ravenscar-thread.c: Fix indentation. * ppc-sysv-tdep.c: Fix indentation. * ppc64-tdep.c: Fix indentation. * printcmd.c: Fix indentation. * proc-api.c: Fix indentation. * producer.c: Fix indentation. * producer.h: Fix indentation. * prologue-value.c: Fix indentation. * prologue-value.h: Fix indentation. * psymtab.c: Fix indentation. * python/py-arch.c: Fix indentation. * python/py-bpevent.c: Fix indentation. * python/py-event.c: Fix indentation. * python/py-event.h: Fix indentation. * python/py-finishbreakpoint.c: Fix indentation. * python/py-frame.c: Fix indentation. * python/py-framefilter.c: Fix indentation. * python/py-inferior.c: Fix indentation. * python/py-infthread.c: Fix indentation. * python/py-objfile.c: Fix indentation. * python/py-prettyprint.c: Fix indentation. * python/py-registers.c: Fix indentation. * python/py-signalevent.c: Fix indentation. * python/py-stopevent.c: Fix indentation. * python/py-stopevent.h: Fix indentation. * python/py-threadevent.c: Fix indentation. * python/py-tui.c: Fix indentation. * python/py-unwind.c: Fix indentation. * python/py-value.c: Fix indentation. * python/py-xmethods.c: Fix indentation. * python/python-internal.h: Fix indentation. * python/python.c: Fix indentation. * ravenscar-thread.c: Fix indentation. * record-btrace.c: Fix indentation. * record-full.c: Fix indentation. * record.c: Fix indentation. * reggroups.c: Fix indentation. * regset.h: Fix indentation. * remote-fileio.c: Fix indentation. * remote.c: Fix indentation. * reverse.c: Fix indentation. * riscv-linux-tdep.c: Fix indentation. * riscv-ravenscar-thread.c: Fix indentation. * riscv-tdep.c: Fix indentation. * rl78-tdep.c: Fix indentation. * rs6000-aix-tdep.c: Fix indentation. * rs6000-lynx178-tdep.c: Fix indentation. * rs6000-nat.c: Fix indentation. * rs6000-tdep.c: Fix indentation. * rust-lang.c: Fix indentation. * rx-tdep.c: Fix indentation. * s12z-tdep.c: Fix indentation. * s390-linux-tdep.c: Fix indentation. * score-tdep.c: Fix indentation. * ser-base.c: Fix indentation. * ser-mingw.c: Fix indentation. * ser-uds.c: Fix indentation. * ser-unix.c: Fix indentation. * serial.c: Fix indentation. * sh-linux-tdep.c: Fix indentation. * sh-nbsd-tdep.c: Fix indentation. * sh-tdep.c: Fix indentation. * skip.c: Fix indentation. * sol-thread.c: Fix indentation. * solib-aix.c: Fix indentation. * solib-darwin.c: Fix indentation. * solib-frv.c: Fix indentation. * solib-svr4.c: Fix indentation. * solib.c: Fix indentation. * source.c: Fix indentation. * sparc-linux-tdep.c: Fix indentation. * sparc-nbsd-tdep.c: Fix indentation. * sparc-obsd-tdep.c: Fix indentation. * sparc-ravenscar-thread.c: Fix indentation. * sparc-tdep.c: Fix indentation. * sparc64-linux-tdep.c: Fix indentation. * sparc64-nbsd-tdep.c: Fix indentation. * sparc64-obsd-tdep.c: Fix indentation. * sparc64-tdep.c: Fix indentation. * stabsread.c: Fix indentation. * stack.c: Fix indentation. * stap-probe.c: Fix indentation. * stubs/ia64vms-stub.c: Fix indentation. * stubs/m32r-stub.c: Fix indentation. * stubs/m68k-stub.c: Fix indentation. * stubs/sh-stub.c: Fix indentation. * stubs/sparc-stub.c: Fix indentation. * symfile-mem.c: Fix indentation. * symfile.c: Fix indentation. * symfile.h: Fix indentation. * symmisc.c: Fix indentation. * symtab.c: Fix indentation. * symtab.h: Fix indentation. * target-float.c: Fix indentation. * target.c: Fix indentation. * target.h: Fix indentation. * tic6x-tdep.c: Fix indentation. * tilegx-linux-tdep.c: Fix indentation. * tilegx-tdep.c: Fix indentation. * top.c: Fix indentation. * tracefile-tfile.c: Fix indentation. * tracepoint.c: Fix indentation. * tui/tui-disasm.c: Fix indentation. * tui/tui-io.c: Fix indentation. * tui/tui-regs.c: Fix indentation. * tui/tui-stack.c: Fix indentation. * tui/tui-win.c: Fix indentation. * tui/tui-winsource.c: Fix indentation. * tui/tui.c: Fix indentation. * typeprint.c: Fix indentation. * ui-out.h: Fix indentation. * unittests/copy_bitwise-selftests.c: Fix indentation. * unittests/memory-map-selftests.c: Fix indentation. * utils.c: Fix indentation. * v850-tdep.c: Fix indentation. * valarith.c: Fix indentation. * valops.c: Fix indentation. * valprint.c: Fix indentation. * valprint.h: Fix indentation. * value.c: Fix indentation. * value.h: Fix indentation. * varobj.c: Fix indentation. * vax-tdep.c: Fix indentation. * windows-nat.c: Fix indentation. * windows-tdep.c: Fix indentation. * xcoffread.c: Fix indentation. * xml-syscall.c: Fix indentation. * xml-tdesc.c: Fix indentation. * xstormy16-tdep.c: Fix indentation. * xtensa-config.c: Fix indentation. * xtensa-linux-nat.c: Fix indentation. * xtensa-linux-tdep.c: Fix indentation. * xtensa-tdep.c: Fix indentation. gdbserver/ChangeLog: * ax.cc: Fix indentation. * dll.cc: Fix indentation. * inferiors.h: Fix indentation. * linux-low.cc: Fix indentation. * linux-nios2-low.cc: Fix indentation. * linux-ppc-ipa.cc: Fix indentation. * linux-ppc-low.cc: Fix indentation. * linux-x86-low.cc: Fix indentation. * linux-xtensa-low.cc: Fix indentation. * regcache.cc: Fix indentation. * server.cc: Fix indentation. * tracepoint.cc: Fix indentation. gdbsupport/ChangeLog: * common-exceptions.h: Fix indentation. * event-loop.cc: Fix indentation. * fileio.cc: Fix indentation. * filestuff.cc: Fix indentation. * gdb-dlfcn.cc: Fix indentation. * gdb_string_view.h: Fix indentation. * job-control.cc: Fix indentation. * signals.cc: Fix indentation. Change-Id: I4bad7ae6be0fbe14168b8ebafb98ffe14964a695
698 lines
24 KiB
C++
698 lines
24 KiB
C++
/* DWARF 2 debugging format support for GDB.
|
|
|
|
Copyright (C) 1994-2020 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 <http://www.gnu.org/licenses/>. */
|
|
|
|
#ifndef DWARF2READ_H
|
|
#define DWARF2READ_H
|
|
|
|
#include <queue>
|
|
#include <unordered_map>
|
|
#include "dwarf2/comp-unit.h"
|
|
#include "dwarf2/index-cache.h"
|
|
#include "dwarf2/section.h"
|
|
#include "filename-seen-cache.h"
|
|
#include "gdb_obstack.h"
|
|
#include "gdbsupport/hash_enum.h"
|
|
#include "gdbsupport/function-view.h"
|
|
#include "psympriv.h"
|
|
|
|
/* Hold 'maintenance (set|show) dwarf' commands. */
|
|
extern struct cmd_list_element *set_dwarf_cmdlist;
|
|
extern struct cmd_list_element *show_dwarf_cmdlist;
|
|
|
|
struct tu_stats
|
|
{
|
|
int nr_uniq_abbrev_tables;
|
|
int nr_symtabs;
|
|
int nr_symtab_sharers;
|
|
int nr_stmt_less_type_units;
|
|
int nr_all_type_units_reallocs;
|
|
};
|
|
|
|
struct dwarf2_cu;
|
|
struct dwarf2_debug_sections;
|
|
struct dwarf2_per_cu_data;
|
|
struct mapped_index;
|
|
struct mapped_debug_names;
|
|
struct signatured_type;
|
|
struct type_unit_group;
|
|
|
|
/* One item on the queue of compilation units to read in full symbols
|
|
for. */
|
|
struct dwarf2_queue_item
|
|
{
|
|
dwarf2_queue_item (dwarf2_per_cu_data *cu, dwarf2_per_objfile *per_objfile,
|
|
enum language lang)
|
|
: per_cu (cu),
|
|
per_objfile (per_objfile),
|
|
pretend_language (lang)
|
|
{
|
|
}
|
|
|
|
~dwarf2_queue_item ();
|
|
|
|
DISABLE_COPY_AND_ASSIGN (dwarf2_queue_item);
|
|
|
|
dwarf2_per_cu_data *per_cu;
|
|
dwarf2_per_objfile *per_objfile;
|
|
enum language pretend_language;
|
|
};
|
|
|
|
/* Some DWARF data can be shared across objfiles who share the same BFD,
|
|
this data is stored in this object.
|
|
|
|
Two dwarf2_per_objfile objects representing objfiles sharing the same BFD
|
|
will point to the same instance of dwarf2_per_bfd, unless the BFD requires
|
|
relocation. */
|
|
|
|
struct dwarf2_per_bfd
|
|
{
|
|
/* Construct a dwarf2_per_bfd for OBFD. NAMES points to the
|
|
dwarf2 section names, or is NULL if the standard ELF names are
|
|
used. CAN_COPY is true for formats where symbol
|
|
interposition is possible and so symbol values must follow copy
|
|
relocation rules. */
|
|
dwarf2_per_bfd (bfd *obfd, const dwarf2_debug_sections *names, bool can_copy);
|
|
|
|
~dwarf2_per_bfd ();
|
|
|
|
DISABLE_COPY_AND_ASSIGN (dwarf2_per_bfd);
|
|
|
|
/* Return the CU/TU given its index.
|
|
|
|
This is intended for loops like:
|
|
|
|
for (i = 0; i < (dwarf2_per_bfd->n_comp_units
|
|
+ dwarf2_per_bfd->n_type_units); ++i)
|
|
{
|
|
dwarf2_per_cu_data *per_cu = dwarf2_per_bfd->get_cutu (i);
|
|
|
|
...;
|
|
}
|
|
*/
|
|
dwarf2_per_cu_data *get_cutu (int index);
|
|
|
|
/* Return the CU given its index.
|
|
This differs from get_cutu in that it's for when you know INDEX refers to a
|
|
CU. */
|
|
dwarf2_per_cu_data *get_cu (int index);
|
|
|
|
/* Return the TU given its index.
|
|
This differs from get_cutu in that it's for when you know INDEX refers to a
|
|
TU. */
|
|
signatured_type *get_tu (int index);
|
|
|
|
/* A convenience function to allocate a dwarf2_per_cu_data. The
|
|
returned object has its "index" field set properly. The object
|
|
is allocated on the dwarf2_per_bfd obstack. */
|
|
dwarf2_per_cu_data *allocate_per_cu ();
|
|
|
|
/* A convenience function to allocate a signatured_type. The
|
|
returned object has its "index" field set properly. The object
|
|
is allocated on the dwarf2_per_bfd obstack. */
|
|
signatured_type *allocate_signatured_type ();
|
|
|
|
/* Return the number of partial symtabs allocated with allocate_per_cu
|
|
and allocate_signatured_type so far. */
|
|
int num_psymtabs () const
|
|
{ return m_num_psymtabs; }
|
|
|
|
private:
|
|
/* This function is mapped across the sections and remembers the
|
|
offset and size of each of the debugging sections we are
|
|
interested in. */
|
|
void locate_sections (bfd *abfd, asection *sectp,
|
|
const dwarf2_debug_sections &names);
|
|
|
|
public:
|
|
/* The corresponding BFD. */
|
|
bfd *obfd;
|
|
|
|
/* Objects that can be shared across objfiles are stored in this
|
|
obstack or on the psymtab obstack, while objects that are
|
|
objfile-specific are stored on the objfile obstack. */
|
|
auto_obstack obstack;
|
|
|
|
dwarf2_section_info info {};
|
|
dwarf2_section_info abbrev {};
|
|
dwarf2_section_info line {};
|
|
dwarf2_section_info loc {};
|
|
dwarf2_section_info loclists {};
|
|
dwarf2_section_info macinfo {};
|
|
dwarf2_section_info macro {};
|
|
dwarf2_section_info str {};
|
|
dwarf2_section_info str_offsets {};
|
|
dwarf2_section_info line_str {};
|
|
dwarf2_section_info ranges {};
|
|
dwarf2_section_info rnglists {};
|
|
dwarf2_section_info addr {};
|
|
dwarf2_section_info frame {};
|
|
dwarf2_section_info eh_frame {};
|
|
dwarf2_section_info gdb_index {};
|
|
dwarf2_section_info debug_names {};
|
|
dwarf2_section_info debug_aranges {};
|
|
|
|
std::vector<dwarf2_section_info> types;
|
|
|
|
/* Table of all the compilation units. This is used to locate
|
|
the target compilation unit of a particular reference. */
|
|
std::vector<dwarf2_per_cu_data *> all_comp_units;
|
|
|
|
/* The .debug_types-related CUs (TUs). */
|
|
std::vector<signatured_type *> all_type_units;
|
|
|
|
/* Table of struct type_unit_group objects.
|
|
The hash key is the DW_AT_stmt_list value. */
|
|
htab_up type_unit_groups;
|
|
|
|
/* A table mapping .debug_types signatures to its signatured_type entry.
|
|
This is NULL if the .debug_types section hasn't been read in yet. */
|
|
htab_up signatured_types;
|
|
|
|
/* Type unit statistics, to see how well the scaling improvements
|
|
are doing. */
|
|
struct tu_stats tu_stats {};
|
|
|
|
/* A table mapping DW_AT_dwo_name values to struct dwo_file objects.
|
|
This is NULL if the table hasn't been allocated yet. */
|
|
htab_up dwo_files;
|
|
|
|
/* True if we've checked for whether there is a DWP file. */
|
|
bool dwp_checked = false;
|
|
|
|
/* The DWP file if there is one, or NULL. */
|
|
std::unique_ptr<struct dwp_file> dwp_file;
|
|
|
|
/* The shared '.dwz' file, if one exists. This is used when the
|
|
original data was compressed using 'dwz -m'. */
|
|
std::unique_ptr<struct dwz_file> dwz_file;
|
|
|
|
/* Whether copy relocations are supported by this object format. */
|
|
bool can_copy;
|
|
|
|
/* A flag indicating whether this objfile has a section loaded at a
|
|
VMA of 0. */
|
|
bool has_section_at_zero = false;
|
|
|
|
/* True if we are using the mapped index,
|
|
or we are faking it for OBJF_READNOW's sake. */
|
|
bool using_index = false;
|
|
|
|
/* The mapped index, or NULL if .gdb_index is missing or not being used. */
|
|
std::unique_ptr<mapped_index> index_table;
|
|
|
|
/* The mapped index, or NULL if .debug_names is missing or not being used. */
|
|
std::unique_ptr<mapped_debug_names> debug_names_table;
|
|
|
|
/* When using index_table, this keeps track of all quick_file_names entries.
|
|
TUs typically share line table entries with a CU, so we maintain a
|
|
separate table of all line table entries to support the sharing.
|
|
Note that while there can be way more TUs than CUs, we've already
|
|
sorted all the TUs into "type unit groups", grouped by their
|
|
DW_AT_stmt_list value. Therefore the only sharing done here is with a
|
|
CU and its associated TU group if there is one. */
|
|
htab_up quick_file_names_table;
|
|
|
|
/* Set during partial symbol reading, to prevent queueing of full
|
|
symbols. */
|
|
bool reading_partial_symbols = false;
|
|
|
|
/* The CUs we recently read. */
|
|
std::vector<dwarf2_per_cu_data *> just_read_cus;
|
|
|
|
/* Table containing all filenames. This is an optional because the
|
|
table is lazily constructed on first access. */
|
|
gdb::optional<filename_seen_cache> filenames_cache;
|
|
|
|
/* If we loaded the index from an external file, this contains the
|
|
resources associated to the open file, memory mapping, etc. */
|
|
std::unique_ptr<index_cache_resource> index_cache_res;
|
|
|
|
/* Mapping from abstract origin DIE to concrete DIEs that reference it as
|
|
DW_AT_abstract_origin. */
|
|
std::unordered_map<sect_offset, std::vector<sect_offset>,
|
|
gdb::hash_enum<sect_offset>>
|
|
abstract_to_concrete;
|
|
|
|
/* CUs that are queued to be read. */
|
|
std::queue<dwarf2_queue_item> queue;
|
|
|
|
/* We keep a separate reference to the partial symtabs, in case we
|
|
are sharing them between objfiles. This is only set after
|
|
partial symbols have been read the first time. */
|
|
std::shared_ptr<psymtab_storage> partial_symtabs;
|
|
|
|
private:
|
|
|
|
/* The total number of per_cu and signatured_type objects that have
|
|
been created so far for this reader. */
|
|
size_t m_num_psymtabs = 0;
|
|
};
|
|
|
|
/* This is the per-objfile data associated with a type_unit_group. */
|
|
|
|
struct type_unit_group_unshareable
|
|
{
|
|
/* The compunit symtab.
|
|
Type units in a group needn't all be defined in the same source file,
|
|
so we create an essentially anonymous symtab as the compunit symtab. */
|
|
struct compunit_symtab *compunit_symtab = nullptr;
|
|
|
|
/* The number of symtabs from the line header.
|
|
The value here must match line_header.num_file_names. */
|
|
unsigned int num_symtabs = 0;
|
|
|
|
/* The symbol tables for this TU (obtained from the files listed in
|
|
DW_AT_stmt_list).
|
|
WARNING: The order of entries here must match the order of entries
|
|
in the line header. After the first TU using this type_unit_group, the
|
|
line header for the subsequent TUs is recreated from this. This is done
|
|
because we need to use the same symtabs for each TU using the same
|
|
DW_AT_stmt_list value. Also note that symtabs may be repeated here,
|
|
there's no guarantee the line header doesn't have duplicate entries. */
|
|
struct symtab **symtabs = nullptr;
|
|
};
|
|
|
|
/* Collection of data recorded per objfile.
|
|
This hangs off of dwarf2_objfile_data_key.
|
|
|
|
Some DWARF data cannot (currently) be shared across objfiles. Such
|
|
data is stored in this object. */
|
|
|
|
struct dwarf2_per_objfile
|
|
{
|
|
dwarf2_per_objfile (struct objfile *objfile, dwarf2_per_bfd *per_bfd)
|
|
: objfile (objfile), per_bfd (per_bfd)
|
|
{}
|
|
|
|
~dwarf2_per_objfile ();
|
|
|
|
/* Return pointer to string at .debug_line_str offset as read from BUF.
|
|
BUF is assumed to be in a compilation unit described by CU_HEADER.
|
|
Return *BYTES_READ_PTR count of bytes read from BUF. */
|
|
const char *read_line_string (const gdb_byte *buf,
|
|
const struct comp_unit_head *cu_header,
|
|
unsigned int *bytes_read_ptr);
|
|
|
|
/* Resize the M_SYMTABS vector to the needed size (the number of partial
|
|
symtabs allocated by the per-bfd). */
|
|
void resize_symtabs ()
|
|
{
|
|
/* The symtabs vector should only grow, not shrink. */
|
|
gdb_assert (per_bfd->num_psymtabs () >= m_symtabs.size ());
|
|
|
|
m_symtabs.resize (per_bfd->num_psymtabs ());
|
|
}
|
|
|
|
/* Return true if the symtab corresponding to PER_CU has been set,
|
|
false otherwise. */
|
|
bool symtab_set_p (const dwarf2_per_cu_data *per_cu) const;
|
|
|
|
/* Return the compunit_symtab associated to PER_CU, if it has been created. */
|
|
compunit_symtab *get_symtab (const dwarf2_per_cu_data *per_cu) const;
|
|
|
|
/* Set the compunit_symtab associated to PER_CU. */
|
|
void set_symtab (const dwarf2_per_cu_data *per_cu, compunit_symtab *symtab);
|
|
|
|
/* Get the type_unit_group_unshareable corresponding to TU_GROUP. If one
|
|
does not exist, create it. */
|
|
type_unit_group_unshareable *get_type_unit_group_unshareable
|
|
(type_unit_group *tu_group);
|
|
|
|
struct type *get_type_for_signatured_type (signatured_type *sig_type) const;
|
|
|
|
void set_type_for_signatured_type (signatured_type *sig_type,
|
|
struct type *type);
|
|
|
|
/* Find an integer type SIZE_IN_BYTES bytes in size and return it.
|
|
UNSIGNED_P controls if the integer is unsigned or not. */
|
|
struct type *int_type (int size_in_bytes, bool unsigned_p) const;
|
|
|
|
/* Get the dwarf2_cu matching PER_CU for this objfile. */
|
|
dwarf2_cu *get_cu (dwarf2_per_cu_data *per_cu);
|
|
|
|
/* Set the dwarf2_cu matching PER_CU for this objfile. */
|
|
void set_cu (dwarf2_per_cu_data *per_cu, dwarf2_cu *cu);
|
|
|
|
/* Remove/free the dwarf2_cu matching PER_CU for this objfile. */
|
|
void remove_cu (dwarf2_per_cu_data *per_cu);
|
|
|
|
/* Free all cached compilation units. */
|
|
void remove_all_cus ();
|
|
|
|
/* Increase the age counter on each CU compilation unit and free
|
|
any that are too old. */
|
|
void age_comp_units ();
|
|
|
|
/* Back link. */
|
|
struct objfile *objfile;
|
|
|
|
/* Pointer to the data that is (possibly) shared between this objfile and
|
|
other objfiles backed by the same BFD. */
|
|
struct dwarf2_per_bfd *per_bfd;
|
|
|
|
/* Table mapping type DIEs to their struct type *.
|
|
This is nullptr if not allocated yet.
|
|
The mapping is done via (CU/TU + DIE offset) -> type. */
|
|
htab_up die_type_hash;
|
|
|
|
/* Table containing line_header indexed by offset and offset_in_dwz. */
|
|
htab_up line_header_hash;
|
|
|
|
private:
|
|
/* Hold the corresponding compunit_symtab for each CU or TU. This
|
|
is indexed by dwarf2_per_cu_data::index. A NULL value means
|
|
that the CU/TU has not been expanded yet. */
|
|
std::vector<compunit_symtab *> m_symtabs;
|
|
|
|
/* Map from a type unit group to the corresponding unshared
|
|
structure. */
|
|
typedef std::unique_ptr<type_unit_group_unshareable>
|
|
type_unit_group_unshareable_up;
|
|
|
|
std::unordered_map<type_unit_group *, type_unit_group_unshareable_up>
|
|
m_type_units;
|
|
|
|
/* Map from signatured types to the corresponding struct type. */
|
|
std::unordered_map<signatured_type *, struct type *> m_type_map;
|
|
|
|
/* Map from the objfile-independent dwarf2_per_cu_data instances to the
|
|
corresponding objfile-dependent dwarf2_cu instances. */
|
|
std::unordered_map<dwarf2_per_cu_data *, dwarf2_cu *> m_dwarf2_cus;
|
|
};
|
|
|
|
/* Get the dwarf2_per_objfile associated to OBJFILE. */
|
|
|
|
dwarf2_per_objfile *get_dwarf2_per_objfile (struct objfile *objfile);
|
|
|
|
/* A partial symtab specialized for DWARF. */
|
|
struct dwarf2_psymtab : public partial_symtab
|
|
{
|
|
dwarf2_psymtab (const char *filename, struct objfile *objfile,
|
|
dwarf2_per_cu_data *per_cu)
|
|
: partial_symtab (filename, objfile, 0),
|
|
per_cu_data (per_cu)
|
|
{
|
|
}
|
|
|
|
void read_symtab (struct objfile *) override;
|
|
void expand_psymtab (struct objfile *) override;
|
|
bool readin_p (struct objfile *) const override;
|
|
compunit_symtab *get_compunit_symtab (struct objfile *) const override;
|
|
|
|
struct dwarf2_per_cu_data *per_cu_data;
|
|
};
|
|
|
|
/* Persistent data held for a compilation unit, even when not
|
|
processing it. We put a pointer to this structure in the
|
|
psymtab. */
|
|
|
|
struct dwarf2_per_cu_data
|
|
{
|
|
/* The start offset and length of this compilation unit.
|
|
NOTE: Unlike comp_unit_head.length, this length includes
|
|
initial_length_size.
|
|
If the DIE refers to a DWO file, this is always of the original die,
|
|
not the DWO file. */
|
|
sect_offset sect_off;
|
|
unsigned int length;
|
|
|
|
/* DWARF standard version this data has been read from (such as 4 or 5). */
|
|
short dwarf_version;
|
|
|
|
/* Flag indicating this compilation unit will be read in before
|
|
any of the current compilation units are processed. */
|
|
unsigned int queued : 1;
|
|
|
|
/* This flag will be set when reading partial DIEs if we need to load
|
|
absolutely all DIEs for this compilation unit, instead of just the ones
|
|
we think are interesting. It gets set if we look for a DIE in the
|
|
hash table and don't find it. */
|
|
unsigned int load_all_dies : 1;
|
|
|
|
/* Non-zero if this CU is from .debug_types.
|
|
Struct dwarf2_per_cu_data is contained in struct signatured_type iff
|
|
this is non-zero. */
|
|
unsigned int is_debug_types : 1;
|
|
|
|
/* Non-zero if this CU is from the .dwz file. */
|
|
unsigned int is_dwz : 1;
|
|
|
|
/* Non-zero if reading a TU directly from a DWO file, bypassing the stub.
|
|
This flag is only valid if is_debug_types is true.
|
|
We can't read a CU directly from a DWO file: There are required
|
|
attributes in the stub. */
|
|
unsigned int reading_dwo_directly : 1;
|
|
|
|
/* Non-zero if the TU has been read.
|
|
This is used to assist the "Stay in DWO Optimization" for Fission:
|
|
When reading a DWO, it's faster to read TUs from the DWO instead of
|
|
fetching them from random other DWOs (due to comdat folding).
|
|
If the TU has already been read, the optimization is unnecessary
|
|
(and unwise - we don't want to change where gdb thinks the TU lives
|
|
"midflight").
|
|
This flag is only valid if is_debug_types is true. */
|
|
unsigned int tu_read : 1;
|
|
|
|
/* Our index in the unshared "symtabs" vector. */
|
|
unsigned index;
|
|
|
|
/* The section this CU/TU lives in.
|
|
If the DIE refers to a DWO file, this is always the original die,
|
|
not the DWO file. */
|
|
struct dwarf2_section_info *section;
|
|
|
|
/* The unit type of this CU. */
|
|
enum dwarf_unit_type unit_type;
|
|
|
|
/* The language of this CU. */
|
|
enum language lang;
|
|
|
|
/* Backlink to the owner of this. */
|
|
dwarf2_per_bfd *per_bfd;
|
|
|
|
/* DWARF header of this CU. Note that dwarf2_cu reads its own version of the
|
|
header, which may differ from this one, since it may pass rcuh_kind::TYPE
|
|
to read_comp_unit_head, whereas for dwarf2_per_cu_data we always pass
|
|
rcuh_kind::COMPILE.
|
|
|
|
Don't access this field directly, use the get_header method instead. It
|
|
should be private, but we can't make it private at the moment. */
|
|
mutable comp_unit_head m_header;
|
|
|
|
/* True if HEADER has been read in.
|
|
|
|
Don't access this field directly. It should be private, but we can't make
|
|
it private at the moment. */
|
|
mutable bool m_header_read_in;
|
|
|
|
/* When dwarf2_per_bfd::using_index is true, the 'quick' field
|
|
is active. Otherwise, the 'psymtab' field is active. */
|
|
union
|
|
{
|
|
/* The partial symbol table associated with this compilation unit,
|
|
or NULL for unread partial units. */
|
|
dwarf2_psymtab *psymtab;
|
|
|
|
/* Data needed by the "quick" functions. */
|
|
struct dwarf2_per_cu_quick_data *quick;
|
|
} v;
|
|
|
|
/* The CUs we import using DW_TAG_imported_unit. This is filled in
|
|
while reading psymtabs, used to compute the psymtab dependencies,
|
|
and then cleared. Then it is filled in again while reading full
|
|
symbols, and only deleted when the objfile is destroyed.
|
|
|
|
This is also used to work around a difference between the way gold
|
|
generates .gdb_index version <=7 and the way gdb does. Arguably this
|
|
is a gold bug. For symbols coming from TUs, gold records in the index
|
|
the CU that includes the TU instead of the TU itself. This breaks
|
|
dw2_lookup_symbol: It assumes that if the index says symbol X lives
|
|
in CU/TU Y, then one need only expand Y and a subsequent lookup in Y
|
|
will find X. Alas TUs live in their own symtab, so after expanding CU Y
|
|
we need to look in TU Z to find X. Fortunately, this is akin to
|
|
DW_TAG_imported_unit, so we just use the same mechanism: For
|
|
.gdb_index version <=7 this also records the TUs that the CU referred
|
|
to. Concurrently with this change gdb was modified to emit version 8
|
|
indices so we only pay a price for gold generated indices.
|
|
http://sourceware.org/bugzilla/show_bug.cgi?id=15021.
|
|
|
|
This currently needs to be a public member due to how
|
|
dwarf2_per_cu_data is allocated and used. Ideally in future things
|
|
could be refactored to make this private. Until then please try to
|
|
avoid direct access to this member, and instead use the helper
|
|
functions above. */
|
|
std::vector <dwarf2_per_cu_data *> *imported_symtabs;
|
|
|
|
/* Return true of IMPORTED_SYMTABS is empty or not yet allocated. */
|
|
bool imported_symtabs_empty () const
|
|
{
|
|
return (imported_symtabs == nullptr || imported_symtabs->empty ());
|
|
}
|
|
|
|
/* Push P to the back of IMPORTED_SYMTABS, allocated IMPORTED_SYMTABS
|
|
first if required. */
|
|
void imported_symtabs_push (dwarf2_per_cu_data *p)
|
|
{
|
|
if (imported_symtabs == nullptr)
|
|
imported_symtabs = new std::vector <dwarf2_per_cu_data *>;
|
|
imported_symtabs->push_back (p);
|
|
}
|
|
|
|
/* Return the size of IMPORTED_SYMTABS if it is allocated, otherwise
|
|
return 0. */
|
|
size_t imported_symtabs_size () const
|
|
{
|
|
if (imported_symtabs == nullptr)
|
|
return 0;
|
|
return imported_symtabs->size ();
|
|
}
|
|
|
|
/* Delete IMPORTED_SYMTABS and set the pointer back to nullptr. */
|
|
void imported_symtabs_free ()
|
|
{
|
|
delete imported_symtabs;
|
|
imported_symtabs = nullptr;
|
|
}
|
|
|
|
/* Get the header of this per_cu, reading it if necessary. */
|
|
const comp_unit_head *get_header () const;
|
|
|
|
/* Return the address size given in the compilation unit header for
|
|
this CU. */
|
|
int addr_size () const;
|
|
|
|
/* Return the offset size given in the compilation unit header for
|
|
this CU. */
|
|
int offset_size () const;
|
|
|
|
/* Return the DW_FORM_ref_addr size given in the compilation unit
|
|
header for this CU. */
|
|
int ref_addr_size () const;
|
|
|
|
/* Return DWARF version number of this CU. */
|
|
short version () const
|
|
{
|
|
return dwarf_version;
|
|
}
|
|
|
|
/* A type unit group has a per_cu object that is recognized by
|
|
having no section. */
|
|
bool type_unit_group_p () const
|
|
{
|
|
return section == nullptr;
|
|
}
|
|
};
|
|
|
|
/* Entry in the signatured_types hash table. */
|
|
|
|
struct signatured_type
|
|
{
|
|
/* The "per_cu" object of this type.
|
|
This struct is used iff per_cu.is_debug_types.
|
|
N.B.: This is the first member so that it's easy to convert pointers
|
|
between them. */
|
|
struct dwarf2_per_cu_data per_cu;
|
|
|
|
/* The type's signature. */
|
|
ULONGEST signature;
|
|
|
|
/* Offset in the TU of the type's DIE, as read from the TU header.
|
|
If this TU is a DWO stub and the definition lives in a DWO file
|
|
(specified by DW_AT_GNU_dwo_name), this value is unusable. */
|
|
cu_offset type_offset_in_tu;
|
|
|
|
/* Offset in the section of the type's DIE.
|
|
If the definition lives in a DWO file, this is the offset in the
|
|
.debug_types.dwo section.
|
|
The value is zero until the actual value is known.
|
|
Zero is otherwise not a valid section offset. */
|
|
sect_offset type_offset_in_section;
|
|
|
|
/* Type units are grouped by their DW_AT_stmt_list entry so that they
|
|
can share them. This points to the containing symtab. */
|
|
struct type_unit_group *type_unit_group;
|
|
|
|
/* Containing DWO unit.
|
|
This field is valid iff per_cu.reading_dwo_directly. */
|
|
struct dwo_unit *dwo_unit;
|
|
};
|
|
|
|
/* Open the separate '.dwz' debug file, if needed. Return NULL if
|
|
there is no .gnu_debugaltlink section in the file. Error if there
|
|
is such a section but the file cannot be found. */
|
|
|
|
extern dwz_file *dwarf2_get_dwz_file (dwarf2_per_bfd *per_bfd);
|
|
|
|
/* Return the type of the DIE at DIE_OFFSET in the CU named by
|
|
PER_CU. */
|
|
|
|
struct type *dwarf2_get_die_type (cu_offset die_offset,
|
|
dwarf2_per_cu_data *per_cu,
|
|
dwarf2_per_objfile *per_objfile);
|
|
|
|
/* Given an index in .debug_addr, fetch the value.
|
|
NOTE: This can be called during dwarf expression evaluation,
|
|
long after the debug information has been read, and thus per_cu->cu
|
|
may no longer exist. */
|
|
|
|
CORE_ADDR dwarf2_read_addr_index (dwarf2_per_cu_data *per_cu,
|
|
dwarf2_per_objfile *per_objfile,
|
|
unsigned int addr_index);
|
|
|
|
/* Return DWARF block referenced by DW_AT_location of DIE at SECT_OFF at PER_CU.
|
|
Returned value is intended for DW_OP_call*. Returned
|
|
dwarf2_locexpr_baton->data has lifetime of
|
|
PER_CU->DWARF2_PER_OBJFILE->OBJFILE. */
|
|
|
|
struct dwarf2_locexpr_baton dwarf2_fetch_die_loc_sect_off
|
|
(sect_offset sect_off, dwarf2_per_cu_data *per_cu,
|
|
dwarf2_per_objfile *per_objfile,
|
|
gdb::function_view<CORE_ADDR ()> get_frame_pc,
|
|
bool resolve_abstract_p = false);
|
|
|
|
/* Like dwarf2_fetch_die_loc_sect_off, but take a CU
|
|
offset. */
|
|
|
|
struct dwarf2_locexpr_baton dwarf2_fetch_die_loc_cu_off
|
|
(cu_offset offset_in_cu, dwarf2_per_cu_data *per_cu,
|
|
dwarf2_per_objfile *per_objfile,
|
|
gdb::function_view<CORE_ADDR ()> get_frame_pc);
|
|
|
|
/* If the DIE at SECT_OFF in PER_CU has a DW_AT_const_value, return a
|
|
pointer to the constant bytes and set LEN to the length of the
|
|
data. If memory is needed, allocate it on OBSTACK. If the DIE
|
|
does not have a DW_AT_const_value, return NULL. */
|
|
|
|
extern const gdb_byte *dwarf2_fetch_constant_bytes
|
|
(sect_offset sect_off, dwarf2_per_cu_data *per_cu,
|
|
dwarf2_per_objfile *per_objfile, obstack *obstack,
|
|
LONGEST *len);
|
|
|
|
/* Return the type of the die at SECT_OFF in PER_CU. Return NULL if no
|
|
valid type for this die is found. */
|
|
|
|
struct type *dwarf2_fetch_die_type_sect_off
|
|
(sect_offset sect_off, dwarf2_per_cu_data *per_cu,
|
|
dwarf2_per_objfile *per_objfile);
|
|
|
|
/* When non-zero, dump line number entries as they are read in. */
|
|
extern unsigned int dwarf_line_debug;
|
|
|
|
#endif /* DWARF2READ_H */
|