public inbox for gdb-cvs@sourceware.org help / color / mirror / Atom feed
From: Tom Tromey <tromey@sourceware.org> To: gdb-cvs@sourceware.org Subject: [binutils-gdb] Capture directory in index_cache_store_context Date: Sat, 9 Mar 2024 00:27:24 +0000 (GMT) [thread overview] Message-ID: <20240309002724.84B1D385E448@sourceware.org> (raw) https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=2509ae7fb0f899ccf19126d1df8a7c31d5fe6aec commit 2509ae7fb0f899ccf19126d1df8a7c31d5fe6aec Author: Tom Tromey <tom@tromey.com> Date: Sat Jan 27 08:52:46 2024 -0700 Capture directory in index_cache_store_context I noticed that index_cache_store_context captures the 'enabled' setting, but not the index cache directory. This patch makes this change, which avoids a possible race -- with background reading, the user could possibly change this directory at the exact moment the writer examines the variable. Diff: --- gdb/dwarf2/index-cache.c | 9 +++++---- gdb/dwarf2/index-cache.h | 3 +++ 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/gdb/dwarf2/index-cache.c b/gdb/dwarf2/index-cache.c index 645e36c66f7..a269eb46a36 100644 --- a/gdb/dwarf2/index-cache.c +++ b/gdb/dwarf2/index-cache.c @@ -90,7 +90,8 @@ index_cache::disable () index_cache_store_context::index_cache_store_context (const index_cache &ic, dwarf2_per_bfd *per_bfd) - : m_enabled (ic.enabled ()) + : m_enabled (ic.enabled ()), + m_dir (ic.m_dir) { if (!m_enabled) return; @@ -124,7 +125,7 @@ index_cache_store_context::index_cache_store_context (const index_cache &ic, m_dwz_build_id_str = build_id_to_string (dwz_build_id); } - if (ic.m_dir.empty ()) + if (m_dir.empty ()) { warning (_("The index cache directory name is empty, skipping store.")); m_enabled = false; @@ -134,7 +135,7 @@ index_cache_store_context::index_cache_store_context (const index_cache &ic, try { /* Try to create the containing directory. */ - if (!mkdir_recursive (ic.m_dir.c_str ())) + if (!mkdir_recursive (m_dir.c_str ())) { warning (_("index cache: could not make cache directory: %s"), safe_strerror (errno)); @@ -170,7 +171,7 @@ index_cache::store (dwarf2_per_bfd *per_bfd, /* Write the index itself to the directory, using the build id as the filename. */ - write_dwarf_index (per_bfd, m_dir.c_str (), + write_dwarf_index (per_bfd, ctx.m_dir.c_str (), ctx.m_build_id_str.c_str (), dwz_build_id_ptr, dw_index_kind::GDB_INDEX); } diff --git a/gdb/dwarf2/index-cache.h b/gdb/dwarf2/index-cache.h index 079ed412d2e..f66f72caea1 100644 --- a/gdb/dwarf2/index-cache.h +++ b/gdb/dwarf2/index-cache.h @@ -48,6 +48,9 @@ private: /* Captured value of enabled (). */ bool m_enabled; + /* Captured value of index cache directory. */ + std::string m_dir; + /* Captured value of build id. */ std::string m_build_id_str;
reply other threads:[~2024-03-09 0:27 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20240309002724.84B1D385E448@sourceware.org \ --to=tromey@sourceware.org \ --cc=gdb-cvs@sourceware.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).