diff options
author | Tom Tromey <tom@tromey.com> | 2020-02-08 13:40:54 -0700 |
---|---|---|
committer | Tom Tromey <tom@tromey.com> | 2020-02-08 13:40:59 -0700 |
commit | 82ca895718becbd1be898a86e4a6d1217fa496c6 (patch) | |
tree | 9678baae2a5c7c9772cb39b917bc87114d3261fc /gdb/dwarf2/index-cache.h | |
parent | 9e35d4996169bc7fa833e8449585d517b8ccc5f8 (diff) | |
download | gdb-82ca895718becbd1be898a86e4a6d1217fa496c6.zip gdb-82ca895718becbd1be898a86e4a6d1217fa496c6.tar.gz gdb-82ca895718becbd1be898a86e4a6d1217fa496c6.tar.bz2 |
Move DWARF code to dwarf2/ subdirectory
This moves all the remaining DWARF code to the new dwarf2
subdirectory. This is just a simple renaming, with updates to
includes as needed.
gdb/ChangeLog
2020-02-08 Tom Tromey <tom@tromey.com>
* dwarf2/expr.c: Rename from dwarf2expr.c.
* dwarf2/expr.h: Rename from dwarf2expr.h.
* dwarf2/frame-tailcall.c: Rename from dwarf2-frame-tailcall.c.
* dwarf2/frame-tailcall.h: Rename from dwarf2-frame-tailcall.h.
* dwarf2/frame.c: Rename from dwarf2-frame.c.
* dwarf2/frame.h: Rename from dwarf2-frame.h.
* dwarf2/index-cache.c: Rename from dwarf-index-cache.c.
* dwarf2/index-cache.h: Rename from dwarf-index-cache.h.
* dwarf2/index-common.c: Rename from dwarf-index-common.c.
* dwarf2/index-common.h: Rename from dwarf-index-common.h.
* dwarf2/index-write.c: Rename from dwarf-index-write.c.
* dwarf2/index-write.h: Rename from dwarf-index-write.h.
* dwarf2/loc.c: Rename from dwarf2loc.c.
* dwarf2/loc.h: Rename from dwarf2loc.h.
* dwarf2/read.c: Rename from dwarf2read.c.
* dwarf2/read.h: Rename from dwarf2read.h.
* dwarf2/abbrev.c, aarch64-tdep.c, alpha-tdep.c,
amd64-darwin-tdep.c, arc-tdep.c, arm-tdep.c, bfin-tdep.c,
compile/compile-c-symbols.c, compile/compile-cplus-symbols.c,
compile/compile-loc2c.c, cris-tdep.c, csky-tdep.c, findvar.c,
gdbtypes.c, guile/scm-type.c, h8300-tdep.c, hppa-bsd-tdep.c,
hppa-linux-tdep.c, i386-darwin-tdep.c, i386-linux-tdep.c,
i386-tdep.c, iq2000-tdep.c, m32c-tdep.c, m68hc11-tdep.c,
m68k-tdep.c, microblaze-tdep.c, mips-tdep.c, mn10300-tdep.c,
msp430-tdep.c, nds32-tdep.c, nios2-tdep.c, or1k-tdep.c,
riscv-tdep.c, rl78-tdep.c, rs6000-tdep.c, rx-tdep.c, s12z-tdep.c,
s390-tdep.c, score-tdep.c, sh-tdep.c, sparc-linux-tdep.c,
sparc-tdep.c, sparc64-linux-tdep.c, sparc64-tdep.c, tic6x-tdep.c,
tilegx-tdep.c, v850-tdep.c, xstormy16-tdep.c, xtensa-tdep.c:
Update.
* Makefile.in (COMMON_SFILES): Update.
(HFILES_NO_SRCDIR): Update.
Change-Id: Ied9ce1436cd27ac4a4cffef10ec92e396f181928
Diffstat (limited to 'gdb/dwarf2/index-cache.h')
-rw-r--r-- | gdb/dwarf2/index-cache.h | 112 |
1 files changed, 112 insertions, 0 deletions
diff --git a/gdb/dwarf2/index-cache.h b/gdb/dwarf2/index-cache.h new file mode 100644 index 0000000..07e93fa --- /dev/null +++ b/gdb/dwarf2/index-cache.h @@ -0,0 +1,112 @@ +/* Caching of GDB/DWARF index files. + + Copyright (C) 2018-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 DWARF_INDEX_CACHE_H +#define DWARF_INDEX_CACHE_H + +#include "dwarf2/index-common.h" +#include "gdbsupport/array-view.h" +#include "symfile.h" + +/* Base of the classes used to hold the resources of the indices loaded from + the cache (e.g. mmapped files). */ + +struct index_cache_resource +{ + virtual ~index_cache_resource () = 0; +}; + +/* Class to manage the access to the DWARF index cache. */ + +class index_cache +{ +public: + /* Change the directory used to save/load index files. */ + void set_directory (std::string dir); + + /* Return true if the usage of the cache is enabled. */ + bool enabled () const + { + return m_enabled; + } + + /* Enable the cache. */ + void enable (); + + /* Disable the cache. */ + void disable (); + + /* Store an index for the specified object file in the cache. */ + void store (struct dwarf2_per_objfile *dwarf2_per_objfile); + + /* Look for an index file matching BUILD_ID. If found, return the contents + as an array_view and store the underlying resources (allocated memory, + mapped file, etc) in RESOURCE. The returned array_view is valid as long + as RESOURCE is not destroyed. + + If no matching index file is found, return an empty array view. */ + gdb::array_view<const gdb_byte> + lookup_gdb_index (const bfd_build_id *build_id, + std::unique_ptr<index_cache_resource> *resource); + + /* Return the number of cache hits. */ + unsigned int n_hits () const + { return m_n_hits; } + + /* Record a cache hit. */ + void hit () + { + if (enabled ()) + m_n_hits++; + } + + /* Return the number of cache misses. */ + unsigned int n_misses () const + { return m_n_misses; } + + /* Record a cache miss. */ + void miss () + { + if (enabled ()) + m_n_misses++; + } + +private: + + /* Compute the absolute filename where the index of the objfile with build + id BUILD_ID will be stored. SUFFIX is appended at the end of the + filename. */ + std::string make_index_filename (const bfd_build_id *build_id, + const char *suffix) const; + + /* The base directory where we are storing and looking up index files. */ + std::string m_dir; + + /* Whether the cache is enabled. */ + bool m_enabled = false; + + /* Number of cache hits and misses during this GDB session. */ + unsigned int m_n_hits = 0; + unsigned int m_n_misses = 0; +}; + +/* The global instance of the index cache. */ +extern index_cache global_index_cache; + +#endif /* DWARF_INDEX_CACHE_H */ |