File tree 4 files changed +38
-8
lines changed
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)
460
460
void
461
461
cooked_index ::start_writing_index (dwarf2_per_bfd * per_bfd )
462
462
{
463
+ index_cache_store_context ctx (global_index_cache );
464
+
463
465
/* This must be set after all the finalization tasks have been
464
466
started, because it may call 'wait'. */
465
467
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 )] ()
467
470
{
468
- maybe_write_index (per_bfd );
471
+ maybe_write_index (per_bfd , ctx );
469
472
});
470
473
}
471
474
@@ -629,13 +632,14 @@ cooked_index::dump (gdbarch *arch) const
629
632
}
630
633
631
634
void
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 )
633
637
{
634
638
/* Wait for finalization. */
635
639
wait ();
636
640
637
641
/* (maybe) store an index in the cache. */
638
- global_index_cache .store (per_bfd );
642
+ global_index_cache .store (per_bfd , ctx );
639
643
}
640
644
641
645
/* Wait for all the index cache entries to be written before gdb
Original file line number Diff line number Diff line change 37
37
38
38
struct dwarf2_per_cu_data ;
39
39
struct dwarf2_per_bfd ;
40
+ struct index_cache_store_context ;
40
41
41
42
/* Flags that describe an entry in the index. */
42
43
enum cooked_index_flag_enum : unsigned char
@@ -435,7 +436,8 @@ class cooked_index : public dwarf_scanner_base
435
436
private:
436
437
437
438
/* 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 &);
439
441
440
442
/* The vector of cooked_index objects. This is stored because the
441
443
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 ()
86
86
m_enabled = false;
87
87
}
88
88
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
+
89
96
/* See dwarf-index-cache.h. */
90
97
91
98
void
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 )
93
101
{
94
- if (!enabled () )
102
+ if (!ctx . m_enabled )
95
103
return ;
96
104
97
105
/* Get build id of objfile. */
Original file line number Diff line number Diff line change 25
25
#include " symfile.h"
26
26
27
27
class dwarf2_per_bfd ;
28
+ class index_cache ;
28
29
29
30
/* Base of the classes used to hold the resources of the indices loaded from
30
31
the cache (e.g. mmapped files). */
@@ -34,6 +35,20 @@ struct index_cache_resource
34
35
virtual ~index_cache_resource () = 0 ;
35
36
};
36
37
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
+
37
52
/* Class to manage the access to the DWARF index cache. */
38
53
39
54
class index_cache
@@ -55,7 +70,8 @@ class index_cache
55
70
void disable ();
56
71
57
72
/* 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 &);
59
75
60
76
/* Look for an index file matching BUILD_ID. If found, return the contents
61
77
as an array_view and store the underlying resources (allocated memory,
You can’t perform that action at this time.
0 commit comments