+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 Ulrich Weigand <uweigand@de.ibm.com>
* frame.c (get_frame_register_bytes): New function.
catch assert
Stop the program execution when an Ada assertion failed.
+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*
+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.
+
2007-01-05 Joel Brobecker <brobecker@adacore.com>
* gdb.texinfo (Set Catchpoints): Add documentation for the new
@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}.
-
-@cindex default value of @samp{solib-absolute-prefix}
+@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}.
+
+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.
-
-@kindex show solib-absolute-prefix
-@item show solib-absolute-prefix
+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 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
@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
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. */
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
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);
}
/* 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. */
&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);
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, _("\