From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 26724 invoked by alias); 31 Jul 2012 12:21:24 -0000 Received: (qmail 26716 invoked by uid 22791); 31 Jul 2012 12:21:22 -0000 X-SWARE-Spam-Status: No, hits=-2.1 required=5.0 tests=AWL,BAYES_00,KHOP_THREADED,SPF_FAIL,TW_BJ X-Spam-Check-By: sourceware.org Received: from gbenson.demon.co.uk (HELO gbenson.demon.co.uk) (80.177.220.214) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 31 Jul 2012 12:21:07 +0000 Date: Tue, 31 Jul 2012 12:21:00 -0000 From: Gary Benson To: Tom Tromey Cc: gdb-patches@sourceware.org Subject: Re: [RFA 5/4 take 2] Improved linker-debugger interface Message-ID: <20120731122104.GC4756@redhat.com> Mail-Followup-To: Tom Tromey , gdb-patches@sourceware.org References: <20120719151913.GF25093@redhat.com> <87boj3hfaj.fsf@fleche.redhat.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="Bn2rw/3z4jIqBvZU" Content-Disposition: inline In-Reply-To: <87boj3hfaj.fsf@fleche.redhat.com> X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2012-07/txt/msg00796.txt.bz2 --Bn2rw/3z4jIqBvZU Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-length: 832 Tom Tromey wrote: > >>>>> "Gary" == Gary Benson writes: > Gary> +/* See comments in objfiles.h. */ > Gary> + > Gary> +void > Gary> +inhibit_section_map_updates (void) > Gary> +{ > Gary> + get_objfile_pspace_data (current_program_space)->inhibit_updates = 1; > Gary> + > Gary> +} > > Spurious blank line before the "}". > > Gary> @@ -1820,6 +1820,18 @@ svr4_handle_solib_event (bpstat bs) > [...] > Gary> + inhibit_section_map_updates (); > [...] > Gary> + resume_section_map_updates (); > > If there is any possibility of throwing an exception between these > calls, then there should be a cleanup instead. [snip] > If there is no possibility, then this patch is ok. I think it is possible, so I've changed it. Attached is an updated patch with both these fixes. Thanks, Gary -- http://gbenson.net/ --Bn2rw/3z4jIqBvZU Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="rtld-stap-7.patch" Content-length: 5113 2012-07-30 Gary Benson * objfiles.h (inhibit_section_map_updates): New function declaration. (resume_section_map_updates): Likewise. (resume_section_map_updates_cleanup): 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. (resume_section_map_updates_cleanup): 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,22 @@ 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); + +/* Version of the above suitable for use as a cleanup. */ +extern void resume_section_map_updates_cleanup (void *arg); + 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,30 @@ 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; +} + +/* See comments in objfiles.h. */ + +void +resume_section_map_updates_cleanup (void *arg) +{ + resume_section_map_updates (); +} + /* 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 @@ -1796,6 +1796,7 @@ struct svr4_info *info = get_svr4_info (); struct probe_and_info buf, *pi; enum probe_action action; + struct cleanup *cleanups = NULL; struct value *val; LONGEST lmid; CORE_ADDR debug_base, lm = 0; @@ -1820,6 +1821,19 @@ 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 (); + cleanups = make_cleanup (resume_section_map_updates_cleanup, NULL); + val = evaluate_probe_argument (pi->probe, 0); if (val == NULL) goto error; @@ -1851,6 +1865,9 @@ action = NAMESPACE_RELOAD; } + do_cleanups (cleanups); + cleanups = NULL; + if (action == NAMESPACE_UPDATE_OR_RELOAD) { if (namespace_update_incremental (info, lmid, lm, is_initial_ns)) @@ -1873,6 +1890,8 @@ warning (_("Probes-based dynamic linker interface failed.\n" "Reverting to original interface.\n")); + if (cleanups != NULL) + do_cleanups (cleanups); free_namespace_table (info); free_probes (info); info->using_probes = 0; --Bn2rw/3z4jIqBvZU--