From: Gary Benson <gbenson@redhat.com>
To: gdb-patches@sourceware.org
Subject: [RFA 5/4 take 2] Improved linker-debugger interface
Date: Thu, 19 Jul 2012 15:19:00 -0000 [thread overview]
Message-ID: <20120719151913.GF25093@redhat.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 798 bytes --]
Hi all,
I did some profiling and realised that the probes patch I just mailed
had reintroduced calls to update_section_map, a slow function I did
some work to avoid calling last year:
http://www.cygwin.com/ml/gdb-patches/2011-07/msg00460.html
http://www.cygwin.com/ml/gdb-patches/2011-10/msg00361.html
Attached is a patch to avoid calling update_section_map from the
probes interface. Updated timings are as follows:
no of solibs 100 250 500 1000 2000 5000
------------------------------------------------------------
old interface 1 3 9 35 141 942
new interface 0 0 1 4 14 89
(times in seconds)
So, with this patch GDB is not three but ten times faster.
Thanks,
Gary
--
http://gbenson.net/
[-- Attachment #2: rtld-stap-7.patch --]
[-- Type: text/plain, Size: 4603 bytes --]
2012-07-19 Gary Benson <gbenson@redhat.com>
* objfiles.h (inhibit_section_map_updates): New function
declaration.
(resume_section_map_updates): Likewise.
* objfiles.c (objfile_pspace_info): New field "inhibit_updates".
(find_pc_section): Do not update the section map if
inhibit_updates is set.
(inhibit_section_map_updates): New function.
(resume_section_map_updates): Likewise.
* solib-svr4.c (svr4_handle_solib_event): Inhibit section map
updates for calls to evaluate_probe_argument.
diff --git a/gdb/objfiles.h b/gdb/objfiles.h
index 0df5798..c7db1f2 100644
--- a/gdb/objfiles.h
+++ b/gdb/objfiles.h
@@ -522,6 +522,19 @@ extern void set_objfile_data (struct objfile *objfile,
extern void *objfile_data (struct objfile *objfile,
const struct objfile_data *data);
+/* In normal use, the section map will be rebuilt by FIND_PC_SECTION
+ if objfiles have been added, removed or relocated since it was last
+ called. Calling INHIBIT_SECTION_MAP_UPDATES will inhibit this
+ behavior until RESUME_SECTION_MAP_UPDATES is called. If you call
+ INHIBIT_SECTION_MAP_UPDATES you must ensure that every call to
+ FIND_PC_SECTION in the inhibited region relates to a section that
+ is already in the section map and has not since been removed or
+ relocated. */
+extern void inhibit_section_map_updates (void);
+
+/* Resume automatically rebuilding the section map as required. */
+extern void resume_section_map_updates (void);
+
extern void default_iterate_over_objfiles_in_search_order
(struct gdbarch *gdbarch,
iterate_over_objfiles_in_search_order_cb_ftype *cb,
diff --git a/gdb/objfiles.c b/gdb/objfiles.c
index 5ff0eb2..327b5d6 100644
--- a/gdb/objfiles.c
+++ b/gdb/objfiles.c
@@ -70,6 +70,9 @@ struct objfile_pspace_info
int objfiles_changed_p;
struct obj_section **sections;
int num_sections;
+
+ /* Nonzero if section map updates should be inhibited. */
+ int inhibit_updates;
};
/* Per-program-space data key. */
@@ -1289,7 +1292,7 @@ find_pc_section (CORE_ADDR pc)
return s;
pspace_info = get_objfile_pspace_data (current_program_space);
- if (pspace_info->objfiles_changed_p != 0)
+ if (pspace_info->objfiles_changed_p && !pspace_info->inhibit_updates)
{
update_section_map (current_program_space,
&pspace_info->sections,
@@ -1457,6 +1460,23 @@ objfiles_changed (void)
get_objfile_pspace_data (current_program_space)->objfiles_changed_p = 1;
}
+/* See comments in objfiles.h. */
+
+void
+inhibit_section_map_updates (void)
+{
+ get_objfile_pspace_data (current_program_space)->inhibit_updates = 1;
+
+}
+
+/* See comments in objfiles.h. */
+
+void
+resume_section_map_updates (void)
+{
+ get_objfile_pspace_data (current_program_space)->inhibit_updates = 0;
+}
+
/* The default implementation for the "iterate_over_objfiles_in_search_order"
gdbarch method. It is equivalent to use the ALL_OBJFILES macro,
searching the objfiles in the order they are stored internally,
diff --git a/gdb/solib-svr4.c b/gdb/solib-svr4.c
index 17395f7..d3c388b 100644
--- a/gdb/solib-svr4.c
+++ b/gdb/solib-svr4.c
@@ -1820,6 +1820,18 @@ svr4_handle_solib_event (bpstat bs)
if (action == NAMESPACE_NO_ACTION)
return;
+ /* EVALUATE_PROBE_ARGUMENT looks up symbols in the dynamic linker
+ using FIND_PC_SECTION. FIND_PC_SECTION is accelerated by a cache
+ called the section map. The section map is invalidated every
+ time a shared library is loaded or unloaded, and if the inferior
+ is generating a lot of shared library events then the section map
+ will be updated every time SVR4_HANDLE_SOLIB_EVENT is called.
+ We called FIND_PC_SECTION in SVR4_CREATE_SOLIB_EVENT_BREAKPOINTS,
+ so we can guarantee that the dynamic linker's sections are in the
+ section map. We can therefore inhibit section map updates across
+ these calls to EVALUATE_PROBE_ARGUMENT and save a lot of time. */
+ inhibit_section_map_updates ();
+
val = evaluate_probe_argument (pi->probe, 0);
if (val == NULL)
goto error;
@@ -1851,6 +1863,8 @@ svr4_handle_solib_event (bpstat bs)
action = NAMESPACE_RELOAD;
}
+ resume_section_map_updates ();
+
if (action == NAMESPACE_UPDATE_OR_RELOAD)
{
if (namespace_update_incremental (info, lmid, lm, is_initial_ns))
@@ -1873,6 +1887,7 @@ svr4_handle_solib_event (bpstat bs)
warning (_("Probes-based dynamic linker interface failed.\n"
"Reverting to original interface.\n"));
+ resume_section_map_updates ();
free_namespace_table (info);
free_probes (info);
info->using_probes = 0;
next reply other threads:[~2012-07-19 15:19 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-07-19 15:19 Gary Benson [this message]
2012-07-19 19:23 ` dje
2012-07-20 9:33 ` Gary Benson
2012-07-19 21:17 ` André Pönitz
2012-07-20 10:02 ` Gary Benson
2012-07-25 18:19 ` Tom Tromey
2012-07-25 18:22 ` Tom Tromey
2012-07-31 12:21 ` Gary Benson
2012-07-31 14:44 ` Tom Tromey
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=20120719151913.GF25093@redhat.com \
--to=gbenson@redhat.com \
--cc=gdb-patches@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: link
Be 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