public inbox for archer-commits@sourceware.org
help / color / mirror / Atom feed
* [SCM]  archer-sergiodj-lazier-debuginfo-reading: Add set-show command for tri-state auto-solib-add option.
@ 2011-06-15  6:51 sergiodj
  0 siblings, 0 replies; only message in thread
From: sergiodj @ 2011-06-15  6:51 UTC (permalink / raw)
  To: archer-commits

The branch, archer-sergiodj-lazier-debuginfo-reading has been updated
       via  3695c7921fa9090469faf2497729164651a437cb (commit)
       via  a3f180c4423115034083984e6a2c43356a6b31d7 (commit)
      from  e40b18e26f3ffbf9d8811bcf215beb754429844b (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email.

- Log -----------------------------------------------------------------
commit 3695c7921fa9090469faf2497729164651a437cb
Author: Sergio Durigan Junior <sergiodj@redhat.com>
Date:   Wed Jun 15 03:50:00 2011 -0300

    Add set-show command for tri-state auto-solib-add option.
    
    Implements a tri-state (`on', `off' and `lazy' options) for
    `auto-solib-add' command.

commit a3f180c4423115034083984e6a2c43356a6b31d7
Author: Sergio Durigan Junior <sergiodj@redhat.com>
Date:   Tue Jun 14 15:51:44 2011 -0300

    Adding `lazy_read' argument to `solib_add'.
    
    This commit adds the `lazy_read' argument to `solib_add', which allows
    the lazy reading of debuginfo files for shlibs.  This is necessary
    because in those situations `solib_add' should not reinit frame cache.

-----------------------------------------------------------------------

Summary of changes:
 gdb/breakpoint.c              |    4 +-
 gdb/config/rs6000/nm-rs6000.h |    2 +-
 gdb/frame.c                   |   12 +++++--
 gdb/infcmd.c                  |    4 +-
 gdb/infrun.c                  |    4 +-
 gdb/remote.c                  |    2 +-
 gdb/rs6000-nat.c              |    2 +-
 gdb/solib-frv.c               |    2 +-
 gdb/solib-ia64-hpux.c         |    4 +-
 gdb/solib-irix.c              |    3 +-
 gdb/solib-osf.c               |    3 +-
 gdb/solib-sunos.c             |    3 +-
 gdb/solib-svr4.c              |    8 +++--
 gdb/solib.c                   |   65 ++++++++++++++++++++++++++++++-----------
 gdb/solib.h                   |    4 ++-
 gdb/symfile.c                 |    2 +-
 gdb/symfile.h                 |   15 +++++++++-
 gdb/windows-nat.c             |    2 +-
 18 files changed, 98 insertions(+), 43 deletions(-)

First 500 lines of diff:
diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c
index 7093104..06ab3b9 100644
--- a/gdb/breakpoint.c
+++ b/gdb/breakpoint.c
@@ -4593,9 +4593,9 @@ bpstat_what (bpstat bs_head)
       target_terminal_ours_for_output ();
 
 #ifdef SOLIB_ADD
-      SOLIB_ADD (NULL, 0, &current_target, auto_solib_add);
+      SOLIB_ADD (NULL, 0, &current_target, auto_solib_add, /*lazy_read=*/0);
 #else
-      solib_add (NULL, 0, &current_target, auto_solib_add);
+      solib_add (NULL, 0, &current_target, auto_solib_add, /*lazy_read=*/0);
 #endif
 
       target_terminal_inferior ();
diff --git a/gdb/config/rs6000/nm-rs6000.h b/gdb/config/rs6000/nm-rs6000.h
index 380850c..769fb9e 100644
--- a/gdb/config/rs6000/nm-rs6000.h
+++ b/gdb/config/rs6000/nm-rs6000.h
@@ -29,7 +29,7 @@
 /* When a target process or core-file has been attached, we sneak in
    and figure out where the shared libraries have got to.  */
 
-#define	SOLIB_ADD(a, b, c, d)	\
+#define	SOLIB_ADD(a, b, c, d, e)	\
   if (PIDGET (inferior_ptid))	\
     /* Attach to process.  */  \
     xcoff_relocate_symtab (PIDGET (inferior_ptid)); \
diff --git a/gdb/frame.c b/gdb/frame.c
index 1bbd55c..c601eaa 100644
--- a/gdb/frame.c
+++ b/gdb/frame.c
@@ -682,10 +682,14 @@ frame_unwind_pc_if_available (struct frame_info *this_frame, CORE_ADDR *pc)
 				    hex_string (this_frame->prev_pc.value));
 	    }
 
-	  /* On-demand loading of shared libraries' debuginfo.  */
-	  solib = solib_match_pc_solist (pc);
-	  if (solib && !solib->symbols_loaded)
-	    solib_add (solib->so_name, 1, &current_target, 1);
+	  if (auto_solib_add == SOLIB_ADD_LAZY)
+	    {
+	      /* On-demand loading of shared libraries' debuginfo.  */
+	      solib = solib_match_pc_solist (pc);
+	      if (solib && !solib->symbols_loaded)
+		solib_add (solib->so_name, 1, &current_target, 1,
+			   /*lazy_read=*/1);
+	    }
 	}
       else
 	internal_error (__FILE__, __LINE__, _("No unwind_pc method"));
diff --git a/gdb/infcmd.c b/gdb/infcmd.c
index f857ba0..b867800 100644
--- a/gdb/infcmd.c
+++ b/gdb/infcmd.c
@@ -441,9 +441,9 @@ post_create_inferior (struct target_ops *target, int from_tty)
 	 solib_create_inferior_hook.  */
 
 #ifdef SOLIB_ADD
-      SOLIB_ADD (NULL, 0, target, auto_solib_add);
+      SOLIB_ADD (NULL, 0, target, auto_solib_add, /*lazy_read=*/0);
 #else
-      solib_add (NULL, 0, target, auto_solib_add);
+      solib_add (NULL, 0, target, auto_solib_add, /*lazy_read=*/0);
 #endif
     }
 
diff --git a/gdb/infrun.c b/gdb/infrun.c
index 36d265c..9c49098 100644
--- a/gdb/infrun.c
+++ b/gdb/infrun.c
@@ -3247,9 +3247,9 @@ handle_inferior_event (struct execution_control_state *ecs)
 	     require the table to contain all sections (including
 	     those found in shared libraries).  */
 #ifdef SOLIB_ADD
-	  SOLIB_ADD (NULL, 0, &current_target, auto_solib_add);
+	  SOLIB_ADD (NULL, 0, &current_target, auto_solib_add, /*lazy_read=*/0);
 #else
-	  solib_add (NULL, 0, &current_target, auto_solib_add);
+	  solib_add (NULL, 0, &current_target, auto_solib_add, /*lazy_read=*/0);
 #endif
 	  target_terminal_inferior ();
 
diff --git a/gdb/remote.c b/gdb/remote.c
index ff64b04..23e9294 100644
--- a/gdb/remote.c
+++ b/gdb/remote.c
@@ -3211,7 +3211,7 @@ remote_start_remote (int from_tty, struct target_ops *target, int extended_p)
   /* On OSs where the list of libraries is global to all
      processes, we fetch them early.  */
   if (gdbarch_has_global_solist (target_gdbarch))
-    solib_add (NULL, from_tty, target, auto_solib_add);
+    solib_add (NULL, from_tty, target, auto_solib_add, /*lazy_read=*/0);
 
   if (non_stop)
     {
diff --git a/gdb/rs6000-nat.c b/gdb/rs6000-nat.c
index e357c4d..39c5ede 100644
--- a/gdb/rs6000-nat.c
+++ b/gdb/rs6000-nat.c
@@ -801,7 +801,7 @@ add_vmap (LdInfo *ldi)
   vp->objfile = obj;
 
   /* Always add symbols for the main objfile.  */
-  if (vp == vmap || auto_solib_add)
+  if (vp == vmap || auto_solib_add == SOLIB_ADD_ON)
     vmap_add_symbols (vp);
   return vp;
 }
diff --git a/gdb/solib-frv.c b/gdb/solib-frv.c
index 7299cef..a791c50 100644
--- a/gdb/solib-frv.c
+++ b/gdb/solib-frv.c
@@ -1302,7 +1302,7 @@ frv_fetch_objfile_link_map (struct objfile *objfile)
 
   /* Cause frv_current_sos() to be run if it hasn't been already.  */
   if (main_lm_addr == 0)
-    solib_add (0, 0, 0, 1);
+    solib_add (0, 0, 0, 1, /*lazy_read=*/0);
 
   /* frv_current_sos() will set main_lm_addr for the main executable.  */
   if (objfile == symfile_objfile)
diff --git a/gdb/solib-ia64-hpux.c b/gdb/solib-ia64-hpux.c
index f6dd2dd..97d0436 100644
--- a/gdb/solib-ia64-hpux.c
+++ b/gdb/solib-ia64-hpux.c
@@ -257,7 +257,7 @@ ia64_hpux_handle_dld_breakpoint_1 (ptid_t ptid)
 	break;
       case BREAK_DE_LIB_LOADED:
 	ia64_hpux_handle_load_event (regcache);
-	solib_add (NULL, 0, &current_target, auto_solib_add);
+	solib_add (NULL, 0, &current_target, auto_solib_add, /*lazy_read=*/0);
 	break;
       case BREAK_DE_LIB_UNLOADED:
       case BREAK_DE_LOAD_COMPLETE:
@@ -567,7 +567,7 @@ chatr +dbg enable a.out"));
       break;  /* End of list.  */
 
   /* Resync the library list at the core level.  */
-  solib_add (NULL, 1, &current_target, auto_solib_add);
+  solib_add (NULL, 1, &current_target, auto_solib_add, /*lazy_read=*/0);
 }
 
 /* The "create_inferior_hook" target_so_ops routine for ia64-hpux.  */
diff --git a/gdb/solib-irix.c b/gdb/solib-irix.c
index 7bb528a..1598f03 100644
--- a/gdb/solib-irix.c
+++ b/gdb/solib-irix.c
@@ -495,7 +495,8 @@ irix_solib_create_inferior_hook (int from_tty)
      and will put out an annoying warning.
      Delaying the resetting of stop_soon until after symbol loading
      suppresses the warning.  */
-  solib_add ((char *) 0, 0, (struct target_ops *) 0, auto_solib_add);
+  solib_add ((char *) 0, 0, (struct target_ops *) 0, auto_solib_add,
+	     /*lazy_read=*/0);
   inf->control.stop_soon = NO_STOP_QUIETLY;
 }
 
diff --git a/gdb/solib-osf.c b/gdb/solib-osf.c
index 0905eb6..8c66152 100644
--- a/gdb/solib-osf.c
+++ b/gdb/solib-osf.c
@@ -356,7 +356,8 @@ osf_solib_create_inferior_hook (int from_tty)
      and will put out an annoying warning.
      Delaying the resetting of stop_soon until after symbol loading
      suppresses the warning.  */
-  solib_add ((char *) 0, 0, (struct target_ops *) 0, auto_solib_add);
+  solib_add ((char *) 0, 0, (struct target_ops *) 0, auto_solib_add,
+	     /*lazy_read=*/0);
   inf->control.stop_soon = NO_STOP_QUIETLY;
 }
 
diff --git a/gdb/solib-sunos.c b/gdb/solib-sunos.c
index 9936038..acec379 100644
--- a/gdb/solib-sunos.c
+++ b/gdb/solib-sunos.c
@@ -805,7 +805,8 @@ sunos_solib_create_inferior_hook (int from_tty)
       warning (_("shared library handler failed to disable breakpoint"));
     }
 
-  solib_add ((char *) 0, 0, (struct target_ops *) 0, auto_solib_add);
+  solib_add ((char *) 0, 0, (struct target_ops *) 0, auto_solib_add,
+	     /*lazy_read=*/0);
 }
 
 static void
diff --git a/gdb/solib-svr4.c b/gdb/solib-svr4.c
index 0491e7c..ca66c42 100644
--- a/gdb/solib-svr4.c
+++ b/gdb/solib-svr4.c
@@ -1241,7 +1241,7 @@ svr4_fetch_objfile_link_map (struct objfile *objfile)
 
   /* Cause svr4_current_sos() to be run if it hasn't been already.  */
   if (info->main_lm_addr == 0)
-    solib_add (NULL, 0, &current_target, auto_solib_add);
+    solib_add (NULL, 0, &current_target, auto_solib_add, /*lazy_read=*/0);
 
   /* svr4_current_sos() will set main_lm_addr for the main executable.  */
   if (objfile == symfile_objfile)
@@ -1370,7 +1370,8 @@ enable_break (struct svr4_info *info, int from_tty)
      mean r_brk has already been relocated.  Assume the dynamic linker
      is the object containing r_brk.  */
 
-  solib_add (NULL, from_tty, &current_target, auto_solib_add);
+  solib_add (NULL, from_tty, &current_target, auto_solib_add,
+	     /*lazy_read=*/0);
   sym_addr = 0;
   if (info->debug_base && solib_svr4_r_map (info) != 0)
     sym_addr = solib_svr4_r_brk (info);
@@ -1542,7 +1543,8 @@ enable_break (struct svr4_info *info, int from_tty)
 	  info->debug_loader_name = xstrdup (interp_name);
 	  info->debug_loader_offset_p = 1;
 	  info->debug_loader_offset = load_addr;
-	  solib_add (NULL, from_tty, &current_target, auto_solib_add);
+	  solib_add (NULL, from_tty, &current_target, auto_solib_add,
+		     /*lazy_read=*/0);
 	}
 
       /* Record the relocated start and end address of the dynamic linker
diff --git a/gdb/solib.c b/gdb/solib.c
index ad733af..d402b92 100644
--- a/gdb/solib.c
+++ b/gdb/solib.c
@@ -54,6 +54,18 @@
 /* Per-architecture data key.  */
 static struct gdbarch_data *solib_data;
 
+/* Used to store the user-defined setting for `auto-solib-add'.  */
+
+static const char *auto_solib_add_choice = "on";
+
+static const char *auto_solib_add_options[] =
+  {
+    "on",
+    "off",
+    "lazy",
+    NULL
+  };
+
 static void *
 solib_init (struct obstack *obstack)
 {
@@ -894,7 +906,7 @@ libpthread_solib_p (struct so_list *so)
    SYNOPSIS
 
    void solib_add (char *pattern, int from_tty, struct target_ops
-   *TARGET, int readsyms)
+   *TARGET, int readsyms, int lazy_read)
 
    DESCRIPTION
 
@@ -905,11 +917,15 @@ libpthread_solib_p (struct so_list *so)
    If READSYMS is 0, defer reading symbolic information until later
    but still do any needed low level processing.
 
+   If LAZY_READ is 1, it means we are lazily reading debuginfo files
+   and should not reinit the frame cache.
+
    FROM_TTY and TARGET are as described for update_solib_list, above.  */
 
 void
 solib_add (char *pattern, int from_tty,
-	   struct target_ops *target, int readsyms)
+	   struct target_ops *target, enum solib_add_opt readsyms,
+	   int lazy_read)
 {
   struct so_list *gdb;
 
@@ -941,7 +957,7 @@ solib_add (char *pattern, int from_tty,
              need the library symbols to be loaded in order to provide
              thread support (x86-linux for instance).  */
           const int add_this_solib =
-            (readsyms || libpthread_solib_p (gdb));
+            (readsyms == SOLIB_ADD_ON || libpthread_solib_p (gdb));
 
 	  any_matches = 1;
 	  if (add_this_solib)
@@ -965,8 +981,8 @@ solib_add (char *pattern, int from_tty,
     if (from_tty && pattern && ! any_matches)
       printf_unfiltered
 	("No loaded shared libraries match the pattern `%s'.\n", pattern);
-#if 0
-    if (0 && loaded_any_symbols)
+
+    if (loaded_any_symbols && !lazy_read)
       {
 	struct target_so_ops *ops = solib_ops (target_gdbarch);
 
@@ -976,7 +992,6 @@ solib_add (char *pattern, int from_tty,
 
 	ops->special_symbol_handling ();
       }
-#endif
   }
 }
 
@@ -1305,7 +1320,7 @@ static void
 sharedlibrary_command (char *args, int from_tty)
 {
   dont_repeat ();
-  solib_add (args, from_tty, (struct target_ops *) 0, 1);
+  solib_add (args, from_tty, (struct target_ops *) 0, 1, /*lazy_read=*/0);
 }
 
 /* LOCAL FUNCTION
@@ -1386,7 +1401,8 @@ reload_shared_libraries_1 (int from_tty)
 	    exception_fprintf (gdb_stderr, e,
 			       _("Error while mapping "
 				 "shared library sections:\n"));
-	  else if (auto_solib_add || was_loaded || libpthread_solib_p (so))
+	  else if (auto_solib_add == SOLIB_ADD_ON
+		   || was_loaded || libpthread_solib_p (so))
 	    solib_read_symbols (so, flags);
 	}
     }
@@ -1438,7 +1454,7 @@ reload_shared_libraries (char *ignored, int from_tty,
      removed.  Call it only after the solib target has been initialized by
      solib_create_inferior_hook.  */
 
-  solib_add (NULL, 0, NULL, auto_solib_add);
+  solib_add (NULL, 0, NULL, auto_solib_add, /*lazy_read=*/0);
 
   breakpoint_re_set ();
 
@@ -1453,11 +1469,24 @@ reload_shared_libraries (char *ignored, int from_tty,
 }
 
 static void
+set_auto_solib_add (char *ignore_args, int from_tty,
+		    struct cmd_list_element *c)
+{
+  if (strcmp (auto_solib_add_choice, "on") == 0)
+    auto_solib_add = SOLIB_ADD_ON;
+  else if (strcmp (auto_solib_add_choice, "off") == 0)
+    auto_solib_add = SOLIB_ADD_OFF;
+  else if (strcmp (auto_solib_add_choice, "lazy") == 0)
+    auto_solib_add = SOLIB_ADD_LAZY;
+}
+
+static void
 show_auto_solib_add (struct ui_file *file, int from_tty,
 		     struct cmd_list_element *c, const char *value)
 {
-  fprintf_filtered (file, _("Autoloading of shared library symbols is %s.\n"),
-		    value);
+  fprintf_filtered (file,
+		    _("Autoloading of shared library symbols is `%s'.\n"),
+		    auto_solib_add_choice);
 }
 
 
@@ -1491,18 +1520,20 @@ _initialize_solib (void)
   add_com ("nosharedlibrary", class_files, no_shared_libraries,
 	   _("Unload all shared object library symbols."));
 
-  add_setshow_boolean_cmd ("auto-solib-add", class_support,
-			   &auto_solib_add, _("\
+  add_setshow_enum_cmd ("auto-solib-add", class_support,
+			auto_solib_add_options,
+			&auto_solib_add_choice, _("\
 Set autoloading of shared library symbols."), _("\
 Show autoloading of shared library symbols."), _("\
 If \"on\", symbols from all shared object libraries will be loaded\n\
 automatically when the inferior begins execution, when the dynamic linker\n\
 informs gdb that a new library has been loaded, or when attaching to the\n\
-inferior.  Otherwise, symbols must be loaded manually, using \
+inferior.  If \"lazy\", symbols from shared object libraries will be loaded\n\
+only when necessary.  Otherwise, symbols must be loaded manually, using\n\
 `sharedlibrary'."),
-			   NULL,
-			   show_auto_solib_add,
-			   &setlist, &showlist);
+			set_auto_solib_add,
+			show_auto_solib_add,
+			&setlist, &showlist);
 
   add_setshow_filename_cmd ("sysroot", class_support,
 			    &gdb_sysroot, _("\
diff --git a/gdb/solib.h b/gdb/solib.h
index c473d85..93f85df 100644
--- a/gdb/solib.h
+++ b/gdb/solib.h
@@ -26,6 +26,7 @@ struct so_list;
 struct target_ops;
 struct target_so_ops;
 struct program_space;
+enum solib_add_opt;
 
 /* Called when we free all symtabs, to free the shared library information
    as well.  */
@@ -34,7 +35,8 @@ extern void clear_solib (void);
 
 /* Called to add symbols from a shared library to gdb's symbol table.  */
 
-extern void solib_add (char *, int, struct target_ops *, int);
+extern void solib_add (char *, int, struct target_ops *,
+		       enum solib_add_opt, int);
 extern int solib_read_symbols (struct so_list *, int);
 
 /* Function to be called when the inferior starts up, to discover the
diff --git a/gdb/symfile.c b/gdb/symfile.c
index 03352fd..1bbac9b 100644
--- a/gdb/symfile.c
+++ b/gdb/symfile.c
@@ -172,7 +172,7 @@ show_symbol_reloading (struct ui_file *file, int from_tty,
    this value if she wants, and GDB will automatically load shared
    library symbols from the beginning.  */
 
-int auto_solib_add = 0;
+enum solib_add_opt auto_solib_add = SOLIB_ADD_ON;
 \f
 
 /* Make a null terminated copy of the string at PTR with SIZE characters in
diff --git a/gdb/symfile.h b/gdb/symfile.h
index 3544475..9a39263 100644
--- a/gdb/symfile.h
+++ b/gdb/symfile.h
@@ -469,6 +469,18 @@ extern char *obconcat (struct obstack *obstackp, ...) ATTRIBUTE_SENTINEL;
 
 			/*   Variables   */
 
+enum solib_add_opt
+  {
+    /* Disable auto-loading of debuginfo from shared libraries.  */
+    SOLIB_ADD_OFF = 0,
+
+    /* Enable auto-loading of debuginfo from shared libraries.  */
+    SOLIB_ADD_ON,
+
+    /* Lazily (on-demand) read debuginfo from shared libraries.  */
+    SOLIB_ADD_LAZY,
+  };
+
 /* If non-zero, shared library symbols will be added automatically
    when the inferior is created, new libraries are loaded, or when
    attaching to the inferior.  This is almost always what users will
@@ -479,7 +491,8 @@ extern char *obconcat (struct obstack *obstackp, ...) ATTRIBUTE_SENTINEL;
    library symbols are not loaded, commands like "info fun" will *not*
    report all the functions that are actually present.  */
 
-extern int auto_solib_add;
+extern enum solib_add_opt auto_solib_add;
+//extern int auto_solib_add;
 
 /* From symfile.c */
 
diff --git a/gdb/windows-nat.c b/gdb/windows-nat.c
index 8096f95..4a65df6 100644
--- a/gdb/windows-nat.c
+++ b/gdb/windows-nat.c
@@ -862,7 +862,7 @@ handle_unload_dll (void *dummy)
 	DEBUG_EVENTS (("gdb: Unloading dll \"%s\".\n", sodel->so_name));
 
 	windows_free_so (sodel);
-	solib_add (NULL, 0, NULL, auto_solib_add);
+	solib_add (NULL, 0, NULL, auto_solib_add, /*lazy_read=*/0);
 	return 1;
       }
 


hooks/post-receive
--
Repository for Project Archer.


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2011-06-15  6:51 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-06-15  6:51 [SCM] archer-sergiodj-lazier-debuginfo-reading: Add set-show command for tri-state auto-solib-add option sergiodj

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).