From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Mailing-List: contact gdb-patches-help@sources.redhat.com; run by ezmlm Received: (qmail 3760 invoked from network); 9 Jan 2003 19:16:58 -0000 Received: from unknown (HELO mx1.redhat.com) (66.187.233.31) by 209.249.29.67 with SMTP; 9 Jan 2003 19:16:58 -0000 Received: from int-mx1.corp.redhat.com (int-mx1.corp.redhat.com [172.16.52.254]) by mx1.redhat.com (8.11.6/8.11.6) with ESMTP id h09ImwB08459 for ; Thu, 9 Jan 2003 13:48:58 -0500 Received: from pobox.corp.redhat.com (pobox.corp.redhat.com [172.16.52.156]) by int-mx1.corp.redhat.com (8.11.6/8.11.6) with ESMTP id h09JGla29629 for ; Thu, 9 Jan 2003 14:16:47 -0500 Received: from localhost.redhat.com (romulus-int.sfbay.redhat.com [172.16.27.46]) by pobox.corp.redhat.com (8.11.6/8.11.6) with ESMTP id h09JGje12157 for ; Thu, 9 Jan 2003 14:16:46 -0500 Received: by localhost.redhat.com (Postfix, from userid 469) id 2A23AFF79; Thu, 9 Jan 2003 14:21:07 -0500 (EST) From: Elena Zannoni MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-ID: <15901.52131.728865.997468@localhost.redhat.com> Date: Thu, 09 Jan 2003 19:16:00 -0000 To: Daniel Jacobowitz Cc: gdb-patches@sources.redhat.com, Dan Kegel Subject: Re: PATCH: --with-sysroot for GDB In-Reply-To: <20030109173810.GA19919@nevyn.them.org> References: <20030109173810.GA19919@nevyn.them.org> X-SW-Source: 2003-01/txt/msg00380.txt.bz2 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 > > * 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 > > * 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.