* PATCH: --with-sysroot for GDB
@ 2003-01-09 17:37 Daniel Jacobowitz
2003-01-09 18:37 ` Kevin Buettner
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Daniel Jacobowitz @ 2003-01-09 17:37 UTC (permalink / raw)
To: gdb-patches, Dan Kegel
[Copied to Dan K. 'cause I know he'll like it :)]
Both binutils and GCC now support (although GCC's support isn't quite
finished yet, working on it...) a mechanism called "sysroot" for
handling cross environments. The basic principal is that anything that
would normally access the "target" filesystem does so just as if it
were a native debugger running on $target, but prefixes all paths with
the value of the sysroot prefix. We use $target/usr/include,
$target/etc/ld.so.conf, $target/lib, et cetera. This is really great
for people using, for instance, gdbserver to debug a remote GNU/Linux
installation. I bet the QNX people could use this, too.
Free bonus: as long as the sysroot is actually within $exec_prefix
(otherwise the relocation functions don't work right), it will move
along with the binary. You can pick up the whole tree, drop it
somewhere else, and keep using it; no rebuild, no reconfigure.
Here's a patch to do the same thing in GDB. Right now all it sets is
solib-absolute-prefix; that's because I can't think of anything else it
should affect, but if you have any ideas speak right up.
It also documents solib-absolute-prefix and solib-search-path, which
have been conspicuously missing from the manual for some time.
Thoughts? I'll look to apply this in a couple of days if no one
objects to the way I implemented it.
--
Daniel Jacobowitz
MontaVista Software Debian GNU/Linux Developer
2003-01-09 Daniel Jacobowitz <drow@mvista.com>
* Makefile.in (TARGET_SYSTEM_ROOT, TARGET_SYSTEM_ROOT_DEFINE): New
variables.
(main.o): Custom rule which uses $(TARGET_SYSTEM_ROOT_DEFINE).
* configure.in: Add --with-sysroot.
* main.c (gdb_sysroot): New variable.
(captured_main): Initialize gdb_sysroot.
* defs.h (gdb_sysroot): New extern declaration.
2003-01-09 Daniel Jacobowitz <drow@mvista.com>
* gdb.texinfo (Files): Document solib-absolute-prefix and
solib-search-path.
Index: Makefile.in
===================================================================
RCS file: /cvs/src/src/gdb/Makefile.in,v
retrieving revision 1.310
diff -u -p -r1.310 Makefile.in
--- Makefile.in 6 Jan 2003 20:45:30 -0000 1.310
+++ Makefile.in 9 Jan 2003 17:29:16 -0000
@@ -136,6 +136,10 @@ INTL_CFLAGS = -I$(INTL_DIR) -I$(INTL_SRC
# Where is the ICONV library? This can be empty if libc has iconv.
LIBICONV = @LIBICONV@
+# Did the user give us a --with-sysroot option?
+TARGET_SYSTEM_ROOT = @TARGET_SYSTEM_ROOT@
+TARGET_SYSTEM_ROOT_DEFINE = @TARGET_SYSTEM_ROOT_DEFINE@
+
#
# CLI sub directory definitons
#
@@ -1402,6 +1406,11 @@ hpux-thread.o: $(srcdir)/hpux-thread.c
$(CC) -c $(INTERNAL_CFLAGS) -I$(srcdir)/osf-share \
-I$(srcdir)/osf-share/HP800 -I/usr/include/dce \
$(srcdir)/hpux-thread.c
+
+# main.o needs an explicit build rule to get TARGET_SYSTEM_ROOT and BINDIR.
+main.o: main.c
+ $(CC) -c $(INTERNAL_CFLAGS) $(TARGET_SYSTEM_ROOT_DEFINE) \
+ -DBINDIR=\"$(bindir)\" $(srcdir)/main.c
# FIXME: Procfs.o gets -Wformat errors because things like pid_t don't
# match output format strings.
Index: configure.in
===================================================================
RCS file: /cvs/src/src/gdb/configure.in,v
retrieving revision 1.116
diff -u -p -r1.116 configure.in
--- configure.in 4 Jan 2003 23:47:12 -0000 1.116
+++ configure.in 9 Jan 2003 17:29:18 -0000
@@ -851,6 +851,38 @@ fi
dnl Handle optional features that can be enabled.
+AC_ARG_WITH(sysroot,
+[ --with-sysroot[=DIR] Search for usr/lib et al within DIR.],
+[
+ case ${with_sysroot} in
+ yes) AC_ERROR(with-sysroot must specify path) ;;
+ *) TARGET_SYSTEM_ROOT=$with_sysroot ;;
+ esac
+
+ TARGET_SYSTEM_ROOT_DEFINE='-DTARGET_SYSTEM_ROOT=\"$(TARGET_SYSTEM_ROOT)\"'
+
+ if test "x$exec_prefix" = xNONE; then
+ if test "x$prefix" = xNONE; then
+ test_prefix=/usr/local
+ else
+ test_prefix=$prefix
+ fi
+ else
+ test_prefix=$exec_prefix
+ fi
+ case ${TARGET_SYSTEM_ROOT} in
+ ${test_prefix}*)
+ t="$TARGET_SYSTEM_ROOT_DEFINE -DTARGET_SYSTEM_ROOT_RELOCATABLE"
+ TARGET_SYSTEM_ROOT_DEFINE="$t"
+ ;;
+ esac
+], [
+ TARGET_SYSTEM_ROOT=
+ TARGET_SYSTEM_ROOT_DEFINE='-DTARGET_SYSTEM_ROOT=\"\"'
+])
+AC_SUBST(TARGET_SYSTEM_ROOT)
+AC_SUBST(TARGET_SYSTEM_ROOT_DEFINE)
+
# NOTE: Don't add -Wall or -Wunused, they both include
# -Wunused-parameter which reports bogus warnings.
# NOTE: If you add to this list, remember to update
Index: defs.h
===================================================================
RCS file: /cvs/src/src/gdb/defs.h,v
retrieving revision 1.107
diff -u -p -r1.107 defs.h
--- defs.h 6 Jan 2003 18:49:08 -0000 1.107
+++ defs.h 9 Jan 2003 17:29:18 -0000
@@ -169,6 +169,9 @@ extern int xdb_commands;
/* enable dbx commands if set */
extern int dbx_commands;
+/* System root path, used to find libraries etc. */
+extern char *gdb_sysroot;
+
extern int quit_flag;
extern int immediate_quit;
extern int sevenbit_strings;
Index: main.c
===================================================================
RCS file: /cvs/src/src/gdb/main.c,v
retrieving revision 1.20
diff -u -p -r1.20 main.c
--- main.c 26 Sep 2002 17:46:04 -0000 1.20
+++ main.c 9 Jan 2003 17:29:18 -0000
@@ -65,6 +65,9 @@ int xdb_commands = 0;
/* Whether dbx commands will be handled */
int dbx_commands = 0;
+/* System root path, used to find libraries etc. */
+char *gdb_sysroot = 0;
+
struct ui_file *gdb_stdout;
struct ui_file *gdb_stderr;
struct ui_file *gdb_stdlog;
@@ -200,6 +203,29 @@ captured_main (void *data)
/* initialize error() */
error_init ();
+
+ /* Set the sysroot path. */
+#ifdef TARGET_SYSTEM_ROOT_RELOCATABLE
+ gdb_sysroot = make_relative_prefix (argv[0], BINDIR, TARGET_SYSTEM_ROOT);
+ if (gdb_sysroot)
+ {
+ struct stat s;
+ int res = stat (gdb_sysroot, &s) == 0 && S_ISDIR (s.st_mode);
+ if (!res)
+ {
+ free (gdb_sysroot);
+ gdb_sysroot = TARGET_SYSTEM_ROOT;
+ }
+ }
+ else
+ gdb_sysroot = TARGET_SYSTEM_ROOT;
+#else
+#if defined (TARGET_SYSTEM_ROOT)
+ gdb_sysroot = TARGET_SYSTEM_ROOT;
+#else
+ gdb_sysroot = "";
+#endif
+#endif
/* Parse arguments and options. */
{
Index: solib.c
===================================================================
RCS file: /cvs/src/src/gdb/solib.c,v
retrieving revision 1.51
diff -u -p -r1.51 solib.c
--- solib.c 9 Dec 2002 00:59:26 -0000 1.51
+++ solib.c 9 Jan 2003 17:29:19 -0000
@@ -875,6 +875,10 @@ For other (relative) files, you can add
add_show_from_set (c, &showlist);
set_cmd_completer (c, filename_completer);
+ /* Set the default value of "solib-absolute-prefix" from the sysroot, if
+ one is set. */
+ solib_absolute_prefix = xstrdup (gdb_sysroot);
+
c = add_set_cmd ("solib-search-path", class_support, var_string,
(char *) &solib_search_path,
"Set the search path for loading non-absolute shared library symbol files.\n\
Index: doc/gdb.texinfo
===================================================================
RCS file: /cvs/src/src/gdb/doc/gdb.texinfo,v
retrieving revision 1.136
diff -u -p -r1.136 gdb.texinfo
--- doc/gdb.texinfo 5 Jan 2003 04:34:39 -0000 1.136
+++ doc/gdb.texinfo 9 Jan 2003 17:29:23 -0000
@@ -9719,6 +9719,49 @@ Mb).
Display the current autoloading size threshold, in megabytes.
@end table
+Shared libraries are also supported in many cross or remote debugging
+configurations. A copy of the target's libraries need to be present on the
+host system; they need to be the same as the target libraries, although the
+copies on the target can be stripped as long as the copies on the host are
+not.
+
+You need to tell @value{GDBN} where the target libraries are, so that it can
+load the correct copies---otherwise, it may try to load the host's libraries.
+@value{GDBN} has two variables to specify the search directories for target
+libraries.
+
+@table @code
+@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}.
+
+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
+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.
+
+@kindex show solib-search-path
+@item show solib-search-path
+Display the current shared library search path.
+@end table
+
@node Symbol Errors
@section Errors reading symbol files
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: PATCH: --with-sysroot for GDB
2003-01-09 17:37 PATCH: --with-sysroot for GDB Daniel Jacobowitz
@ 2003-01-09 18:37 ` Kevin Buettner
2003-01-09 19:02 ` Daniel Jacobowitz
2003-01-09 19:16 ` Elena Zannoni
2003-01-13 17:59 ` Daniel Jacobowitz
2 siblings, 1 reply; 5+ messages in thread
From: Kevin Buettner @ 2003-01-09 18:37 UTC (permalink / raw)
To: Daniel Jacobowitz, gdb-patches; +Cc: Dan Kegel
On Jan 9, 12:38pm, Daniel Jacobowitz wrote:
> Thoughts? I'll look to apply this in a couple of days if no one
> objects to the way I implemented it.
>
>
> 2003-01-09 Daniel Jacobowitz <drow@mvista.com>
>
> * Makefile.in (TARGET_SYSTEM_ROOT, TARGET_SYSTEM_ROOT_DEFINE): New
> variables.
> (main.o): Custom rule which uses $(TARGET_SYSTEM_ROOT_DEFINE).
> * configure.in: Add --with-sysroot.
> * main.c (gdb_sysroot): New variable.
> (captured_main): Initialize gdb_sysroot.
> * defs.h (gdb_sysroot): New extern declaration.
You missed a ChangeLog entry for solib.c, but I've looked over that part
of the patch and it looks good. (But do write a ChangeLog entry for it.)
Anyway, thanks -- something like this has been needed for a long time now.
Kevin
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: PATCH: --with-sysroot for GDB
2003-01-09 18:37 ` Kevin Buettner
@ 2003-01-09 19:02 ` Daniel Jacobowitz
0 siblings, 0 replies; 5+ messages in thread
From: Daniel Jacobowitz @ 2003-01-09 19:02 UTC (permalink / raw)
To: gdb-patches
On Thu, Jan 09, 2003 at 11:37:00AM -0700, Kevin Buettner wrote:
> On Jan 9, 12:38pm, Daniel Jacobowitz wrote:
>
> > Thoughts? I'll look to apply this in a couple of days if no one
> > objects to the way I implemented it.
> >
> >
> > 2003-01-09 Daniel Jacobowitz <drow@mvista.com>
> >
> > * Makefile.in (TARGET_SYSTEM_ROOT, TARGET_SYSTEM_ROOT_DEFINE): New
> > variables.
> > (main.o): Custom rule which uses $(TARGET_SYSTEM_ROOT_DEFINE).
> > * configure.in: Add --with-sysroot.
> > * main.c (gdb_sysroot): New variable.
> > (captured_main): Initialize gdb_sysroot.
> > * defs.h (gdb_sysroot): New extern declaration.
>
> You missed a ChangeLog entry for solib.c, but I've looked over that part
> of the patch and it looks good. (But do write a ChangeLog entry for it.)
Oops, thanks for spotting that! Will fix before I check it in.
--
Daniel Jacobowitz
MontaVista Software Debian GNU/Linux Developer
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: PATCH: --with-sysroot for GDB
2003-01-09 17:37 PATCH: --with-sysroot for GDB Daniel Jacobowitz
2003-01-09 18:37 ` Kevin Buettner
@ 2003-01-09 19:16 ` Elena Zannoni
2003-01-13 17:59 ` Daniel Jacobowitz
2 siblings, 0 replies; 5+ messages in thread
From: Elena Zannoni @ 2003-01-09 19:16 UTC (permalink / raw)
To: Daniel Jacobowitz; +Cc: gdb-patches, Dan Kegel
Daniel Jacobowitz writes:
> [Copied to Dan K. 'cause I know he'll like it :)]
>
> Both binutils and GCC now support (although GCC's support isn't quite
> finished yet, working on it...) a mechanism called "sysroot" for
> handling cross environments. The basic principal is that anything that
> would normally access the "target" filesystem does so just as if it
> were a native debugger running on $target, but prefixes all paths with
> the value of the sysroot prefix. We use $target/usr/include,
> $target/etc/ld.so.conf, $target/lib, et cetera. This is really great
> for people using, for instance, gdbserver to debug a remote GNU/Linux
> installation. I bet the QNX people could use this, too.
>
> Free bonus: as long as the sysroot is actually within $exec_prefix
> (otherwise the relocation functions don't work right), it will move
> along with the binary. You can pick up the whole tree, drop it
> somewhere else, and keep using it; no rebuild, no reconfigure.
>
> Here's a patch to do the same thing in GDB. Right now all it sets is
> solib-absolute-prefix; that's because I can't think of anything else it
> should affect, but if you have any ideas speak right up.
>
> It also documents solib-absolute-prefix and solib-search-path, which
> have been conspicuously missing from the manual for some time.
>
> Thoughts? I'll look to apply this in a couple of days if no one
> objects to the way I implemented it.
main.c ok, except for.... see below:
>
> --
> Daniel Jacobowitz
> MontaVista Software Debian GNU/Linux Developer
>
> 2003-01-09 Daniel Jacobowitz <drow@mvista.com>
>
> * Makefile.in (TARGET_SYSTEM_ROOT, TARGET_SYSTEM_ROOT_DEFINE): New
> variables.
> (main.o): Custom rule which uses $(TARGET_SYSTEM_ROOT_DEFINE).
> * configure.in: Add --with-sysroot.
> * main.c (gdb_sysroot): New variable.
> (captured_main): Initialize gdb_sysroot.
> * defs.h (gdb_sysroot): New extern declaration.
>
> 2003-01-09 Daniel Jacobowitz <drow@mvista.com>
>
> * gdb.texinfo (Files): Document solib-absolute-prefix and
> solib-search-path.
>
> Index: Makefile.in
> ===================================================================
> RCS file: /cvs/src/src/gdb/Makefile.in,v
> retrieving revision 1.310
> diff -u -p -r1.310 Makefile.in
> --- Makefile.in 6 Jan 2003 20:45:30 -0000 1.310
> +++ Makefile.in 9 Jan 2003 17:29:16 -0000
> @@ -136,6 +136,10 @@ INTL_CFLAGS = -I$(INTL_DIR) -I$(INTL_SRC
> # Where is the ICONV library? This can be empty if libc has iconv.
> LIBICONV = @LIBICONV@
>
> +# Did the user give us a --with-sysroot option?
> +TARGET_SYSTEM_ROOT = @TARGET_SYSTEM_ROOT@
> +TARGET_SYSTEM_ROOT_DEFINE = @TARGET_SYSTEM_ROOT_DEFINE@
> +
> #
> # CLI sub directory definitons
> #
> @@ -1402,6 +1406,11 @@ hpux-thread.o: $(srcdir)/hpux-thread.c
> $(CC) -c $(INTERNAL_CFLAGS) -I$(srcdir)/osf-share \
> -I$(srcdir)/osf-share/HP800 -I/usr/include/dce \
> $(srcdir)/hpux-thread.c
> +
> +# main.o needs an explicit build rule to get TARGET_SYSTEM_ROOT and BINDIR.
> +main.o: main.c
> + $(CC) -c $(INTERNAL_CFLAGS) $(TARGET_SYSTEM_ROOT_DEFINE) \
> + -DBINDIR=\"$(bindir)\" $(srcdir)/main.c
>
> # FIXME: Procfs.o gets -Wformat errors because things like pid_t don't
> # match output format strings.
> Index: configure.in
> ===================================================================
> RCS file: /cvs/src/src/gdb/configure.in,v
> retrieving revision 1.116
> diff -u -p -r1.116 configure.in
> --- configure.in 4 Jan 2003 23:47:12 -0000 1.116
> +++ configure.in 9 Jan 2003 17:29:18 -0000
> @@ -851,6 +851,38 @@ fi
>
> dnl Handle optional features that can be enabled.
>
> +AC_ARG_WITH(sysroot,
> +[ --with-sysroot[=DIR] Search for usr/lib et al within DIR.],
> +[
> + case ${with_sysroot} in
> + yes) AC_ERROR(with-sysroot must specify path) ;;
> + *) TARGET_SYSTEM_ROOT=$with_sysroot ;;
> + esac
> +
> + TARGET_SYSTEM_ROOT_DEFINE='-DTARGET_SYSTEM_ROOT=\"$(TARGET_SYSTEM_ROOT)\"'
> +
> + if test "x$exec_prefix" = xNONE; then
> + if test "x$prefix" = xNONE; then
> + test_prefix=/usr/local
> + else
> + test_prefix=$prefix
> + fi
> + else
> + test_prefix=$exec_prefix
> + fi
> + case ${TARGET_SYSTEM_ROOT} in
> + ${test_prefix}*)
> + t="$TARGET_SYSTEM_ROOT_DEFINE -DTARGET_SYSTEM_ROOT_RELOCATABLE"
> + TARGET_SYSTEM_ROOT_DEFINE="$t"
> + ;;
> + esac
> +], [
> + TARGET_SYSTEM_ROOT=
> + TARGET_SYSTEM_ROOT_DEFINE='-DTARGET_SYSTEM_ROOT=\"\"'
> +])
> +AC_SUBST(TARGET_SYSTEM_ROOT)
> +AC_SUBST(TARGET_SYSTEM_ROOT_DEFINE)
> +
> # NOTE: Don't add -Wall or -Wunused, they both include
> # -Wunused-parameter which reports bogus warnings.
> # NOTE: If you add to this list, remember to update
> Index: defs.h
> ===================================================================
> RCS file: /cvs/src/src/gdb/defs.h,v
> retrieving revision 1.107
> diff -u -p -r1.107 defs.h
> --- defs.h 6 Jan 2003 18:49:08 -0000 1.107
> +++ defs.h 9 Jan 2003 17:29:18 -0000
> @@ -169,6 +169,9 @@ extern int xdb_commands;
> /* enable dbx commands if set */
> extern int dbx_commands;
>
> +/* System root path, used to find libraries etc. */
> +extern char *gdb_sysroot;
> +
> extern int quit_flag;
> extern int immediate_quit;
> extern int sevenbit_strings;
> Index: main.c
> ===================================================================
> RCS file: /cvs/src/src/gdb/main.c,v
> retrieving revision 1.20
> diff -u -p -r1.20 main.c
> --- main.c 26 Sep 2002 17:46:04 -0000 1.20
> +++ main.c 9 Jan 2003 17:29:18 -0000
> @@ -65,6 +65,9 @@ int xdb_commands = 0;
> /* Whether dbx commands will be handled */
> int dbx_commands = 0;
>
> +/* System root path, used to find libraries etc. */
> +char *gdb_sysroot = 0;
> +
> struct ui_file *gdb_stdout;
> struct ui_file *gdb_stderr;
> struct ui_file *gdb_stdlog;
> @@ -200,6 +203,29 @@ captured_main (void *data)
>
> /* initialize error() */
> error_init ();
> +
> + /* Set the sysroot path. */
> +#ifdef TARGET_SYSTEM_ROOT_RELOCATABLE
> + gdb_sysroot = make_relative_prefix (argv[0], BINDIR, TARGET_SYSTEM_ROOT);
> + if (gdb_sysroot)
> + {
> + struct stat s;
> + int res = stat (gdb_sysroot, &s) == 0 && S_ISDIR (s.st_mode);
please split this statement into an if + assignment.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: PATCH: --with-sysroot for GDB
2003-01-09 17:37 PATCH: --with-sysroot for GDB Daniel Jacobowitz
2003-01-09 18:37 ` Kevin Buettner
2003-01-09 19:16 ` Elena Zannoni
@ 2003-01-13 17:59 ` Daniel Jacobowitz
2 siblings, 0 replies; 5+ messages in thread
From: Daniel Jacobowitz @ 2003-01-13 17:59 UTC (permalink / raw)
To: gdb-patches
On Thu, Jan 09, 2003 at 12:38:10PM -0500, Daniel Jacobowitz wrote:
> [Copied to Dan K. 'cause I know he'll like it :)]
>
> Both binutils and GCC now support (although GCC's support isn't quite
> finished yet, working on it...) a mechanism called "sysroot" for
> handling cross environments. The basic principal is that anything that
> would normally access the "target" filesystem does so just as if it
> were a native debugger running on $target, but prefixes all paths with
> the value of the sysroot prefix. We use $target/usr/include,
> $target/etc/ld.so.conf, $target/lib, et cetera. This is really great
> for people using, for instance, gdbserver to debug a remote GNU/Linux
> installation. I bet the QNX people could use this, too.
>
> Free bonus: as long as the sysroot is actually within $exec_prefix
> (otherwise the relocation functions don't work right), it will move
> along with the binary. You can pick up the whole tree, drop it
> somewhere else, and keep using it; no rebuild, no reconfigure.
>
> Here's a patch to do the same thing in GDB. Right now all it sets is
> solib-absolute-prefix; that's because I can't think of anything else it
> should affect, but if you have any ideas speak right up.
>
> It also documents solib-absolute-prefix and solib-search-path, which
> have been conspicuously missing from the manual for some time.
>
> Thoughts? I'll look to apply this in a couple of days if no one
> objects to the way I implemented it.
Thanks to Kevin and Elena for their feedback. Here's what I committed;
I was also missing a ChangeLog entry for regenerating configure.
--
Daniel Jacobowitz
MontaVista Software Debian GNU/Linux Developer
2003-01-13 Daniel Jacobowitz <drow@mvista.com>
* Makefile.in (TARGET_SYSTEM_ROOT, TARGET_SYSTEM_ROOT_DEFINE): New
variables.
(main.o): Custom rule which uses $(TARGET_SYSTEM_ROOT_DEFINE).
* configure.in: Add --with-sysroot.
* configure: Regenerated.
* main.c (gdb_sysroot): New variable.
(captured_main): Initialize gdb_sysroot.
* defs.h (gdb_sysroot): New extern declaration.
* solib.c (_initialize_solib): Initialize solib_absolute_prefix.
2003-01-13 Daniel Jacobowitz <drow@mvista.com>
* gdb.texinfo (Files): Document solib-absolute-prefix and
solib-search-path.
Index: Makefile.in
===================================================================
RCS file: /cvs/src/src/gdb/Makefile.in,v
retrieving revision 1.311
diff -u -p -r1.311 Makefile.in
--- Makefile.in 9 Jan 2003 18:03:35 -0000 1.311
+++ Makefile.in 13 Jan 2003 17:29:57 -0000
@@ -136,6 +136,10 @@ INTL_CFLAGS = -I$(INTL_DIR) -I$(INTL_SRC
# Where is the ICONV library? This can be empty if libc has iconv.
LIBICONV = @LIBICONV@
+# Did the user give us a --with-sysroot option?
+TARGET_SYSTEM_ROOT = @TARGET_SYSTEM_ROOT@
+TARGET_SYSTEM_ROOT_DEFINE = @TARGET_SYSTEM_ROOT_DEFINE@
+
#
# CLI sub directory definitons
#
@@ -1402,6 +1406,11 @@ hpux-thread.o: $(srcdir)/hpux-thread.c
$(CC) -c $(INTERNAL_CFLAGS) -I$(srcdir)/osf-share \
-I$(srcdir)/osf-share/HP800 -I/usr/include/dce \
$(srcdir)/hpux-thread.c
+
+# main.o needs an explicit build rule to get TARGET_SYSTEM_ROOT and BINDIR.
+main.o: main.c
+ $(CC) -c $(INTERNAL_CFLAGS) $(TARGET_SYSTEM_ROOT_DEFINE) \
+ -DBINDIR=\"$(bindir)\" $(srcdir)/main.c
# FIXME: Procfs.o gets -Wformat errors because things like pid_t don't
# match output format strings.
Index: configure.in
===================================================================
RCS file: /cvs/src/src/gdb/configure.in,v
retrieving revision 1.116
diff -u -p -r1.116 configure.in
--- configure.in 4 Jan 2003 23:47:12 -0000 1.116
+++ configure.in 13 Jan 2003 17:29:59 -0000
@@ -851,6 +851,38 @@ fi
dnl Handle optional features that can be enabled.
+AC_ARG_WITH(sysroot,
+[ --with-sysroot[=DIR] Search for usr/lib et al within DIR.],
+[
+ case ${with_sysroot} in
+ yes) AC_ERROR(with-sysroot must specify path) ;;
+ *) TARGET_SYSTEM_ROOT=$with_sysroot ;;
+ esac
+
+ TARGET_SYSTEM_ROOT_DEFINE='-DTARGET_SYSTEM_ROOT=\"$(TARGET_SYSTEM_ROOT)\"'
+
+ if test "x$exec_prefix" = xNONE; then
+ if test "x$prefix" = xNONE; then
+ test_prefix=/usr/local
+ else
+ test_prefix=$prefix
+ fi
+ else
+ test_prefix=$exec_prefix
+ fi
+ case ${TARGET_SYSTEM_ROOT} in
+ ${test_prefix}*)
+ t="$TARGET_SYSTEM_ROOT_DEFINE -DTARGET_SYSTEM_ROOT_RELOCATABLE"
+ TARGET_SYSTEM_ROOT_DEFINE="$t"
+ ;;
+ esac
+], [
+ TARGET_SYSTEM_ROOT=
+ TARGET_SYSTEM_ROOT_DEFINE='-DTARGET_SYSTEM_ROOT=\"\"'
+])
+AC_SUBST(TARGET_SYSTEM_ROOT)
+AC_SUBST(TARGET_SYSTEM_ROOT_DEFINE)
+
# NOTE: Don't add -Wall or -Wunused, they both include
# -Wunused-parameter which reports bogus warnings.
# NOTE: If you add to this list, remember to update
Index: defs.h
===================================================================
RCS file: /cvs/src/src/gdb/defs.h,v
retrieving revision 1.107
diff -u -p -r1.107 defs.h
--- defs.h 6 Jan 2003 18:49:08 -0000 1.107
+++ defs.h 13 Jan 2003 17:29:59 -0000
@@ -1,7 +1,7 @@
/* *INDENT-OFF* */ /* ATTR_FORMAT confuses indent, avoid running it for now */
/* Basic, host-specific, and target-specific definitions for GDB.
Copyright 1986, 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996,
- 1997, 1998, 1999, 2000, 2001, 2002
+ 1997, 1998, 1999, 2000, 2001, 2002, 2003
Free Software Foundation, Inc.
This file is part of GDB.
@@ -168,6 +168,9 @@ extern int xdb_commands;
/* enable dbx commands if set */
extern int dbx_commands;
+
+/* System root path, used to find libraries etc. */
+extern char *gdb_sysroot;
extern int quit_flag;
extern int immediate_quit;
Index: main.c
===================================================================
RCS file: /cvs/src/src/gdb/main.c,v
retrieving revision 1.20
diff -u -p -r1.20 main.c
--- main.c 26 Sep 2002 17:46:04 -0000 1.20
+++ main.c 13 Jan 2003 17:29:59 -0000
@@ -1,6 +1,6 @@
/* Top level stuff for GDB, the GNU debugger.
Copyright 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995,
- 1996, 1997, 1998, 1999, 2000, 2001, 2002
+ 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003
Free Software Foundation, Inc.
This file is part of GDB.
@@ -65,6 +65,9 @@ int xdb_commands = 0;
/* Whether dbx commands will be handled */
int dbx_commands = 0;
+/* System root path, used to find libraries etc. */
+char *gdb_sysroot = 0;
+
struct ui_file *gdb_stdout;
struct ui_file *gdb_stderr;
struct ui_file *gdb_stdlog;
@@ -200,6 +203,34 @@ captured_main (void *data)
/* initialize error() */
error_init ();
+
+ /* Set the sysroot path. */
+#ifdef TARGET_SYSTEM_ROOT_RELOCATABLE
+ gdb_sysroot = make_relative_prefix (argv[0], BINDIR, TARGET_SYSTEM_ROOT);
+ if (gdb_sysroot)
+ {
+ struct stat s;
+ int res = 0;
+
+ if (stat (gdb_sysroot, &s) == 0)
+ if (S_ISDIR (s.st_mode))
+ res = 1;
+
+ if (res == 0)
+ {
+ free (gdb_sysroot);
+ gdb_sysroot = TARGET_SYSTEM_ROOT;
+ }
+ }
+ else
+ gdb_sysroot = TARGET_SYSTEM_ROOT;
+#else
+#if defined (TARGET_SYSTEM_ROOT)
+ gdb_sysroot = TARGET_SYSTEM_ROOT;
+#else
+ gdb_sysroot = "";
+#endif
+#endif
/* Parse arguments and options. */
{
Index: solib.c
===================================================================
RCS file: /cvs/src/src/gdb/solib.c,v
retrieving revision 1.51
diff -u -p -r1.51 solib.c
--- solib.c 9 Dec 2002 00:59:26 -0000 1.51
+++ solib.c 13 Jan 2003 17:30:00 -0000
@@ -1,7 +1,7 @@
/* Handle shared libraries for GDB, the GNU Debugger.
Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
- 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
+ 1999, 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
This file is part of GDB.
@@ -874,6 +874,10 @@ For other (relative) files, you can add
&setlist);
add_show_from_set (c, &showlist);
set_cmd_completer (c, filename_completer);
+
+ /* Set the default value of "solib-absolute-prefix" from the sysroot, if
+ one is set. */
+ solib_absolute_prefix = xstrdup (gdb_sysroot);
c = add_set_cmd ("solib-search-path", class_support, var_string,
(char *) &solib_search_path,
Index: doc/gdb.texinfo
===================================================================
RCS file: /cvs/src/src/gdb/doc/gdb.texinfo,v
retrieving revision 1.136
diff -u -p -r1.136 gdb.texinfo
--- doc/gdb.texinfo 5 Jan 2003 04:34:39 -0000 1.136
+++ doc/gdb.texinfo 13 Jan 2003 17:30:05 -0000
@@ -9719,6 +9719,49 @@ Mb).
Display the current autoloading size threshold, in megabytes.
@end table
+Shared libraries are also supported in many cross or remote debugging
+configurations. A copy of the target's libraries need to be present on the
+host system; they need to be the same as the target libraries, although the
+copies on the target can be stripped as long as the copies on the host are
+not.
+
+You need to tell @value{GDBN} where the target libraries are, so that it can
+load the correct copies---otherwise, it may try to load the host's libraries.
+@value{GDBN} has two variables to specify the search directories for target
+libraries.
+
+@table @code
+@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}.
+
+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
+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.
+
+@kindex show solib-search-path
+@item show solib-search-path
+Display the current shared library search path.
+@end table
+
@node Symbol Errors
@section Errors reading symbol files
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2003-01-13 17:59 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-01-09 17:37 PATCH: --with-sysroot for GDB Daniel Jacobowitz
2003-01-09 18:37 ` Kevin Buettner
2003-01-09 19:02 ` Daniel Jacobowitz
2003-01-09 19:16 ` Elena Zannoni
2003-01-13 17:59 ` Daniel Jacobowitz
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox