From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 21914 invoked by alias); 23 Apr 2009 21:27:44 -0000 Received: (qmail 21897 invoked by uid 22791); 23 Apr 2009 21:27:39 -0000 X-SWARE-Spam-Status: No, hits=-1.5 required=5.0 tests=AWL,BAYES_00,HK_OBFDOM,J_CHICKENPOX_37,J_CHICKENPOX_92,SPF_HELO_PASS,SPF_PASS X-Spam-Check-By: sourceware.org Received: from mx2.redhat.com (HELO mx2.redhat.com) (66.187.237.31) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 23 Apr 2009 21:27:30 +0000 Received: from int-mx2.corp.redhat.com (int-mx2.corp.redhat.com [172.16.27.26]) by mx2.redhat.com (8.13.8/8.13.8) with ESMTP id n3NLR537031337; Thu, 23 Apr 2009 17:27:05 -0400 Received: from ns3.rdu.redhat.com (ns3.rdu.redhat.com [10.11.255.199]) by int-mx2.corp.redhat.com (8.13.1/8.13.1) with ESMTP id n3NLR4Zw026310; Thu, 23 Apr 2009 17:27:04 -0400 Received: from opsy.redhat.com (vpn-14-41.rdu.redhat.com [10.11.14.41]) by ns3.rdu.redhat.com (8.13.8/8.13.8) with ESMTP id n3NLR3Eq026809; Thu, 23 Apr 2009 17:27:03 -0400 Received: by opsy.redhat.com (Postfix, from userid 500) id 79E6237829A; Thu, 23 Apr 2009 15:27:02 -0600 (MDT) To: =?utf-8?Q?S=C3=A9rgio?= Durigan =?utf-8?Q?J=C3=BAnior?= Cc: gdb-patches@sourceware.org Subject: Re: [PATCH 0/3] catch syscall -- try 5 -- Introduction References: <1240446781.2000.82.camel@miki> <1240453740.2000.90.camel@miki> From: Tom Tromey Reply-To: Tom Tromey Date: Thu, 23 Apr 2009 21:27:00 -0000 In-Reply-To: (Tom Tromey's message of "Thu\, 23 Apr 2009 12\:23\:10 -0600") Message-ID: User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2009-04/txt/msg00669.txt.bz2 >>>>> "Tom" =3D=3D Tom Tromey writes: S=C3=A9rgio> I'd obviously prefer to have my version of the patch commited, S=C3=A9rgio> since my testcase is based on it Tom> I'll catch you on irc and we can decide. We discussed this on irc a bit, and agreed that I will commit my version of the patch. This version has the simplifications to how relocatable directories are defined, and renames the command to "set data-directory", per commentary on the list. The patch needed a minor refresh to apply after the AS_HELP_STRING changes. The actual patch I'm committing is appended. Tom 2009-04-23 Sergio Durigan Junior Tom Tromey * configure, config.in: Regenerate. * configure.ac: Support for relocatable GDB datadir. Use GDB_AC_WITH_DIR. Always define TARGET_SYSTEM_ROOT_RELOCATABLE. * acinclude.m4 (GDB_AC_WITH_DIR): New defun. * top.c (init_main): Add "set data-directory". * defs.h (gdb_datadir): Declare. * main.c (gdb_datadir): New global. (captured_main): Initialize gdb_datadir. Use relocate_directory. (relocate_path): New function. (relocate_directory): Likewise. (get_init_files): Use relocate_path. (README): Mention --with-gdb-datadir. 2009-04-23 Tom Tromey * gdb.texinfo (Data Files): New node. (GDB Files): Update menu. Index: README =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /cvs/src/src/gdb/README,v retrieving revision 1.42 diff -u -r1.42 README --- README 17 Jan 2008 20:18:48 -0000 1.42 +++ README 23 Apr 2009 21:17:44 -0000 @@ -436,6 +436,11 @@ Same as `--host=3DHOST'. If you omit this, GDB will guess; it's quite accurate. =20 +`--with-gdb-datadir=3DPATH' + Set the GDB-specific data directory. GDB will look here for + certain supporting files or scripts. This defaults to the `gdb' + subdirectory of `datadir' (which can be set using `--datadir'). + `configure' accepts other options, for compatibility with configuring other GNU tools recursively; but these are the only options that affect GDB or its supporting libraries. Index: acinclude.m4 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /cvs/src/src/gdb/acinclude.m4,v retrieving revision 1.29 diff -u -r1.29 acinclude.m4 --- acinclude.m4 22 Apr 2009 00:17:50 -0000 1.29 +++ acinclude.m4 23 Apr 2009 21:17:44 -0000 @@ -387,3 +387,38 @@ AC_MSG_RESULT(${private_dir}) fi ]) + +dnl GDB_AC_WITH_DIR([VARIABLE], [ARG-NAME], [HELP], [DEFAULT]) +dnl Add a new --with option that defines a directory. +dnl The result is stored in VARIABLE. AC_DEFINE_DIR is called +dnl on this variable, as is AC_SUBST. +dnl ARG-NAME is the base name of the argument (without "--with"). +dnl HELP is the help text to use. +dnl If the user's choice is relative to the prefix, then the +dnl result is relocatable, then this will define the C macro +dnl VARIABLE_RELOCATABLE to 1; otherwise it is defined as 0. +dnl DEFAULT is the default value, which is used if the user +dnl does not specify the argument. +AC_DEFUN([GDB_AC_WITH_DIR], [ + AC_ARG_WITH([$2], AS_HELP_STRING([--with-][$2][=3DPATH], [$3]), [ + [$1]=3D$withval], [[$1]=3D[$4]]) + AC_DEFINE_DIR([$1], [$1], [$3]) + AC_SUBST([$1]) + if test "x$exec_prefix" =3D xNONE || test "x$exec_prefix" =3D 'x${prefix= }'; then + if test "x$prefix" =3D xNONE; then + test_prefix=3D/usr/local + else + test_prefix=3D$prefix + fi + else + test_prefix=3D$exec_prefix + fi + value=3D0 + case ${ac_define_dir} in + "${test_prefix}"|"${test_prefix}/"*|\ + '${exec_prefix}'|'${exec_prefix}/'*) + value=3D1 + ;; + esac + AC_DEFINE_UNQUOTED([$1]_RELOCATABLE, $value, [Define if the $2 directory= should be relocated when GDB is moved.]) + ]) Index: configure.ac =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /cvs/src/src/gdb/configure.ac,v retrieving revision 1.100 diff -u -r1.100 configure.ac --- configure.ac 22 Apr 2009 00:17:50 -0000 1.100 +++ configure.ac 23 Apr 2009 21:17:45 -0000 @@ -92,31 +92,15 @@ # generate its Makefile.in. AM_INIT_AUTOMAKE(gdb, UNUSED-VERSION, [no-define]) =20 -debugdir=3D${libdir}/debug -=09=20 -AC_ARG_WITH(separate-debug-dir, -[AS_HELP_STRING([--with-separate-debug-dir=3DPATH], [look for global separ= ate debug info in this path [LIBDIR/debug]])], -[debugdir=3D"${withval}"]) -=09 -AC_DEFINE_DIR(DEBUGDIR, debugdir, - [Global directory for separate debug files. ]) -#AC_DEFINE_UNQUOTED(DEBUGDIR, "$debugdir"), - -if test "x$exec_prefix" =3D xNONE || test "x$exec_prefix" =3D 'x${prefix}'= ; then - if test "x$prefix" =3D xNONE; then - test_prefix=3D/usr/local - else - test_prefix=3D$prefix - fi -else - test_prefix=3D$exec_prefix -fi -case ${debugdir} in -"${test_prefix}"|"${test_prefix}/"*|\ -'${exec_prefix}'|'${exec_prefix}/'*) - AC_DEFINE(DEBUGDIR_RELOCATABLE, 1, [Define if the debug directory should= be relocated when GDB is moved.]) - ;; -esac +GDB_AC_WITH_DIR(DEBUGDIR, separate-debug-dir, + [look for global separate debug info in this path @<:@LIBDIR/debug@:>@= ], + [${libdir}/debug]) + +# GDB's datadir relocation + +GDB_AC_WITH_DIR(GDB_DATADIR, gdb-datadir, + [look for global separate data files in this path @<:@DATADIR/gdb@:>@], + [${datadir}/gdb]) =20 AC_ARG_WITH(relocated-sources, AS_HELP_STRING([--with-relocated-sources=3DPATH], [automatically relocate = this path for source files]), @@ -1479,6 +1463,7 @@ =20 dnl Handle optional features that can be enabled. =20 +target_sysroot_reloc=3D0 AC_ARG_WITH(sysroot, AS_HELP_STRING([--with-sysroot@<:@=3DDIR@:>@], [search for usr/lib et al w= ithin DIR]), [ @@ -1504,44 +1489,20 @@ "${test_exec_prefix}"|"${test_exec_prefix}/"*|\ '${prefix}'|'${prefix}/'*|\ '${exec_prefix}'|'${exec_prefix}/'*) - t=3D"$TARGET_SYSTEM_ROOT_DEFINE -DTARGET_SYSTEM_ROOT_RELOCATABLE" - TARGET_SYSTEM_ROOT_DEFINE=3D"$t" + target_sysroot_reloc=3D1 ;; esac ], [ TARGET_SYSTEM_ROOT=3D TARGET_SYSTEM_ROOT_DEFINE=3D'-DTARGET_SYSTEM_ROOT=3D\"\"' ]) +TARGET_SYSTEM_ROOT_DEFINE=3D"$TARGET_SYSTEM_ROOT_DEFINE -DTARGET_SYSTEM_RO= OT_RELOCATABLE=3D$target_sysroot_reloc" AC_SUBST(TARGET_SYSTEM_ROOT) AC_SUBST(TARGET_SYSTEM_ROOT_DEFINE) =20 -system_gdbinit=3D -AC_ARG_WITH(system-gdbinit, -AS_HELP_STRING([--with-system-gdbinit=3DFILE], [automatically load a syste= m-wide gdbinit file]), -[system_gdbinit=3D${withval}]) - -AC_DEFINE_DIR(SYSTEM_GDBINIT, system_gdbinit, - [System-wide gdbinit file.]) - -if test "x$prefix" =3D xNONE; then - test_prefix=3D$ac_default_prefix -else - test_prefix=3D$prefix -fi -if test "x$exec_prefix" =3D xNONE || test "x$exec_prefix" =3D 'x${prefix}'= ; then - test_exec_prefix=3D$test_prefix -else - test_exec_prefix=3D$exec_prefix -fi -case ${system_gdbinit} in - "${test_prefix}"|"${test_prefix}/"*|\ - "${test_exec_prefix}"|"${test_exec_prefix}/"*|\ - '${prefix}'|'${prefix}/'*|\ - '${exec_prefix}'|'${exec_prefix}/'*) - AC_DEFINE(SYSTEM_GDBINIT_RELOCATABLE, 1, - [Define if the system-wide gdbinit file should be relocated wh= en GDB is moved.]) - ;; -esac +GDB_AC_WITH_DIR(SYSTEM_GDBINIT, system-gdbinit, + [automatically load a system-wide gdbinit file], + []) =20 AC_ARG_ENABLE(werror, AS_HELP_STRING([--enable-werror], [treat compile warnings as errors]), Index: defs.h =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /cvs/src/src/gdb/defs.h,v retrieving revision 1.248 diff -u -r1.248 defs.h --- defs.h 20 Mar 2009 23:04:32 -0000 1.248 +++ defs.h 23 Apr 2009 21:17:45 -0000 @@ -153,6 +153,9 @@ /* System root path, used to find libraries etc. */ extern char *gdb_sysroot; =20 +/* GDB datadir, used to store data files. */ +extern char *gdb_datadir; + /* Search path for separate debug files. */ extern char *debug_file_directory; =20 Index: main.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /cvs/src/src/gdb/main.c,v retrieving revision 1.74 diff -u -r1.74 main.c --- main.c 21 Apr 2009 10:13:05 -0000 1.74 +++ main.c 23 Apr 2009 21:17:45 -0000 @@ -64,6 +64,9 @@ /* System root path, used to find libraries etc. */ char *gdb_sysroot =3D 0; =20 +/* GDB datadir, used to store data files. */ +char *gdb_datadir =3D 0; + struct ui_file *gdb_stdout; struct ui_file *gdb_stderr; struct ui_file *gdb_stdlog; @@ -95,6 +98,57 @@ =20 extern char *external_editor_command; =20 +/* Relocate a file or directory. PROGNAME is the name by which gdb + was invoked (i.e., argv[0]). INITIAL is the default value for the + file or directory. FLAG is true if the value is relocatable, false + otherwise. Returns a newly allocated string; this may return NULL + under the same conditions as make_relative_prefix. */ +static char * +relocate_path (const char *progname, const char *initial, int flag) +{ + if (flag) + return make_relative_prefix (progname, BINDIR, initial); + return xstrdup (initial); +} + +/* Like relocate_path, but specifically checks for a directory. + INITIAL is relocated according to the rules of relocate_path. If + the result is a directory, it is used; otherwise, INITIAL is used. + The chosen directory is then canonicalized using lrealpath. This + function always returns a newly-allocated string. */ +static char * +relocate_directory (const char *progname, const char *initial, int flag) +{ + char *dir; + + dir =3D relocate_path (progname, initial, flag); + if (dir) + { + struct stat s; + + if (stat (dir, &s) !=3D 0 || !S_ISDIR (s.st_mode)) + { + xfree (dir); + dir =3D NULL; + } + } + if (!dir) + dir =3D xstrdup (initial); + + /* Canonicalize the directory. */ + if (*dir) + { + char *canon_sysroot =3D lrealpath (dir); + if (canon_sysroot) + { + xfree (dir); + dir =3D canon_sysroot; + } + } + + return dir; +} + /* Compute the locations of init files that GDB should source and return them in SYSTEM_GDBINIT, HOME_GDBINIT, LOCAL_GDBINIT. If there is=20 no system gdbinit (resp. home gdbinit and local gdbinit) to be loaded, @@ -115,24 +169,16 @@ struct stat homebuf, cwdbuf, s; char *homedir, *relocated_sysgdbinit; =20 - sysgdbinit =3D SYSTEM_GDBINIT; - if (!sysgdbinit [0] || stat (sysgdbinit, &s) !=3D 0) - sysgdbinit =3D NULL; - -#ifdef SYSTEM_GDBINIT_RELOCATABLE - relocated_sysgdbinit =3D make_relative_prefix (gdb_program_name, BIN= DIR, - SYSTEM_GDBINIT); - if (relocated_sysgdbinit) + if (SYSTEM_GDBINIT[0]) { - struct stat s; - int res =3D 0; - - if (stat (relocated_sysgdbinit, &s) =3D=3D 0) + relocated_sysgdbinit =3D relocate_path (gdb_program_name, + SYSTEM_GDBINIT, + SYSTEM_GDBINIT_RELOCATABLE); + if (relocated_sysgdbinit && stat (relocated_sysgdbinit, &s) =3D=3D 0) sysgdbinit =3D relocated_sysgdbinit; else xfree (relocated_sysgdbinit); } -#endif =20 homedir =3D getenv ("HOME"); =20 @@ -291,73 +337,14 @@ current_directory =3D gdb_dirbuf; =20 /* Set the sysroot path. */ -#ifdef TARGET_SYSTEM_ROOT_RELOCATABLE - gdb_sysroot =3D make_relative_prefix (argv[0], BINDIR, TARGET_SYSTEM_ROO= T); - if (gdb_sysroot) - { - struct stat s; - int res =3D 0; + gdb_sysroot =3D relocate_directory (argv[0], TARGET_SYSTEM_ROOT, + TARGET_SYSTEM_ROOT_RELOCATABLE); =20 - if (stat (gdb_sysroot, &s) =3D=3D 0) - if (S_ISDIR (s.st_mode)) - res =3D 1; + debug_file_directory =3D relocate_directory (argv[0], DEBUGDIR, + DEBUGDIR_RELOCATABLE); =20 - if (res =3D=3D 0) - { - xfree (gdb_sysroot); - gdb_sysroot =3D xstrdup (TARGET_SYSTEM_ROOT); - } - } - else - gdb_sysroot =3D xstrdup (TARGET_SYSTEM_ROOT); -#else - gdb_sysroot =3D xstrdup (TARGET_SYSTEM_ROOT); -#endif - - /* Canonicalize the sysroot path. */ - if (*gdb_sysroot) - { - char *canon_sysroot =3D lrealpath (gdb_sysroot); - if (canon_sysroot) - { - xfree (gdb_sysroot); - gdb_sysroot =3D canon_sysroot; - } - } - -#ifdef DEBUGDIR_RELOCATABLE - debug_file_directory =3D make_relative_prefix (argv[0], BINDIR, DEBUGDIR= ); - if (debug_file_directory) - { - struct stat s; - int res =3D 0; - - if (stat (debug_file_directory, &s) =3D=3D 0) - if (S_ISDIR (s.st_mode)) - res =3D 1; - - if (res =3D=3D 0) - { - xfree (debug_file_directory); - debug_file_directory =3D xstrdup (DEBUGDIR); - } - } - else - debug_file_directory =3D xstrdup (DEBUGDIR); -#else - debug_file_directory =3D xstrdup (DEBUGDIR); -#endif - - /* Canonicalize the debugfile path. */ - if (*debug_file_directory) - { - char *canon_debug =3D lrealpath (debug_file_directory); - if (canon_debug) - { - xfree (debug_file_directory); - debug_file_directory =3D canon_debug; - } - } + gdb_datadir =3D relocate_directory (argv[0], GDB_DATADIR, + GDB_DATADIR_RELOCATABLE); =20 get_init_files (&system_gdbinit, &home_gdbinit, &local_gdbinit); =20 Index: top.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /cvs/src/src/gdb/top.c,v retrieving revision 1.163 diff -u -r1.163 top.c --- top.c 25 Mar 2009 21:42:34 -0000 1.163 +++ top.c 23 Apr 2009 21:17:45 -0000 @@ -1619,6 +1619,15 @@ NULL, show_exec_done_display_p, &setlist, &showlist); + + add_setshow_filename_cmd ("data-directory", class_maintenance, + &gdb_datadir, _("Set GDB's data directory."), + _("Show GDB's data directory."), + _("\ +When set, GDB uses the specified path to search for data files."), + NULL, NULL, + &setlist, + &showlist); } =20 void Index: doc/gdb.texinfo =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /cvs/src/src/gdb/doc/gdb.texinfo,v retrieving revision 1.584 diff -u -r1.584 gdb.texinfo --- doc/gdb.texinfo 22 Apr 2009 17:24:59 -0000 1.584 +++ doc/gdb.texinfo 23 Apr 2009 21:17:49 -0000 @@ -12734,6 +12734,7 @@ * Files:: Commands to specify files * Separate Debug Files:: Debugging information in separate files * Symbol Errors:: Errors reading symbol files +* Data Files:: GDB data files @end menu =20 @node Files @@ -13568,6 +13569,36 @@ =20 @end table =20 +@node Data Files +@section GDB Data Files + +@cindex prefix for data files +@value{GDBN} will sometimes read an auxiliary data file. These files +are kept in a directory known as the @dfn{data directory}. + +You can set the data directory's name, and view the name @value{GDBN} +is currently using. + +@table @code +@kindex set data-directory +@item set data-directory @var{directory} +Set the directory which @value{GDBN} searches for auxiliary data files +to @var{directory}. + +@kindex show data-directory +@item show data-directory +Show the directory @value{GDBN} searches for auxiliary data files. +@end table + +@cindex default data directory +@cindex @samp{--with-gdb-datadir} +You can set the default data directory by using the configure-time +@samp{--with-gdb-datadir} option. If the data directory is inside +@value{GDBN}'s configured binary prefix (set with @samp{--prefix} or +@samp{--exec-prefix}), then the default data directory will be updated +automatically if the installed @value{GDBN} is moved to a new +location. + @node Targets @chapter Specifying a Debugging Target =20