Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Paul Pluzhnikov <ppluzhnikov@google.com>
To: Pedro Alves <pedro@codesourcery.com>
Cc: gdb-patches@sourceware.org, Luis Machado <lgustavo@codesourcery.com>
Subject: Re: [RFC][patch] Avoid repeated calls to solib_add on initial attach.
Date: Fri, 22 Jul 2011 17:27:00 -0000	[thread overview]
Message-ID: <CALoOobOabEOxAh1aqhpDpxFT7g=Xf4CBATcPVbSfijM7V4T5bQ@mail.gmail.com> (raw)
In-Reply-To: <201107201903.22754.pedro@codesourcery.com>

[-- Attachment #1: Type: text/plain, Size: 593 bytes --]

On Wed, Jul 20, 2011 at 11:03 AM, Pedro Alves <pedro@codesourcery.com> wrote:

> (Meant to say before but forgot... the DSO list is per
> program space, not inferior -- you should move the
> counter to struct program_space)

Thanks for comments.

Revised patch attached. Tested on Linux/x86_64 with no regressions.


-- 
Paul Pluzhnikov


2011-07-22  Paul Pluzhnikov  <ppluzhnikov@google.com>

	* progspace.h (struct program_space): 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.

[-- Attachment #2: gdb-suppress-repeated-solib-add-20110722.txt --]
[-- Type: text/plain, Size: 3261 bytes --]

Index: progspace.h
===================================================================
RCS file: /cvs/src/src/gdb/progspace.h,v
retrieving revision 1.7
diff -u -p -r1.7 progspace.h
--- progspace.h	10 Jan 2011 20:38:50 -0000	1.7
+++ progspace.h	22 Jul 2011 17:03:07 -0000
@@ -185,6 +185,9 @@ struct program_space
        solib.c.  */
     struct so_list *so_list;
 
+    /* Number of calls to solib_add.  */
+    unsigned solib_add_generation;
+
     /* Per pspace data-pointers required by other GDB modules.  */
     void **data;
     unsigned num_data;
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	22 Jul 2011 17:03:07 -0000
@@ -421,6 +421,9 @@ post_create_inferior (struct target_ops 
 
   if (exec_bfd)
     {
+      const unsigned solib_add_generation
+	= current_program_space->solib_add_generation;
+
       /* Create the hooks to handle shared library load and unload
 	 events.  */
 #ifdef SOLIB_CREATE_INFERIOR_HOOK
@@ -428,24 +431,29 @@ post_create_inferior (struct target_ops 
 #else
       solib_create_inferior_hook (from_tty);
 #endif
-    }
-
-  /* If the solist is global across processes, there's no need to
-     refetch it here.  */
-  if (exec_bfd && !gdbarch_has_global_solist (target_gdbarch))
-    {
-      /* 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.  */
 
+      if (current_program_space->solib_add_generation == solib_add_generation)
+	{
+	  /* The platform-specific hook should load initial shared libraries,
+	     but didn't.  FROM_TTY will be incorrectly 0 but such solib
+	     targets should be fixed anyway.  Call it only after the solib
+	     target has been initialized by solib_create_inferior_hook.  */
+
+	  if (info_verbose)
+	    warning (_("platform-specific solib_create_inferior_hook did "
+		       "not load initial shared libraries."));
+
+	  /* If the solist is global across processes, there's no need to
+	     refetch it here.  */
+	  if (!gdbarch_has_global_solist (target_gdbarch))
+	    {
 #ifdef SOLIB_ADD
-      SOLIB_ADD (NULL, 0, target, auto_solib_add);
+	      SOLIB_ADD (NULL, 0, target, auto_solib_add);
 #else
-      solib_add (NULL, 0, target, auto_solib_add);
+	      solib_add (NULL, 0, target, auto_solib_add);
 #endif
+	    }
+	}
     }
 
   /* If the user sets watchpoints before execution having started,
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	22 Jul 2011 17:03:07 -0000
@@ -914,6 +914,8 @@ solib_add (char *pattern, int from_tty,
 {
   struct so_list *gdb;
 
+  current_program_space->solib_add_generation++;
+
   if (pattern)
     {
       char *re_err = re_comp (pattern);

  reply	other threads:[~2011-07-22 17:19 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-07-15 20:58 Paul Pluzhnikov
2011-07-20 13:56 ` Gary Benson
2011-07-20 14:59 ` Pedro Alves
2011-07-20 16:15   ` Paul Pluzhnikov
2011-07-20 16:56     ` Pedro Alves
2011-07-20 16:59       ` Paul Pluzhnikov
2011-07-20 17:36         ` Pedro Alves
2011-07-20 18:38       ` Pedro Alves
2011-07-22 17:27         ` Paul Pluzhnikov [this message]
2011-07-22 17:51           ` Pedro Alves
2011-07-22 17:36     ` Tom Tromey
2011-07-22 17:43       ` Pedro Alves

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='CALoOobOabEOxAh1aqhpDpxFT7g=Xf4CBATcPVbSfijM7V4T5bQ@mail.gmail.com' \
    --to=ppluzhnikov@google.com \
    --cc=gdb-patches@sourceware.org \
    --cc=lgustavo@codesourcery.com \
    --cc=pedro@codesourcery.com \
    /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