]> git.pld-linux.org Git - packages/gdb.git/blame - gdb-dlopen-stap-probe-7of7.patch
- typo
[packages/gdb.git] / gdb-dlopen-stap-probe-7of7.patch
CommitLineData
a7de96f0
PS
12012-07-30 Gary Benson <gbenson@redhat.com>
2
3 * objfiles.h (inhibit_section_map_updates): New function
4 declaration.
5 (resume_section_map_updates): Likewise.
6 (resume_section_map_updates_cleanup): Likewise.
7 * objfiles.c (objfile_pspace_info): New field "inhibit_updates".
8 (find_pc_section): Do not update the section map if
9 inhibit_updates is set.
10 (inhibit_section_map_updates): New function.
11 (resume_section_map_updates): Likewise.
12 (resume_section_map_updates_cleanup): Likewise.
13 * solib-svr4.c (svr4_handle_solib_event): Inhibit section map
14 updates for calls to evaluate_probe_argument.
15
16Index: gdb-7.4.91.20120814/gdb/objfiles.h
17===================================================================
18--- gdb-7.4.91.20120814.orig/gdb/objfiles.h 2012-08-14 17:16:54.000000000 +0200
19+++ gdb-7.4.91.20120814/gdb/objfiles.h 2012-08-14 17:20:55.913174609 +0200
20@@ -526,6 +526,22 @@ extern void set_objfile_data (struct obj
21 extern void *objfile_data (struct objfile *objfile,
22 const struct objfile_data *data);
23
24+/* In normal use, the section map will be rebuilt by FIND_PC_SECTION
25+ if objfiles have been added, removed or relocated since it was last
26+ called. Calling INHIBIT_SECTION_MAP_UPDATES will inhibit this
27+ behavior until RESUME_SECTION_MAP_UPDATES is called. If you call
28+ INHIBIT_SECTION_MAP_UPDATES you must ensure that every call to
29+ FIND_PC_SECTION in the inhibited region relates to a section that
30+ is already in the section map and has not since been removed or
31+ relocated. */
32+extern void inhibit_section_map_updates (void);
33+
34+/* Resume automatically rebuilding the section map as required. */
35+extern void resume_section_map_updates (void);
36+
37+/* Version of the above suitable for use as a cleanup. */
38+extern void resume_section_map_updates_cleanup (void *arg);
39+
40 extern void default_iterate_over_objfiles_in_search_order
41 (struct gdbarch *gdbarch,
42 iterate_over_objfiles_in_search_order_cb_ftype *cb,
43Index: gdb-7.4.91.20120814/gdb/objfiles.c
44===================================================================
45--- gdb-7.4.91.20120814.orig/gdb/objfiles.c 2012-08-14 17:16:55.000000000 +0200
46+++ gdb-7.4.91.20120814/gdb/objfiles.c 2012-08-14 17:20:55.915174609 +0200
47@@ -70,6 +70,9 @@ struct objfile_pspace_info
48 int objfiles_changed_p;
49 struct obj_section **sections;
50 int num_sections;
51+
52+ /* Nonzero if section map updates should be inhibited. */
53+ int inhibit_updates;
54 };
55
56 /* Per-program-space data key. */
57@@ -1295,7 +1298,7 @@ find_pc_section (CORE_ADDR pc)
58 return s;
59
60 pspace_info = get_objfile_pspace_data (current_program_space);
61- if (pspace_info->objfiles_changed_p != 0)
62+ if (pspace_info->objfiles_changed_p && !pspace_info->inhibit_updates)
63 {
64 update_section_map (current_program_space,
65 &pspace_info->sections,
66@@ -1463,6 +1466,30 @@ objfiles_changed (void)
67 get_objfile_pspace_data (current_program_space)->objfiles_changed_p = 1;
68 }
69
70+/* See comments in objfiles.h. */
71+
72+void
73+inhibit_section_map_updates (void)
74+{
75+ get_objfile_pspace_data (current_program_space)->inhibit_updates = 1;
76+}
77+
78+/* See comments in objfiles.h. */
79+
80+void
81+resume_section_map_updates (void)
82+{
83+ get_objfile_pspace_data (current_program_space)->inhibit_updates = 0;
84+}
85+
86+/* See comments in objfiles.h. */
87+
88+void
89+resume_section_map_updates_cleanup (void *arg)
90+{
91+ resume_section_map_updates ();
92+}
93+
94 /* The default implementation for the "iterate_over_objfiles_in_search_order"
95 gdbarch method. It is equivalent to use the ALL_OBJFILES macro,
96 searching the objfiles in the order they are stored internally,
97Index: gdb-7.4.91.20120814/gdb/solib-svr4.c
98===================================================================
99--- gdb-7.4.91.20120814.orig/gdb/solib-svr4.c 2012-08-14 17:20:42.000000000 +0200
100+++ gdb-7.4.91.20120814/gdb/solib-svr4.c 2012-08-14 17:21:14.090169216 +0200
101@@ -1847,6 +1847,7 @@ svr4_handle_solib_event (bpstat bs)
102 struct svr4_info *info = get_svr4_info ();
103 struct probe_and_info buf, *pi = &buf;
104 enum probe_action action;
105+ struct cleanup *cleanups = NULL;
106 struct value *val;
107 LONGEST lmid;
108 CORE_ADDR debug_base, lm = 0;
109@@ -1870,6 +1871,19 @@ svr4_handle_solib_event (bpstat bs)
110 if (action == NAMESPACE_NO_ACTION)
111 return;
112
113+ /* EVALUATE_PROBE_ARGUMENT looks up symbols in the dynamic linker
114+ using FIND_PC_SECTION. FIND_PC_SECTION is accelerated by a cache
115+ called the section map. The section map is invalidated every
116+ time a shared library is loaded or unloaded, and if the inferior
117+ is generating a lot of shared library events then the section map
118+ will be updated every time SVR4_HANDLE_SOLIB_EVENT is called.
119+ We called FIND_PC_SECTION in SVR4_CREATE_SOLIB_EVENT_BREAKPOINTS,
120+ so we can guarantee that the dynamic linker's sections are in the
121+ section map. We can therefore inhibit section map updates across
122+ these calls to EVALUATE_PROBE_ARGUMENT and save a lot of time. */
123+ inhibit_section_map_updates ();
124+ cleanups = make_cleanup (resume_section_map_updates_cleanup, NULL);
125+
126 val = evaluate_probe_argument (pi->probe, 0);
127 if (val == NULL)
128 goto error;
129@@ -1901,6 +1915,9 @@ svr4_handle_solib_event (bpstat bs)
130 action = NAMESPACE_RELOAD;
131 }
132
133+ do_cleanups (cleanups);
134+ cleanups = NULL;
135+
136 if (action == NAMESPACE_UPDATE_OR_RELOAD)
137 {
138 if (namespace_update_incremental (info, lmid, lm, is_initial_ns))
139@@ -1923,6 +1940,8 @@ svr4_handle_solib_event (bpstat bs)
140 warning (_("Probes-based dynamic linker interface failed.\n"
141 "Reverting to original interface.\n"));
142
143+ if (cleanups != NULL)
144+ do_cleanups (cleanups);
145 free_namespace_table (info);
146 free_probes (info);
147 info->using_probes = 0;
This page took 0.046245 seconds and 4 git commands to generate.