This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[RFC][patch] Avoid repeated calls to solib_add on initial attach.
- From: ppluzhnikov at google dot com (Paul Pluzhnikov)
- To: gdb-patches at sourceware dot org
- Cc: ppluzhnikov at google dot com
- Date: Fri, 15 Jul 2011 13:52:09 -0700 (PDT)
- Subject: [RFC][patch] Avoid repeated calls to solib_add on initial attach.
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 <ppluzhnikov@google.com>
* 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);