File tree Expand file tree Collapse file tree 4 files changed +38
-8
lines changed Expand file tree Collapse file tree 4 files changed +38
-8
lines changed Original file line number Diff line number Diff line change @@ -460,12 +460,15 @@ cooked_index::cooked_index (vec_type &&vec)
460460void
461461cooked_index ::start_writing_index (dwarf2_per_bfd * per_bfd )
462462{
463+ index_cache_store_context ctx (global_index_cache );
464+
463465 /* This must be set after all the finalization tasks have been
464466 started, because it may call 'wait'. */
465467 m_write_future
466- = gdb ::thread_pool ::g_thread_pool -> post_task ([this , per_bfd ] ()
468+ = gdb ::thread_pool ::g_thread_pool -> post_task ([this , per_bfd ,
469+ ctx = std ::move (ctx )] ()
467470 {
468- maybe_write_index (per_bfd );
471+ maybe_write_index (per_bfd , ctx );
469472 });
470473}
471474
@@ -629,13 +632,14 @@ cooked_index::dump (gdbarch *arch) const
629632}
630633
631634void
632- cooked_index ::maybe_write_index (dwarf2_per_bfd * per_bfd )
635+ cooked_index ::maybe_write_index (dwarf2_per_bfd * per_bfd ,
636+ const index_cache_store_context & ctx )
633637{
634638 /* Wait for finalization. */
635639 wait ();
636640
637641 /* (maybe) store an index in the cache. */
638- global_index_cache .store (per_bfd );
642+ global_index_cache .store (per_bfd , ctx );
639643}
640644
641645/* Wait for all the index cache entries to be written before gdb
Original file line number Diff line number Diff line change 3737
3838struct dwarf2_per_cu_data ;
3939struct dwarf2_per_bfd ;
40+ struct index_cache_store_context ;
4041
4142/* Flags that describe an entry in the index. */
4243enum cooked_index_flag_enum : unsigned char
@@ -435,7 +436,8 @@ class cooked_index : public dwarf_scanner_base
435436private:
436437
437438 /* Maybe write the index to the index cache. */
438- void maybe_write_index (dwarf2_per_bfd *per_bfd);
439+ void maybe_write_index (dwarf2_per_bfd *per_bfd,
440+ const index_cache_store_context &);
439441
440442 /* The vector of cooked_index objects. This is stored because the
441443 entries are stored on the obstacks in those objects. */
Original file line number Diff line number Diff line change @@ -86,12 +86,20 @@ index_cache::disable ()
8686 m_enabled = false;
8787}
8888
89+ /* See index-cache.h. */
90+
91+ index_cache_store_context ::index_cache_store_context (const index_cache & ic )
92+ : m_enabled (ic .enabled ())
93+ {
94+ }
95+
8996/* See dwarf-index-cache.h. */
9097
9198void
92- index_cache ::store (dwarf2_per_bfd * per_bfd )
99+ index_cache ::store (dwarf2_per_bfd * per_bfd ,
100+ const index_cache_store_context & ctx )
93101{
94- if (!enabled () )
102+ if (!ctx . m_enabled )
95103 return ;
96104
97105 /* Get build id of objfile. */
Original file line number Diff line number Diff line change 2525#include " symfile.h"
2626
2727class dwarf2_per_bfd ;
28+ class index_cache ;
2829
2930/* Base of the classes used to hold the resources of the indices loaded from
3031 the cache (e.g. mmapped files). */
@@ -34,6 +35,20 @@ struct index_cache_resource
3435 virtual ~index_cache_resource () = 0 ;
3536};
3637
38+ /* Information to be captured in the main thread, and to be used by worker
39+ threads during store (). */
40+
41+ struct index_cache_store_context
42+ {
43+ friend class index_cache ;
44+
45+ explicit index_cache_store_context (const index_cache &ic);
46+
47+ private:
48+ /* Captured value of enabled (). */
49+ bool m_enabled;
50+ };
51+
3752/* Class to manage the access to the DWARF index cache. */
3853
3954class index_cache
@@ -55,7 +70,8 @@ class index_cache
5570 void disable ();
5671
5772 /* Store an index for the specified object file in the cache. */
58- void store (dwarf2_per_bfd *per_bfd);
73+ void store (dwarf2_per_bfd *per_bfd,
74+ const index_cache_store_context &);
5975
6076 /* Look for an index file matching BUILD_ID. If found, return the contents
6177 as an array_view and store the underlying resources (allocated memory,
You can’t perform that action at this time.
0 commit comments