From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 11535 invoked by alias); 15 Jul 2011 20:52:27 -0000 Received: (qmail 11525 invoked by uid 22791); 15 Jul 2011 20:52:26 -0000 X-SWARE-Spam-Status: No, hits=-2.0 required=5.0 tests=AWL,BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,RP_MATCHES_RCVD,SPF_HELO_PASS X-Spam-Check-By: sourceware.org Received: from smtp-out.google.com (HELO smtp-out.google.com) (74.125.121.67) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 15 Jul 2011 20:52:12 +0000 Received: from wpaz5.hot.corp.google.com (wpaz5.hot.corp.google.com [172.24.198.69]) by smtp-out.google.com with ESMTP id p6FKqAeA032669 for ; Fri, 15 Jul 2011 13:52:11 -0700 Received: from elbrus2.mtv.corp.google.com (elbrus2.mtv.corp.google.com [172.18.111.111]) by wpaz5.hot.corp.google.com with ESMTP id p6FKq9DW009602; Fri, 15 Jul 2011 13:52:10 -0700 Received: by elbrus2.mtv.corp.google.com (Postfix, from userid 74925) id 8B3B3190BC2; Fri, 15 Jul 2011 13:52:09 -0700 (PDT) To: gdb-patches@sourceware.org Cc: ppluzhnikov@google.com Subject: [RFC][patch] Avoid repeated calls to solib_add on initial attach. Message-Id: <20110715205209.8B3B3190BC2@elbrus2.mtv.corp.google.com> Date: Fri, 15 Jul 2011 20:58:00 -0000 From: ppluzhnikov@google.com (Paul Pluzhnikov) 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: 2011-07/txt/msg00407.txt.bz2 Greetings, Following up on my earlier "slow on high-latency links" message: http://sourceware.org/ml/gdb-patches/2011-07/msg00391.html ... Attached patch avoids calling solib_add twice when initially attaching inferior. I am not entirely happy about this patch, but don't have a better idea for a fix, and do want to avoid repeated rescans of the shared library list. (Some of our executables use 4000+ shared libraries, and the time in solib_add does add up.) Tested on Linux/x86_64, no regressions. Comments? Thanks, -- Paul Pluzhnikov 2011-07-15 Paul Pluzhnikov * inferior.h (struct inferior): Add solib_add_generation. * infcmd.c (post_create_inferior): Only call solib_add if not already done. * solib.c (solib_add): Increment solib_add_generation. Index: inferior.h =================================================================== RCS file: /cvs/src/src/gdb/inferior.h,v retrieving revision 1.160 diff -u -p -r1.160 inferior.h --- inferior.h 3 Jun 2011 15:32:44 -0000 1.160 +++ inferior.h 15 Jul 2011 20:10:20 -0000 @@ -536,6 +536,9 @@ struct inferior if any catching is necessary. */ int total_syscalls_count; + /* This counts the number of solib_add() calls performed. */ + int solib_add_generation; + /* Per inferior data-pointers required by other GDB modules. */ void **data; unsigned num_data; Index: solib.c =================================================================== RCS file: /cvs/src/src/gdb/solib.c,v retrieving revision 1.149 diff -u -p -r1.149 solib.c --- solib.c 30 Jun 2011 19:29:54 -0000 1.149 +++ solib.c 15 Jul 2011 20:10:20 -0000 @@ -914,6 +914,8 @@ solib_add (char *pattern, int from_tty, { struct so_list *gdb; + current_inferior ()->solib_add_generation++; + if (pattern) { char *re_err = re_comp (pattern); Index: infcmd.c =================================================================== RCS file: /cvs/src/src/gdb/infcmd.c,v retrieving revision 1.287 diff -u -p -r1.287 infcmd.c --- infcmd.c 30 May 2011 18:04:32 -0000 1.287 +++ infcmd.c 15 Jul 2011 20:50:56 -0000 @@ -398,6 +398,7 @@ void post_create_inferior (struct target_ops *target, int from_tty) { volatile struct gdb_exception ex; + int solib_add_generation; /* Be sure we own the terminal in case write operations are performed. */ target_terminal_ours (); @@ -419,6 +420,7 @@ post_create_inferior (struct target_ops if (ex.reason < 0 && ex.error != NOT_AVAILABLE_ERROR) throw_exception (ex); + solib_add_generation = current_inferior ()->solib_add_generation; if (exec_bfd) { /* Create the hooks to handle shared library load and unload @@ -432,14 +434,16 @@ post_create_inferior (struct target_ops /* If the solist is global across processes, there's no need to refetch it here. */ - if (exec_bfd && !gdbarch_has_global_solist (target_gdbarch)) + if (exec_bfd && !gdbarch_has_global_solist (target_gdbarch) + && current_inferior ()->solib_add_generation == solib_add_generation) { /* Sometimes the platform-specific hook loads initial shared libraries, and sometimes it doesn't. If it doesn't FROM_TTY will be incorrectly 0 but such solib targets should be fixed anyway. If we made all the inferior hook methods consistent, this call could be removed. Call it only after the solib target has been initialized by - solib_create_inferior_hook. */ + solib_create_inferior_hook. Only do this if not alreay done from + inside solib_create_inferior_hook. */ #ifdef SOLIB_ADD SOLIB_ADD (NULL, 0, target, auto_solib_add);