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]

Re: [rfa] Rename "set solib-absolute-prefix" to "set sysroot", improve docs


On Sat, Jan 06, 2007 at 12:32:02PM +0200, Eli Zaretskii wrote:
> > So just delete the first clause, and use this for the intro sentence?
> > 
> >   Use @var{path} as the system root for the program being debugged.
> 
> Yes.

Thanks for reviewing this.  Here's the version I've checked in.

> Either that, or strip the drive letter from the original file name and
> append the rest to the value of sysroot.

Either sounds sensible to me as long as we document our choice, if/when
there is a need for this functionality for Windows paths.  I'll
revisit if it comes up.

-- 
Daniel Jacobowitz
CodeSourcery

2007-01-08  Daniel Jacobowitz  <dan@codesourcery.com>

	* NEWS: Add "set sysroot" and "show sysroot".
	* solib.c (solib_absolute_prefix): Delete.  Replace
	all uses with gdb_sysroot.
	(_initialize_solib): Add "set sysroot" and "show sysroot".
	Make "solib-absolute-prefix" an alias to it.

2007-01-08  Daniel Jacobowitz  <dan@codesourcery.com>

	* gdb.texinfo (Commands to specify files): Describe
	"set sysroot" and "show sysroot".
	(Using the `gdbserver' program): Lowercase argument
	to @var.  Expand description of setting up GDB on the
	host.

Index: NEWS
===================================================================
RCS file: /cvs/src/src/gdb/NEWS,v
retrieving revision 1.207
diff -u -p -r1.207 NEWS
--- NEWS	3 Jan 2007 18:05:43 -0000	1.207
+++ NEWS	5 Jan 2007 19:21:06 -0000
@@ -30,6 +30,12 @@ show breakpoint auto-hw
   "break" command and internal breakpoints used for other commands
   including "next" and "finish".
 
+set sysroot
+show sysroot
+  Set an alternate system root for target files.  This is a more
+  general version of "set solib-absolute-prefix", which is now
+  an alias to "set sysroot".
+
 * New native configurations
 
 OpenBSD/sh			sh*-*openbsd*
Index: solib.c
===================================================================
RCS file: /cvs/src/src/gdb/solib.c,v
retrieving revision 1.88
diff -u -p -r1.88 solib.c
--- solib.c	29 Nov 2006 12:27:01 -0000	1.88
+++ solib.c	5 Jan 2007 19:21:07 -0000
@@ -85,10 +85,6 @@ static int solib_cleanup_queued = 0;	/* 
 
 static void do_clear_solib (void *);
 
-/* If non-zero, this is a prefix that will be added to the front of the name
-   shared libraries with an absolute filename for loading.  */
-static char *solib_absolute_prefix = NULL;
-
 /* If non-empty, this is a search path for loading non-absolute shared library
    symbol files.  This takes precedence over the environment variables PATH
    and LD_LIBRARY_PATH.  */
@@ -114,26 +110,26 @@ The search path for loading non-absolute
 
    DESCRIPTION
 
-   Global variable SOLIB_ABSOLUTE_PREFIX is used as a prefix directory
+   Global variable GDB_SYSROOT is used as a prefix directory
    to search for shared libraries if they have an absolute path.
 
    Global variable SOLIB_SEARCH_PATH is used as a prefix directory
    (or set of directories, as in LD_LIBRARY_PATH) to search for all
-   shared libraries if not found in SOLIB_ABSOLUTE_PREFIX.
+   shared libraries if not found in GDB_SYSROOT.
 
    Search algorithm:
-   * If there is a solib_absolute_prefix and path is absolute:
-   *   Search for solib_absolute_prefix/path.
+   * If there is a gdb_sysroot and path is absolute:
+   *   Search for gdb_sysroot/path.
    * else
    *   Look for it literally (unmodified).
    * Look in SOLIB_SEARCH_PATH.
    * If available, use target defined search function.
-   * If solib_absolute_prefix is NOT set, perform the following two searches:
+   * If gdb_sysroot is NOT set, perform the following two searches:
    *   Look in inferior's $PATH.
    *   Look in inferior's $LD_LIBRARY_PATH.
    *   
    * The last check avoids doing this search when targetting remote
-   * machines since solib_absolute_prefix will almost always be set.
+   * machines since gdb_sysroot will almost always be set.
 
    RETURNS
 
@@ -146,25 +142,24 @@ solib_open (char *in_pathname, char **fo
   int found_file = -1;
   char *temp_pathname = NULL;
   char *p = in_pathname;
-  int solib_absolute_prefix_is_empty;
+  int gdb_sysroot_is_empty;
 
-  solib_absolute_prefix_is_empty = (solib_absolute_prefix == NULL
-                                    || *solib_absolute_prefix == 0);
+  gdb_sysroot_is_empty = (gdb_sysroot == NULL || *gdb_sysroot == 0);
 
-  if (! IS_ABSOLUTE_PATH (in_pathname) || solib_absolute_prefix_is_empty)
+  if (! IS_ABSOLUTE_PATH (in_pathname) || gdb_sysroot_is_empty)
     temp_pathname = in_pathname;
   else
     {
-      int prefix_len = strlen (solib_absolute_prefix);
+      int prefix_len = strlen (gdb_sysroot);
 
       /* Remove trailing slashes from absolute prefix.  */
       while (prefix_len > 0
-	     && IS_DIR_SEPARATOR (solib_absolute_prefix[prefix_len - 1]))
+	     && IS_DIR_SEPARATOR (gdb_sysroot[prefix_len - 1]))
 	prefix_len--;
 
       /* Cat the prefixed pathname together.  */
       temp_pathname = alloca (prefix_len + strlen (in_pathname) + 1);
-      strncpy (temp_pathname, solib_absolute_prefix, prefix_len);
+      strncpy (temp_pathname, gdb_sysroot, prefix_len);
       temp_pathname[prefix_len] = '\0';
       strcat (temp_pathname, in_pathname);
     }
@@ -172,7 +167,7 @@ solib_open (char *in_pathname, char **fo
   /* Now see if we can open it.  */
   found_file = open (temp_pathname, O_RDONLY | O_BINARY, 0);
 
-  /* If the search in solib_absolute_prefix failed, and the path name is
+  /* If the search in gdb_sysroot failed, and the path name is
      absolute at this point, make it relative.  (openp will try and open the
      file according to its absolute path otherwise, which is not what we want.)
      Affects subsequent searches for this solib.  */
@@ -206,14 +201,14 @@ solib_open (char *in_pathname, char **fo
 					   &temp_pathname);
 
   /* If not found, next search the inferior's $PATH environment variable. */
-  if (found_file < 0 && solib_absolute_prefix_is_empty)
+  if (found_file < 0 && gdb_sysroot_is_empty)
     found_file = openp (get_in_environ (inferior_environ, "PATH"),
 			OPF_TRY_CWD_FIRST, in_pathname, O_RDONLY | O_BINARY, 0,
 			&temp_pathname);
 
   /* If not found, next search the inferior's $LD_LIBRARY_PATH 
      environment variable. */
-  if (found_file < 0 && solib_absolute_prefix_is_empty)
+  if (found_file < 0 && gdb_sysroot_is_empty)
     found_file = openp (get_in_environ (inferior_environ, "LD_LIBRARY_PATH"),
 			OPF_TRY_CWD_FIRST, in_pathname, O_RDONLY | O_BINARY, 0,
 			&temp_pathname);
@@ -979,18 +974,21 @@ inferior.  Otherwise, symbols must be lo
 			   show_auto_solib_add,
 			   &setlist, &showlist);
 
-  add_setshow_filename_cmd ("solib-absolute-prefix", class_support,
-			    &solib_absolute_prefix, _("\
-Set prefix for loading absolute shared library symbol files."), _("\
-Show prefix for loading absolute shared library symbol files."), _("\
-For other (relative) files, you can add values using `set solib-search-path'."),
+  add_setshow_filename_cmd ("sysroot", class_support,
+			    &gdb_sysroot, _("\
+Set an alternate system root."), _("\
+Show the current system root."), _("\
+The system root is used to load absolute shared library symbol files.\n\
+For other (relative) files, you can add directories using\n\
+`set solib-search-path'."),
 			    reload_shared_libraries,
 			    NULL,
 			    &setlist, &showlist);
 
-  /* Set the default value of "solib-absolute-prefix" from the sysroot, if
-     one is set.  */
-  solib_absolute_prefix = xstrdup (gdb_sysroot);
+  add_alias_cmd ("solib-absolute-prefix", "sysroot", class_support, 0,
+		 &setlist);
+  add_alias_cmd ("solib-absolute-prefix", "sysroot", class_support, 0,
+		 &showlist);
 
   add_setshow_optional_filename_cmd ("solib-search-path", class_support,
 				     &solib_search_path, _("\
Index: doc/gdb.texinfo
===================================================================
RCS file: /cvs/src/src/gdb/doc/gdb.texinfo,v
retrieving revision 1.374
diff -u -p -r1.374 gdb.texinfo
--- doc/gdb.texinfo	4 Jan 2007 22:11:44 -0000	1.374
+++ doc/gdb.texinfo	5 Jan 2007 19:21:11 -0000
@@ -11828,33 +11828,45 @@ to specify the search directories for ta
 
 @table @code
 @cindex prefix for shared library file names
+@cindex system root, alternate
 @kindex set solib-absolute-prefix
-@item set solib-absolute-prefix @var{path}
-If this variable is set, @var{path} will be used as a prefix for any
-absolute shared library paths; many runtime loaders store the absolute
-paths to the shared library in the target program's memory.  If you use
-@samp{solib-absolute-prefix} to find shared libraries, they need to be laid
-out in the same way that they are on the target, with e.g.@: a
-@file{/usr/lib} hierarchy under @var{path}.
+@kindex set sysroot
+@item set sysroot @var{path}
+Use @var{path} as the system root for the program being debugged.  Any
+absolute shared library paths will be prefixed with @var{path}; many
+runtime loaders store the absolute paths to the shared library in the
+target program's memory.  If you use @code{set sysroot} to find shared
+libraries, they need to be laid out in the same way that they are on
+the target, with e.g.@: a @file{/lib} and @file{/usr/lib} hierarchy
+under @var{path}.
 
-@cindex default value of @samp{solib-absolute-prefix}
+The @code{set solib-absolute-prefix} command is an alias for @code{set
+sysroot}.
+
+@cindex default system root
 @cindex @samp{--with-sysroot}
-You can set the default value of @samp{solib-absolute-prefix} by using the
-configure-time @samp{--with-sysroot} option.
+You can set the default system root by using the configure-time
+@samp{--with-sysroot} option.  If the system root is inside
+@value{GDBN}'s configured binary prefix (set with @samp{--prefix} or
+@samp{--exec-prefix}), then the default system root will be updated
+automatically if the installed @value{GDBN} is moved to a new
+location.
 
-@kindex show solib-absolute-prefix
-@item show solib-absolute-prefix
+@kindex show sysroot
+@item show sysroot
 Display the current shared library prefix.
 
 @kindex set solib-search-path
 @item set solib-search-path @var{path}
-If this variable is set, @var{path} is a colon-separated list of directories
-to search for shared libraries.  @samp{solib-search-path} is used after
-@samp{solib-absolute-prefix} fails to locate the library, or if the path to
-the library is relative instead of absolute.  If you want to use
-@samp{solib-search-path} instead of @samp{solib-absolute-prefix}, be sure to
-set @samp{solib-absolute-prefix} to a nonexistant directory to prevent
-@value{GDBN} from finding your host's libraries.
+If this variable is set, @var{path} is a colon-separated list of
+directories to search for shared libraries.  @samp{solib-search-path}
+is used after @samp{sysroot} fails to locate the library, or if the
+path to the library is relative instead of absolute.  If you want to
+use @samp{solib-search-path} instead of @samp{sysroot}, be sure to set
+@samp{sysroot} to a nonexistant directory to prevent @value{GDBN} from
+finding your host's libraries.  @samp{sysroot} is preferred; setting
+it to a nonexistant directory may interfere with automatic loading
+of shared library symbols.
 
 @kindex show solib-search-path
 @item show solib-search-path
@@ -12695,25 +12707,34 @@ You can debug processes by name instead 
 @code{pidof} utility:
 
 @smallexample
-target> gdbserver @var{comm} --attach `pidof @var{PROGRAM}`
+target> gdbserver @var{comm} --attach `pidof @var{program}`
 @end smallexample
 
-In case more than one copy of @var{PROGRAM} is running, or @var{PROGRAM}
+In case more than one copy of @var{program} is running, or @var{program}
 has multiple threads, most versions of @code{pidof} support the
 @code{-s} option to only return the first process ID.
 
 @item On the host machine,
-connect to your target (@pxref{Connecting,,Connecting to a remote target}).
+first make sure you have the necessary symbol files.  Load symbols for
+your application using the @code{file} command before you connect.  Use
+@code{set sysroot} to locate target libraries (unless your @value{GDBN}
+was compiled with the correct sysroot using @code{--with-system-root}).
+
+The symbol file and target libraries must exactly match the executable
+and libraries on the target, with one exception: the files on the host
+system should not be stripped, even if the files on the target system
+are.  Mismatched or missing files will lead to confusing results
+during debugging.  On @sc{gnu}/Linux targets, mismatched or missing
+files may also prevent @code{gdbserver} from debugging multi-threaded
+programs.
+
+Connect to your target (@pxref{Connecting,,Connecting to a remote target}).
 For TCP connections, you must start up @code{gdbserver} prior to using
 the @code{target remote} command.  Otherwise you may get an error whose
 text depends on the host system, but which usually looks something like
 @samp{Connection refused}.  You don't need to use the @code{load}
 command in @value{GDBN} when using @code{gdbserver}, since the program is
-already on the target.  However, if you want to load the symbols (as
-you normally would), do that with the @code{file} command, and issue
-it @emph{before} connecting to the server; otherwise, you will get an
-error message saying @code{"Program is already running"}, since the
-program is considered running after the connection.
+already on the target.
 
 @end table
 


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