This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RFC: lazily read new inferior debuginfo


I would appreciate comments on this patch.

This is the final patch in my series to implement lazy reading of
debuginfo.

This patch implements a simple heuristic to decide when to read
debuginfo.  Debuginfo for most inferiors is read immediately.  However,
if we followed the inferior via a fork, then we defer reading it until
it is needed.

Before this patch, my `make' scenario takes 3 minutes in gdb; but after
it, the time drops to 1 minute.  (I have some subset of the debuginfo of
all the inferiors installed; the pre-patch scenario would be even slower
if I installed it all.)

Built and regtested on x86-64 (compile farm).

With this patch, we do still read some debuginfo for all new inferiors.
I see many instances of this:

    Reading symbols from /usr/lib/debug/lib/ld-2.12.2.so.debug...done.

This happens due to the call to find_pc_partial_function in
handle_inferior_event.  I haven't yet looked deeply into why this is
needed.

Tom

2011-03-09  Tom Tromey  <tromey@redhat.com>

	* symfile.c (symbol_file_add_main_1): Use inferior's
	symfile_flags.
	* solib.c (solib_read_symbols): Use inferior's symfile_flags.
	* linux-nat.c (linux_child_follow_fork): Set symfile_flags on
	inferior.
	* infrun.c (handle_vfork_child_exec_or_exit): Set symfile_flags on
	inferior.
	(follow_exec): Use inferior's symfile_flags.
	* inferior.h (struct inferior) <symfile_flags>: New field.

diff --git a/gdb/inferior.h b/gdb/inferior.h
index 13a06d9..62e3412 100644
--- a/gdb/inferior.h
+++ b/gdb/inferior.h
@@ -524,6 +524,11 @@ struct inferior
      if any catching is necessary.  */
   int total_syscalls_count;
 
+  /* Default flags to pass to the symbol reading functions.  These are
+     used whenever a new objfile is created.  The valid values come
+     from enum symfile_add_flags.  */
+  int symfile_flags;
+
   /* Per inferior data-pointers required by other GDB modules.  */
   void **data;
   unsigned num_data;
diff --git a/gdb/infrun.c b/gdb/infrun.c
index 7cee7c8..711309b 100644
--- a/gdb/infrun.c
+++ b/gdb/infrun.c
@@ -696,6 +696,7 @@ handle_vfork_child_exec_or_exit (int exec)
 	  pspace = add_program_space (maybe_new_address_space ());
 	  set_current_program_space (pspace);
 	  inf->removable = 1;
+	  inf->symfile_flags = SYMFILE_NO_READ;
 	  clone_program_space (pspace, inf->vfork_parent->pspace);
 	  inf->pspace = pspace;
 	  inf->aspace = pspace->aspace;
@@ -857,10 +858,13 @@ follow_exec (ptid_t pid, char *execd_pathname)
      solib_create_inferior_hook below.  breakpoint_re_set would fail to insert
      the breakpoints with the zero displacement.  */
 
-  symbol_file_add (execd_pathname, SYMFILE_MAINLINE | SYMFILE_DEFER_BP_RESET,
+  symbol_file_add (execd_pathname,
+		   (inf->symfile_flags
+		    | SYMFILE_MAINLINE | SYMFILE_DEFER_BP_RESET),
 		   NULL, 0);
 
-  set_initial_language ();
+  if ((inf->symfile_flags & SYMFILE_NO_READ) == 0)
+    set_initial_language ();
 
 #ifdef SOLIB_CREATE_INFERIOR_HOOK
   SOLIB_CREATE_INFERIOR_HOOK (PIDGET (inferior_ptid));
diff --git a/gdb/linux-nat.c b/gdb/linux-nat.c
index 922a2cf..a2a64b8 100644
--- a/gdb/linux-nat.c
+++ b/gdb/linux-nat.c
@@ -56,6 +56,7 @@
 #include "terminal.h"
 #include <sys/vfs.h>
 #include "solib.h"
+#include "symfile.h"
 
 #ifndef SPUFS_MAGIC
 #define SPUFS_MAGIC 0x23c9b64e
@@ -747,6 +748,7 @@ holding the child stopped.  Try \"set detach-on-fork\" or \
 	  child_lp = add_lwp (inferior_ptid);
 	  child_lp->stopped = 1;
 	  child_lp->resumed = 1;
+	  child_inf->symfile_flags = SYMFILE_NO_READ;
 
 	  /* If this is a vfork child, then the address-space is
 	     shared with the parent.  */
@@ -954,6 +956,7 @@ holding the child stopped.  Try \"set detach-on-fork\" or \
 	  child_inf->aspace = new_address_space ();
 	  child_inf->pspace = add_program_space (child_inf->aspace);
 	  child_inf->removable = 1;
+	  child_inf->symfile_flags = SYMFILE_NO_READ;
 	  set_current_program_space (child_inf->pspace);
 	  clone_program_space (child_inf->pspace, parent_pspace);
 
diff --git a/gdb/solib.c b/gdb/solib.c
index 2bf0751..f4bcdcd 100644
--- a/gdb/solib.c
+++ b/gdb/solib.c
@@ -631,6 +631,8 @@ solib_read_symbols (struct so_list *so, int flags)
     {
       volatile struct gdb_exception e;
 
+      flags |= current_inferior ()->symfile_flags;
+
       TRY_CATCH (e, RETURN_MASK_ERROR)
 	{
 	  struct section_addr_info *sap;
diff --git a/gdb/symfile.c b/gdb/symfile.c
index 06b5dec..9b19faa 100644
--- a/gdb/symfile.c
+++ b/gdb/symfile.c
@@ -1247,14 +1247,17 @@ symbol_file_add_main (char *args, int from_tty)
 static void
 symbol_file_add_main_1 (char *args, int from_tty, int flags)
 {
-  const int add_flags = SYMFILE_MAINLINE | (from_tty ? SYMFILE_VERBOSE : 0);
+  const int add_flags = (current_inferior ()->symfile_flags
+			 | SYMFILE_MAINLINE | (from_tty ? SYMFILE_VERBOSE : 0));
+
   symbol_file_add (args, add_flags, NULL, flags);
 
   /* Getting new symbols may change our opinion about
      what is frameless.  */
   reinit_frame_cache ();
 
-  set_initial_language ();
+  if ((flags & SYMFILE_NO_READ) == 0)
+    set_initial_language ();
 }
 
 void


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]