From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2126) id A1743385E009; Sat, 9 Mar 2024 00:27:29 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A1743385E009 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1709944049; bh=88hGMJ7C1y9PWqj52zBzZCC+940Rw/E4KwuobUDAg0c=; h=From:To:Subject:Date:From; b=TL1tJRbwHO/IZptcnwEpn4hzhH+VxSOvAy94UsV4BFtnr7VUK0jn2Lgi6ybB4KMi/ OkKFGRJev4mztD644EQYqRH7wLmYo9LqGiu9mKev/d+18w1v6TE23jQYgE+Er6l0xY cO/X6Bi8kTdwAk6n17+LcIeVfsonmTuDh+btITZE= Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Tom Tromey To: gdb-cvs@sourceware.org Subject: [binutils-gdb] Capture the per-BFD object in index_cache_store_context X-Act-Checkin: binutils-gdb X-Git-Author: Tom Tromey X-Git-Refname: refs/heads/master X-Git-Oldrev: 2509ae7fb0f899ccf19126d1df8a7c31d5fe6aec X-Git-Newrev: b183313dfa9bcb221f3276eccfda1d875431b6be Message-Id: <20240309002729.A1743385E009@sourceware.org> Date: Sat, 9 Mar 2024 00:27:29 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3Db183313dfa9b= cb221f3276eccfda1d875431b6be commit b183313dfa9bcb221f3276eccfda1d875431b6be Author: Tom Tromey Date: Sat Jan 27 08:56:53 2024 -0700 Capture the per-BFD object in index_cache_store_context =20 This changes index_cache_store_context to also capture the per-BFD object when it is constructed. This is used when storing to the cache, and this approach makes the code a little simpler. Diff: --- gdb/dwarf2/cooked-index.c | 7 +++---- gdb/dwarf2/cooked-index.h | 3 +-- gdb/dwarf2/index-cache.c | 12 ++++++------ gdb/dwarf2/index-cache.h | 6 ++++-- 4 files changed, 14 insertions(+), 14 deletions(-) diff --git a/gdb/dwarf2/cooked-index.c b/gdb/dwarf2/cooked-index.c index dc8b6f08ff4..7d353c3d25e 100644 --- a/gdb/dwarf2/cooked-index.c +++ b/gdb/dwarf2/cooked-index.c @@ -631,7 +631,7 @@ cooked_index::set_contents (vec_type &&vec) gdb::task_group finalizers ([this, ctx =3D std::move (ctx)] () { m_state->set (cooked_state::FINALIZED); - maybe_write_index (m_per_bfd, ctx); + maybe_write_index (ctx); }); =20 for (auto &idx : m_vector) @@ -837,13 +837,12 @@ cooked_index::dump (gdbarch *arch) } =20 void -cooked_index::maybe_write_index (dwarf2_per_bfd *per_bfd, - const index_cache_store_context &ctx) +cooked_index::maybe_write_index (const index_cache_store_context &ctx) { if (index_for_writing () !=3D nullptr) { /* (maybe) store an index in the cache. */ - global_index_cache.store (m_per_bfd, ctx); + global_index_cache.store (ctx); } m_state->set (cooked_state::CACHE_DONE); } diff --git a/gdb/dwarf2/cooked-index.h b/gdb/dwarf2/cooked-index.h index 629a5b6b9ee..17659df0531 100644 --- a/gdb/dwarf2/cooked-index.h +++ b/gdb/dwarf2/cooked-index.h @@ -672,8 +672,7 @@ public: private: =20 /* Maybe write the index to the index cache. */ - void maybe_write_index (dwarf2_per_bfd *per_bfd, - const index_cache_store_context &); + void maybe_write_index (const index_cache_store_context &); =20 /* The vector of cooked_index objects. This is stored because the entries are stored on the obstacks in those objects. */ diff --git a/gdb/dwarf2/index-cache.c b/gdb/dwarf2/index-cache.c index a269eb46a36..91f2af3e275 100644 --- a/gdb/dwarf2/index-cache.c +++ b/gdb/dwarf2/index-cache.c @@ -91,7 +91,8 @@ index_cache::disable () index_cache_store_context::index_cache_store_context (const index_cache &i= c, dwarf2_per_bfd *per_bfd) : m_enabled (ic.enabled ()), - m_dir (ic.m_dir) + m_dir (ic.m_dir), + m_per_bfd (per_bfd) { if (!m_enabled) return; @@ -154,8 +155,7 @@ index_cache_store_context::index_cache_store_context (c= onst index_cache &ic, /* See dwarf-index-cache.h. */ =20 void -index_cache::store (dwarf2_per_bfd *per_bfd, - const index_cache_store_context &ctx) +index_cache::store (const index_cache_store_context &ctx) { if (!ctx.m_enabled) return; @@ -167,18 +167,18 @@ index_cache::store (dwarf2_per_bfd *per_bfd, try { index_cache_debug ("writing index cache for objfile %s", - bfd_get_filename (per_bfd->obfd)); + bfd_get_filename (ctx.m_per_bfd->obfd)); =20 /* Write the index itself to the directory, using the build id as the filename. */ - write_dwarf_index (per_bfd, ctx.m_dir.c_str (), + write_dwarf_index (ctx.m_per_bfd, ctx.m_dir.c_str (), ctx.m_build_id_str.c_str (), dwz_build_id_ptr, dw_index_kind::GDB_INDEX); } catch (const gdb_exception_error &except) { index_cache_debug ("couldn't store index cache for objfile %s: %s", - bfd_get_filename (per_bfd->obfd), except.what ()); + bfd_get_filename (ctx.m_per_bfd->obfd), except.what ()); } } =20 diff --git a/gdb/dwarf2/index-cache.h b/gdb/dwarf2/index-cache.h index f66f72caea1..09577aca257 100644 --- a/gdb/dwarf2/index-cache.h +++ b/gdb/dwarf2/index-cache.h @@ -51,6 +51,9 @@ private: /* Captured value of index cache directory. */ std::string m_dir; =20 + /* The per-bfd object that we're caching. */ + dwarf2_per_bfd *m_per_bfd; + /* Captured value of build id. */ std::string m_build_id_str; =20 @@ -80,8 +83,7 @@ public: void disable (); =20 /* Store an index for the specified object file in the cache. */ - void store (dwarf2_per_bfd *per_bfd, - const index_cache_store_context &); + void store (const index_cache_store_context &); =20 /* Look for an index file matching BUILD_ID. If found, return the conte= nts as an array_view and store the underlying resources (allocated memory,