* Python pretty-printing [1/6]
@ 2009-04-02 20:54 Tom Tromey
2009-04-03 14:23 ` Eli Zaretskii
` (3 more replies)
0 siblings, 4 replies; 19+ messages in thread
From: Tom Tromey @ 2009-04-02 20:54 UTC (permalink / raw)
To: gdb-patches
This is the first in a series of patches which implement the
long-discussed Python pretty-printing feature.
This patch imports --with-gdb-data from Sérgio's syscall patch.
It also adds --with-pythondir and arranges for some Python variables
to be set appropriately.
This code is needed as the basis of the auto-loading patch.
Tom
2009-01-25 Sergio Durigan Junior <sergiodj@linux.vnet.ibm.com>
Tom Tromey <tromey@redhat.com>
* configure, config.in: Regenerate.
* configure.ac: Support for relocatable GDB datadir. Add
--with-pythondir.
* python/python.c (_initialize_python): Set pythondir or datadir
as needed. Update sys.path.
* maint.c (_initialize_maint_cmds): Add "maint set gdb_datadir".
* defs.h (gdb_datadir): Declare.
* main.c (gdb_datadir): New global.
(captured_main): Initialize gdb_datadir.
gdb/ChangeLog | 13 ++++++++
gdb/config.in | 9 ++++++
gdb/configure | 77 ++++++++++++++++++++++++++++++++++++++++++++++++++-
gdb/configure.ac | 45 +++++++++++++++++++++++++++++
gdb/defs.h | 3 ++
gdb/main.c | 37 ++++++++++++++++++++++++
gdb/maint.c | 8 +++++
gdb/python/python.c | 15 ++++++++++
8 files changed, 206 insertions(+), 1 deletions(-)
diff --git a/gdb/configure.ac b/gdb/configure.ac
index 821dffe..9bca6c6 100644
--- a/gdb/configure.ac
+++ b/gdb/configure.ac
@@ -118,6 +118,51 @@ case ${debugdir} in
;;
esac
+# GDB's datadir relocation
+
+gdbdatadir=${datadir}/gdb
+
+AC_ARG_WITH([gdb-datadir],
+ [AS_HELP_STRING([--with-gdb-datadir],
+ [look for global separate data files in this path [DATADIR/gdb]])], [gdbdatadir="${withval}"])
+
+AC_DEFINE_DIR(GDB_DATADIR, gdbdatadir,
+ [Global directory for GDB data files. ])
+
+if test "x$exec_prefix" = xNONE || test "x$exec_prefix" = 'x${prefix}'; then
+ if test "x$prefix" = xNONE; then
+ test_prefix=/usr/local
+ else
+ test_prefix=$prefix
+ fi
+else
+ test_prefix=$exec_prefix
+fi
+
+case ${gdbdatadir} in
+ "${test_prefix}"|"${test_prefix}/"*|\
+ '${exec_prefix}'|'${exec_prefix}/'*)
+ AC_DEFINE(GDB_DATADIR_RELOCATABLE, 1, [Define if GDB datadir should be relocated when GDB is moved.])
+ ;;
+esac
+GDB_DATADIR_PATH=${gdbdatadir}
+AC_SUBST(GDB_DATADIR_PATH)
+
+AC_ARG_WITH([pythondir],
+ [AS_HELP_STRING([--with-pythondir],
+ [install Python data files in this path [DATADIR/gdb/python]])], [pythondir="${withval}"], [pythondir=no])
+
+# If the user passed in a path, define it. Otherwise, compute it at
+# runtime based on the possibly-relocatable datadir.
+if test "$pythondir" = "no"; then
+ pythondir='$(GDB_DATADIR_PATH)/python'
+else
+ AC_DEFINE_UNQUOTED(PYTHONDIR, "$pythondir",
+ [Define to install path for Python sources])
+fi
+AC_SUBST(pythondir)
+
+
AC_CONFIG_SUBDIRS(doc testsuite)
# Check whether to support alternative target configurations
diff --git a/gdb/defs.h b/gdb/defs.h
index 882a844..ee80659 100644
--- a/gdb/defs.h
+++ b/gdb/defs.h
@@ -153,6 +153,9 @@ extern int dbx_commands;
/* System root path, used to find libraries etc. */
extern char *gdb_sysroot;
+/* GDB datadir, used to store data files. */
+extern char *gdb_datadir;
+
/* Search path for separate debug files. */
extern char *debug_file_directory;
diff --git a/gdb/main.c b/gdb/main.c
index 5d4640b..fe65dc5 100644
--- a/gdb/main.c
+++ b/gdb/main.c
@@ -62,6 +62,9 @@ int dbx_commands = 0;
/* System root path, used to find libraries etc. */
char *gdb_sysroot = 0;
+/* GDB datadir, used to store data files. */
+char *gdb_datadir = 0;
+
struct ui_file *gdb_stdout;
struct ui_file *gdb_stderr;
struct ui_file *gdb_stdlog;
@@ -357,6 +360,40 @@ captured_main (void *data)
}
}
+#ifdef GDB_DATADIR_RELOCATABLE
+ gdb_datadir = make_relative_prefix (argv[0], BINDIR, GDB_DATADIR);
+ if (gdb_datadir)
+ {
+ struct stat s;
+ int res = 0;
+
+ if (stat (gdb_datadir, &s) == 0)
+ if (S_ISDIR (s.st_mode))
+ res = 1;
+
+ if (res == 0)
+ {
+ xfree (gdb_datadir);
+ gdb_datadir = xstrdup (GDB_DATADIR);
+ }
+ }
+ else
+ gdb_datadir = xstrdup (GDB_DATADIR);
+#else
+ gdb_datadir = xstrdup (GDB_DATADIR);
+#endif /* GDB_DATADIR_RELOCATABLE */
+
+ /* Canonicalize the GDB's datadir path. */
+ if (*gdb_datadir)
+ {
+ char *canon_debug = lrealpath (gdb_datadir);
+ if (canon_debug)
+ {
+ xfree (gdb_datadir);
+ gdb_datadir = canon_debug;
+ }
+ }
+
get_init_files (&system_gdbinit, &home_gdbinit, &local_gdbinit);
/* There will always be an interpreter. Either the one passed into
diff --git a/gdb/maint.c b/gdb/maint.c
index 56cafe9..1b57ff5 100644
--- a/gdb/maint.c
+++ b/gdb/maint.c
@@ -906,4 +906,12 @@ When enabled GDB is profiled."),
show_maintenance_profile_p,
&maintenance_set_cmdlist,
&maintenance_show_cmdlist);
+ add_setshow_filename_cmd ("gdb_datadir", class_maintenance,
+ &gdb_datadir, _("Set GDB's datadir path."),
+ _("Show GDB's datadir path."),
+ _("\
+When set, GDB uses the specified path to search for data files."),
+ NULL, NULL,
+ &maintenance_set_cmdlist,
+ &maintenance_show_cmdlist);
}
diff --git a/gdb/python/python.c b/gdb/python/python.c
index b48cf05..1762c46 100644
--- a/gdb/python/python.c
+++ b/gdb/python/python.c
@@ -409,6 +409,12 @@ Enables or disables printing of Python stack traces."),
PyModule_AddStringConstant (gdb_module, "VERSION", (char*) version);
PyModule_AddStringConstant (gdb_module, "HOST_CONFIG", (char*) host_name);
PyModule_AddStringConstant (gdb_module, "TARGET_CONFIG", (char*) target_name);
+#ifdef PYTHONDIR
+ PyModule_AddStringConstant (gdb_module, "pythondir", PYTHONDIR);
+#else
+ if (gdb_datadir)
+ PyModule_AddStringConstant (gdb_module, "datadir", gdb_datadir);
+#endif
gdbpy_initialize_values ();
gdbpy_initialize_commands ();
@@ -442,6 +448,15 @@ class GdbOutputFile:\n\
\n\
sys.stderr = GdbOutputFile()\n\
sys.stdout = GdbOutputFile()\n\
+if hasattr (gdb, 'datadir'):\n\
+ gdb.pythondir = gdb.datadir + '/python'\n\
+if hasattr (gdb, 'pythondir'):\n\
+ sys.path.insert(0, gdb.pythondir)\n\
+ gdb.__path__ = [gdb.pythondir + '/gdb']\n\
+ from os.path import exists\n\
+ ipy = gdb.pythondir + '/gdb/__init__.py'\n\
+ if exists (ipy):\n\
+ execfile (ipy)\n\
");
/* Release the GIL while gdb runs. */
--
1.6.0.6
^ permalink raw reply [flat|nested] 19+ messages in thread* Re: Python pretty-printing [1/6] 2009-04-02 20:54 Python pretty-printing [1/6] Tom Tromey @ 2009-04-03 14:23 ` Eli Zaretskii 2009-04-03 15:46 ` Tom Tromey 2009-04-03 15:23 ` Daniel Jacobowitz ` (2 subsequent siblings) 3 siblings, 1 reply; 19+ messages in thread From: Eli Zaretskii @ 2009-04-03 14:23 UTC (permalink / raw) To: tromey; +Cc: gdb-patches > From: Tom Tromey <tromey@redhat.com> > Date: Thu, 02 Apr 2009 14:54:02 -0600 > > This is the first in a series of patches which implement the > long-discussed Python pretty-printing feature. Thanks. > This patch imports --with-gdb-data from Sérgio's syscall patch. > It also adds --with-pythondir and arranges for some Python variables > to be set appropriately. Should these configure-time options be described in the manual and/or in README? > * maint.c (_initialize_maint_cmds): Add "maint set gdb_datadir". Is this new command documented in one of your patches? If it is, I missed that part. ^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: Python pretty-printing [1/6] 2009-04-03 14:23 ` Eli Zaretskii @ 2009-04-03 15:46 ` Tom Tromey 2009-04-03 17:13 ` Eli Zaretskii 2009-04-03 18:29 ` Tom Tromey 0 siblings, 2 replies; 19+ messages in thread From: Tom Tromey @ 2009-04-03 15:46 UTC (permalink / raw) To: Eli Zaretskii; +Cc: gdb-patches >>>>> "Eli" == Eli Zaretskii <eliz@gnu.org> writes: >> This patch imports --with-gdb-data from Sérgio's syscall patch. >> It also adds --with-pythondir and arranges for some Python variables >> to be set appropriately. Eli> Should these configure-time options be described in the manual and/or Eli> in README? Tell me where you want this, and I will add it. Most of the gdb-specific configure options aren't documented. That is why I did not bother. >> * maint.c (_initialize_maint_cmds): Add "maint set gdb_datadir". Eli> Is this new command documented in one of your patches? If it is, I Eli> missed that part. I will add this. Tom ^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: Python pretty-printing [1/6] 2009-04-03 15:46 ` Tom Tromey @ 2009-04-03 17:13 ` Eli Zaretskii 2009-04-04 21:43 ` Thiago Jung Bauermann 2009-04-03 18:29 ` Tom Tromey 1 sibling, 1 reply; 19+ messages in thread From: Eli Zaretskii @ 2009-04-03 17:13 UTC (permalink / raw) To: Tom Tromey; +Cc: gdb-patches > Cc: gdb-patches@sourceware.org > From: Tom Tromey <tromey@redhat.com> > Date: Fri, 03 Apr 2009 09:45:50 -0600 > > >>>>> "Eli" == Eli Zaretskii <eliz@gnu.org> writes: > > >> This patch imports --with-gdb-data from Sérgio's syscall patch. > >> It also adds --with-pythondir and arranges for some Python variables > >> to be set appropriately. > > Eli> Should these configure-time options be described in the manual and/or > Eli> in README? > > Tell me where you want this, and I will add it. Most of the > gdb-specific configure options aren't documented. That is why I did > not bother. I think it should be in README, if no one else objects. I will add the rest of the options myself later. Joel, if it isn't done when you are going to branch, would you please ping me? ^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: Python pretty-printing [1/6] 2009-04-03 17:13 ` Eli Zaretskii @ 2009-04-04 21:43 ` Thiago Jung Bauermann 2009-04-05 3:12 ` Eli Zaretskii 0 siblings, 1 reply; 19+ messages in thread From: Thiago Jung Bauermann @ 2009-04-04 21:43 UTC (permalink / raw) To: Eli Zaretskii; +Cc: Tom Tromey, gdb-patches, Joel Brobecker El vie, 03-04-2009 a las 20:11 +0300, Eli Zaretskii escribió: > > Cc: gdb-patches@sourceware.org > > From: Tom Tromey <tromey@redhat.com> > > Date: Fri, 03 Apr 2009 09:45:50 -0600 > > > > Tell me where you want this, and I will add it. Most of the > > gdb-specific configure options aren't documented. That is why I did > > not bother. > > I think it should be in README, if no one else objects. > > I will add the rest of the options myself later. Joel, if it isn't > done when you are going to branch, would you please ping me? I just added this: * Add missing configure options to the README (ping Eli about it). to the release page on the wiki [0]. [0] - http://sourceware.org/gdb/wiki/GDB_7.0_Release -- []'s Thiago Jung Bauermann IBM Linux Technology Center ^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: Python pretty-printing [1/6] 2009-04-04 21:43 ` Thiago Jung Bauermann @ 2009-04-05 3:12 ` Eli Zaretskii 0 siblings, 0 replies; 19+ messages in thread From: Eli Zaretskii @ 2009-04-05 3:12 UTC (permalink / raw) To: Thiago Jung Bauermann; +Cc: tromey, gdb-patches, brobecker > From: Thiago Jung Bauermann <bauerman@br.ibm.com> > Cc: Tom Tromey <tromey@redhat.com>, gdb-patches@sourceware.org, > Joel Brobecker <brobecker@adacore.com> > Date: Sat, 04 Apr 2009 18:43:29 -0300 > > > I will add the rest of the options myself later. Joel, if it isn't > > done when you are going to branch, would you please ping me? > > I just added this: > > * Add missing configure options to the README (ping Eli about it). > > to the release page on the wiki [0]. Thanks. ^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: Python pretty-printing [1/6] 2009-04-03 15:46 ` Tom Tromey 2009-04-03 17:13 ` Eli Zaretskii @ 2009-04-03 18:29 ` Tom Tromey 2009-04-03 19:14 ` Daniel Jacobowitz 1 sibling, 1 reply; 19+ messages in thread From: Tom Tromey @ 2009-04-03 18:29 UTC (permalink / raw) To: Eli Zaretskii; +Cc: gdb-patches, Sérgio Durigan Júnior Tom> * maint.c (_initialize_maint_cmds): Add "maint set gdb_datadir". Eli> Is this new command documented in one of your patches? If it is, I Eli> missed that part. Tom> I will add this. I am considering just dropping this command instead. It doesn't seem very useful to me. Sérgio, do you remember why you added this? Tom ^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: Python pretty-printing [1/6] 2009-04-03 18:29 ` Tom Tromey @ 2009-04-03 19:14 ` Daniel Jacobowitz 2009-04-03 20:39 ` Tom Tromey 0 siblings, 1 reply; 19+ messages in thread From: Daniel Jacobowitz @ 2009-04-03 19:14 UTC (permalink / raw) To: Tom Tromey; +Cc: Eli Zaretskii, gdb-patches, Sérgio Durigan Júnior On Fri, Apr 03, 2009 at 12:29:36PM -0600, Tom Tromey wrote: > Tom> * maint.c (_initialize_maint_cmds): Add "maint set gdb_datadir". > > Eli> Is this new command documented in one of your patches? If it is, I > Eli> missed that part. > > Tom> I will add this. > > I am considering just dropping this command instead. > It doesn't seem very useful to me. Sérgio, do you remember why you > added this? FWIW, I think it shouldn't even be a maint command. We can set debug-file-directory and sysroot, why not datadir? Vladimir was just asking you about testing pretty-printing with an uninstalled GDB; that seems like one use. -- Daniel Jacobowitz CodeSourcery ^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: Python pretty-printing [1/6] 2009-04-03 19:14 ` Daniel Jacobowitz @ 2009-04-03 20:39 ` Tom Tromey 0 siblings, 0 replies; 19+ messages in thread From: Tom Tromey @ 2009-04-03 20:39 UTC (permalink / raw) To: Eli Zaretskii; +Cc: gdb-patches, Sérgio Durigan Júnior >>>>> "Daniel" == Daniel Jacobowitz <drow@false.org> writes: Daniel> FWIW, I think it shouldn't even be a maint command. We can set Daniel> debug-file-directory and sysroot, why not datadir? Good point. I renamed it to "set datadir". I think I will put the docs for this in a later patch. At least with the current gdb, it seems to make the most sense to have the documentation for this new parameter located near the sole user of it; but that node doesn't appear until patch #2. I also noticed that some of the code in patch #1 is actually not really related to this feature. All the pythondir stuff will be gone in the next revision; I'll send this as soon as I fix up the README. Tom ^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: Python pretty-printing [1/6] 2009-04-02 20:54 Python pretty-printing [1/6] Tom Tromey 2009-04-03 14:23 ` Eli Zaretskii @ 2009-04-03 15:23 ` Daniel Jacobowitz 2009-04-03 23:58 ` Tom Tromey 2009-04-07 18:24 ` Joel Brobecker 3 siblings, 0 replies; 19+ messages in thread From: Daniel Jacobowitz @ 2009-04-03 15:23 UTC (permalink / raw) To: Tom Tromey; +Cc: gdb-patches On Thu, Apr 02, 2009 at 02:54:02PM -0600, Tom Tromey wrote: > This is the first in a series of patches which implement the > long-discussed Python pretty-printing feature. > > This patch imports --with-gdb-data from Sérgio's syscall patch. > It also adds --with-pythondir and arranges for some Python variables > to be set appropriately. If you specify --with-pythondir=$prefix/python, it's not relocatable. I'd like to keep all specified paths with the same relocation behavior, please. Bonus points if you can reduce the code duplication involved in defining each switch and relocating each path... -- Daniel Jacobowitz CodeSourcery ^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: Python pretty-printing [1/6] 2009-04-02 20:54 Python pretty-printing [1/6] Tom Tromey 2009-04-03 14:23 ` Eli Zaretskii 2009-04-03 15:23 ` Daniel Jacobowitz @ 2009-04-03 23:58 ` Tom Tromey 2009-04-04 3:30 ` Daniel Jacobowitz 2009-04-04 9:10 ` Eli Zaretskii 2009-04-07 18:24 ` Joel Brobecker 3 siblings, 2 replies; 19+ messages in thread From: Tom Tromey @ 2009-04-03 23:58 UTC (permalink / raw) To: gdb-patches Here is the revised version of patch #1. I believe I have addressed all the comments. (As I mentioned before, I plan to document "set data-directory" in a later patch -- unless, Eli, there is an existing node where you want this to appear.) While testing this I discovered that the relocatable directory code in configure does not appear to actually work. This patch fixes this problem. Tom 2009-01-25 Sergio Durigan Junior <sergiodj@linux.vnet.ibm.com> Tom Tromey <tromey@redhat.com> * 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. --- gdb/ChangeLog | 16 ++++++ gdb/README | 5 ++ gdb/acinclude.m4 | 35 ++++++++++++ gdb/config.in | 16 ++++-- gdb/configure | 154 ++++++++++++++++++++++++++++++++++++++---------------- gdb/configure.ac | 70 ++++++------------------- gdb/defs.h | 3 + gdb/main.c | 143 +++++++++++++++++++++++--------------------------- gdb/top.c | 9 +++ 9 files changed, 269 insertions(+), 182 deletions(-) diff --git a/gdb/README b/gdb/README index cc16ecd..868cbb5 100644 --- a/gdb/README +++ b/gdb/README @@ -436,6 +436,11 @@ prefer; but you may abbreviate option names if you use `--'. Same as `--host=HOST'. If you omit this, GDB will guess; it's quite accurate. +`--with-gdb-datadir=PATH' + 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. diff --git a/gdb/acinclude.m4 b/gdb/acinclude.m4 index 5e77230..cdf8015 100644 --- a/gdb/acinclude.m4 +++ b/gdb/acinclude.m4 @@ -387,3 +387,38 @@ AC_DEFUN([CY_AC_TK_PRIVATE_HEADERS], [ 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][=PATH], [$3]), [ + [$1]=$withval], [[$1]=[$4]]) + AC_DEFINE_DIR([$1], [$1], [$3]) + AC_SUBST([$1]) + if test "x$exec_prefix" = xNONE || test "x$exec_prefix" = 'x${prefix}'; then + if test "x$prefix" = xNONE; then + test_prefix=/usr/local + else + test_prefix=$prefix + fi + else + test_prefix=$exec_prefix + fi + value=0 + case ${ac_define_dir} in + "${test_prefix}"|"${test_prefix}/"*|\ + '${exec_prefix}'|'${exec_prefix}/'*) + value=1 + ;; + esac + AC_DEFINE_UNQUOTED([$1]_RELOCATABLE, $value, [Define if the $2 directory should be relocated when GDB is moved.]) + ]) diff --git a/gdb/configure.ac b/gdb/configure.ac index 821dffe..05dcd9b 100644 --- a/gdb/configure.ac +++ b/gdb/configure.ac @@ -92,31 +92,16 @@ AC_SUBST(PACKAGE) # generate its Makefile.in. AM_INIT_AUTOMAKE(gdb, UNUSED-VERSION, [no-define]) -debugdir=${libdir}/debug - -AC_ARG_WITH(separate-debug-dir, -[ --with-separate-debug-dir=path Look for global separate debug info in this path [LIBDIR/debug]], -[debugdir="${withval}"]) - -AC_DEFINE_DIR(DEBUGDIR, debugdir, - [Global directory for separate debug files. ]) -#AC_DEFINE_UNQUOTED(DEBUGDIR, "$debugdir"), - -if test "x$exec_prefix" = xNONE || test "x$exec_prefix" = 'x${prefix}'; then - if test "x$prefix" = xNONE; then - test_prefix=/usr/local - else - test_prefix=$prefix - fi -else - test_prefix=$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]) + AC_CONFIG_SUBDIRS(doc testsuite) @@ -1474,6 +1459,7 @@ fi dnl Handle optional features that can be enabled. +target_sysroot_reloc=0 AC_ARG_WITH(sysroot, [ --with-sysroot[=DIR] Search for usr/lib et al within DIR.], [ @@ -1499,44 +1485,20 @@ AC_ARG_WITH(sysroot, "${test_exec_prefix}"|"${test_exec_prefix}/"*|\ '${prefix}'|'${prefix}/'*|\ '${exec_prefix}'|'${exec_prefix}/'*) - t="$TARGET_SYSTEM_ROOT_DEFINE -DTARGET_SYSTEM_ROOT_RELOCATABLE" - TARGET_SYSTEM_ROOT_DEFINE="$t" + target_sysroot_reloc=1 ;; esac ], [ TARGET_SYSTEM_ROOT= TARGET_SYSTEM_ROOT_DEFINE='-DTARGET_SYSTEM_ROOT=\"\"' ]) +TARGET_SYSTEM_ROOT_DEFINE="$TARGET_SYSTEM_ROOT_DEFINE -DTARGET_SYSTEM_ROOT_RELOCATABLE=$target_sysroot_reloc" AC_SUBST(TARGET_SYSTEM_ROOT) AC_SUBST(TARGET_SYSTEM_ROOT_DEFINE) -system_gdbinit= -AC_ARG_WITH(system-gdbinit, -[ --with-system-gdbinit=file Automatically load a system-wide gdbinit file], -[system_gdbinit=${withval}]) - -AC_DEFINE_DIR(SYSTEM_GDBINIT, system_gdbinit, - [System-wide gdbinit file.]) - -if test "x$prefix" = xNONE; then - test_prefix=$ac_default_prefix -else - test_prefix=$prefix -fi -if test "x$exec_prefix" = xNONE || test "x$exec_prefix" = 'x${prefix}'; then - test_exec_prefix=$test_prefix -else - test_exec_prefix=$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 when GDB is moved.]) - ;; -esac +GDB_AC_WITH_DIR(SYSTEM_GDBINIT, system-gdbinit, + [Automatically load a system-wide gdbinit file], + []) AC_ARG_ENABLE(werror, [ --enable-werror treat compile warnings as errors], diff --git a/gdb/defs.h b/gdb/defs.h index 882a844..ee80659 100644 --- a/gdb/defs.h +++ b/gdb/defs.h @@ -153,6 +153,9 @@ extern int dbx_commands; /* System root path, used to find libraries etc. */ extern char *gdb_sysroot; +/* GDB datadir, used to store data files. */ +extern char *gdb_datadir; + /* Search path for separate debug files. */ extern char *debug_file_directory; diff --git a/gdb/main.c b/gdb/main.c index 5d4640b..edfea30 100644 --- a/gdb/main.c +++ b/gdb/main.c @@ -62,6 +62,9 @@ int dbx_commands = 0; /* System root path, used to find libraries etc. */ char *gdb_sysroot = 0; +/* GDB datadir, used to store data files. */ +char *gdb_datadir = 0; + struct ui_file *gdb_stdout; struct ui_file *gdb_stderr; struct ui_file *gdb_stdlog; @@ -93,6 +96,57 @@ static void print_gdb_help (struct ui_file *); extern char *external_editor_command; +/* 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 = relocate_path (progname, initial, flag); + if (dir) + { + struct stat s; + + if (stat (dir, &s) != 0 || !S_ISDIR (s.st_mode)) + { + xfree (dir); + dir = NULL; + } + } + if (!dir) + dir = xstrdup (initial); + + /* Canonicalize the directory. */ + if (*dir) + { + char *canon_sysroot = lrealpath (dir); + if (canon_sysroot) + { + xfree (dir); + dir = 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 no system gdbinit (resp. home gdbinit and local gdbinit) to be loaded, @@ -113,24 +167,16 @@ get_init_files (char **system_gdbinit, struct stat homebuf, cwdbuf, s; char *homedir, *relocated_sysgdbinit; - sysgdbinit = SYSTEM_GDBINIT; - if (!sysgdbinit [0] || stat (sysgdbinit, &s) != 0) - sysgdbinit = NULL; - -#ifdef SYSTEM_GDBINIT_RELOCATABLE - relocated_sysgdbinit = make_relative_prefix (gdb_program_name, BINDIR, - SYSTEM_GDBINIT); - if (relocated_sysgdbinit) + if (SYSTEM_GDBINIT[0]) { - struct stat s; - int res = 0; - - if (stat (relocated_sysgdbinit, &s) == 0) + relocated_sysgdbinit = relocate_path (gdb_program_name, + SYSTEM_GDBINIT, + SYSTEM_GDBINIT_RELOCATABLE); + if (relocated_sysgdbinit && stat (relocated_sysgdbinit, &s) == 0) sysgdbinit = relocated_sysgdbinit; else xfree (relocated_sysgdbinit); } -#endif homedir = getenv ("HOME"); @@ -289,73 +335,14 @@ captured_main (void *data) current_directory = gdb_dirbuf; /* 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; + gdb_sysroot = relocate_directory (argv[0], TARGET_SYSTEM_ROOT, + TARGET_SYSTEM_ROOT_RELOCATABLE); - if (res == 0) - { - xfree (gdb_sysroot); - gdb_sysroot = xstrdup (TARGET_SYSTEM_ROOT); - } - } - else - gdb_sysroot = xstrdup (TARGET_SYSTEM_ROOT); -#else - gdb_sysroot = xstrdup (TARGET_SYSTEM_ROOT); -#endif - - /* Canonicalize the sysroot path. */ - if (*gdb_sysroot) - { - char *canon_sysroot = lrealpath (gdb_sysroot); - if (canon_sysroot) - { - xfree (gdb_sysroot); - gdb_sysroot = canon_sysroot; - } - } + debug_file_directory = relocate_directory (argv[0], DEBUGDIR, + DEBUGDIR_RELOCATABLE); -#ifdef DEBUGDIR_RELOCATABLE - debug_file_directory = make_relative_prefix (argv[0], BINDIR, DEBUGDIR); - if (debug_file_directory) - { - struct stat s; - int res = 0; - - if (stat (debug_file_directory, &s) == 0) - if (S_ISDIR (s.st_mode)) - res = 1; - - if (res == 0) - { - xfree (debug_file_directory); - debug_file_directory = xstrdup (DEBUGDIR); - } - } - else - debug_file_directory = xstrdup (DEBUGDIR); -#else - debug_file_directory = xstrdup (DEBUGDIR); -#endif - - /* Canonicalize the debugfile path. */ - if (*debug_file_directory) - { - char *canon_debug = lrealpath (debug_file_directory); - if (canon_debug) - { - xfree (debug_file_directory); - debug_file_directory = canon_debug; - } - } + gdb_datadir = relocate_directory (argv[0], GDB_DATADIR, + GDB_DATADIR_RELOCATABLE); get_init_files (&system_gdbinit, &home_gdbinit, &local_gdbinit); diff --git a/gdb/top.c b/gdb/top.c index 3aff25f..5654535 100644 --- a/gdb/top.c +++ b/gdb/top.c @@ -1619,6 +1619,15 @@ Use \"on\" to enable the notification, and \"off\" to disable it."), 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); } void -- 1.6.0.6 ^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: Python pretty-printing [1/6] 2009-04-03 23:58 ` Tom Tromey @ 2009-04-04 3:30 ` Daniel Jacobowitz 2009-04-04 16:16 ` Tom Tromey 2009-04-04 9:10 ` Eli Zaretskii 1 sibling, 1 reply; 19+ messages in thread From: Daniel Jacobowitz @ 2009-04-04 3:30 UTC (permalink / raw) To: Tom Tromey; +Cc: gdb-patches On Fri, Apr 03, 2009 at 05:58:24PM -0600, Tom Tromey wrote: > While testing this I discovered that the relocatable directory code in > configure does not appear to actually work. This patch fixes this > problem. Could you expand on the problem? I can definitely say that it works; we use it every day. -- Daniel Jacobowitz CodeSourcery ^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: Python pretty-printing [1/6] 2009-04-04 3:30 ` Daniel Jacobowitz @ 2009-04-04 16:16 ` Tom Tromey 0 siblings, 0 replies; 19+ messages in thread From: Tom Tromey @ 2009-04-04 16:16 UTC (permalink / raw) To: gdb-patches >>>>> "Daniel" == Daniel Jacobowitz <drow@false.org> writes: Tom> While testing this I discovered that the relocatable directory code in Tom> configure does not appear to actually work. This patch fixes this Tom> problem. Daniel> Could you expand on the problem? I can definitely say that it works; Daniel> we use it every day. There's no bug -- I was confused. Sorry about that. Tom ^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: Python pretty-printing [1/6] 2009-04-03 23:58 ` Tom Tromey 2009-04-04 3:30 ` Daniel Jacobowitz @ 2009-04-04 9:10 ` Eli Zaretskii 2009-04-06 17:45 ` Tom Tromey 1 sibling, 1 reply; 19+ messages in thread From: Eli Zaretskii @ 2009-04-04 9:10 UTC (permalink / raw) To: Tom Tromey; +Cc: gdb-patches > From: Tom Tromey <tromey@redhat.com> > Date: Fri, 03 Apr 2009 17:58:24 -0600 > > (As I mentioned before, I plan to document "set data-directory" in a > later patch -- unless, Eli, there is an existing node where you want > this to appear.) Looks like a new node under "GDB Files" is in order. I don't see a better place in any existing node. Thanks. ^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: Python pretty-printing [1/6] 2009-04-04 9:10 ` Eli Zaretskii @ 2009-04-06 17:45 ` Tom Tromey 2009-04-06 20:38 ` Eli Zaretskii 2009-04-07 18:52 ` Daniel Jacobowitz 0 siblings, 2 replies; 19+ messages in thread From: Tom Tromey @ 2009-04-06 17:45 UTC (permalink / raw) To: Eli Zaretskii; +Cc: gdb-patches >>>>> "Eli" == Eli Zaretskii <eliz@gnu.org> writes: Eli> Looks like a new node under "GDB Files" is in order. I don't see a Eli> better place in any existing node. Here is an updated patch. Tom 2009-04-06 Sergio Durigan Junior <sergiodj@linux.vnet.ibm.com> Tom Tromey <tromey@redhat.com> * 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-06 Tom Tromey <tromey@redhat.com> * gdb.texinfo (Data Files): New node. (GDB Files): Update menu. diff --git a/gdb/README b/gdb/README index cc16ecd..868cbb5 100644 --- a/gdb/README +++ b/gdb/README @@ -436,6 +436,11 @@ prefer; but you may abbreviate option names if you use `--'. Same as `--host=HOST'. If you omit this, GDB will guess; it's quite accurate. +`--with-gdb-datadir=PATH' + 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. diff --git a/gdb/acinclude.m4 b/gdb/acinclude.m4 index 5e77230..cdf8015 100644 --- a/gdb/acinclude.m4 +++ b/gdb/acinclude.m4 @@ -387,3 +387,38 @@ AC_DEFUN([CY_AC_TK_PRIVATE_HEADERS], [ 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][=PATH], [$3]), [ + [$1]=$withval], [[$1]=[$4]]) + AC_DEFINE_DIR([$1], [$1], [$3]) + AC_SUBST([$1]) + if test "x$exec_prefix" = xNONE || test "x$exec_prefix" = 'x${prefix}'; then + if test "x$prefix" = xNONE; then + test_prefix=/usr/local + else + test_prefix=$prefix + fi + else + test_prefix=$exec_prefix + fi + value=0 + case ${ac_define_dir} in + "${test_prefix}"|"${test_prefix}/"*|\ + '${exec_prefix}'|'${exec_prefix}/'*) + value=1 + ;; + esac + AC_DEFINE_UNQUOTED([$1]_RELOCATABLE, $value, [Define if the $2 directory should be relocated when GDB is moved.]) + ]) diff --git a/gdb/configure.ac b/gdb/configure.ac index 821dffe..05dcd9b 100644 --- a/gdb/configure.ac +++ b/gdb/configure.ac @@ -92,31 +92,16 @@ AC_SUBST(PACKAGE) # generate its Makefile.in. AM_INIT_AUTOMAKE(gdb, UNUSED-VERSION, [no-define]) -debugdir=${libdir}/debug - -AC_ARG_WITH(separate-debug-dir, -[ --with-separate-debug-dir=path Look for global separate debug info in this path [LIBDIR/debug]], -[debugdir="${withval}"]) - -AC_DEFINE_DIR(DEBUGDIR, debugdir, - [Global directory for separate debug files. ]) -#AC_DEFINE_UNQUOTED(DEBUGDIR, "$debugdir"), - -if test "x$exec_prefix" = xNONE || test "x$exec_prefix" = 'x${prefix}'; then - if test "x$prefix" = xNONE; then - test_prefix=/usr/local - else - test_prefix=$prefix - fi -else - test_prefix=$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]) + AC_CONFIG_SUBDIRS(doc testsuite) @@ -1474,6 +1459,7 @@ fi dnl Handle optional features that can be enabled. +target_sysroot_reloc=0 AC_ARG_WITH(sysroot, [ --with-sysroot[=DIR] Search for usr/lib et al within DIR.], [ @@ -1499,44 +1485,20 @@ AC_ARG_WITH(sysroot, "${test_exec_prefix}"|"${test_exec_prefix}/"*|\ '${prefix}'|'${prefix}/'*|\ '${exec_prefix}'|'${exec_prefix}/'*) - t="$TARGET_SYSTEM_ROOT_DEFINE -DTARGET_SYSTEM_ROOT_RELOCATABLE" - TARGET_SYSTEM_ROOT_DEFINE="$t" + target_sysroot_reloc=1 ;; esac ], [ TARGET_SYSTEM_ROOT= TARGET_SYSTEM_ROOT_DEFINE='-DTARGET_SYSTEM_ROOT=\"\"' ]) +TARGET_SYSTEM_ROOT_DEFINE="$TARGET_SYSTEM_ROOT_DEFINE -DTARGET_SYSTEM_ROOT_RELOCATABLE=$target_sysroot_reloc" AC_SUBST(TARGET_SYSTEM_ROOT) AC_SUBST(TARGET_SYSTEM_ROOT_DEFINE) -system_gdbinit= -AC_ARG_WITH(system-gdbinit, -[ --with-system-gdbinit=file Automatically load a system-wide gdbinit file], -[system_gdbinit=${withval}]) - -AC_DEFINE_DIR(SYSTEM_GDBINIT, system_gdbinit, - [System-wide gdbinit file.]) - -if test "x$prefix" = xNONE; then - test_prefix=$ac_default_prefix -else - test_prefix=$prefix -fi -if test "x$exec_prefix" = xNONE || test "x$exec_prefix" = 'x${prefix}'; then - test_exec_prefix=$test_prefix -else - test_exec_prefix=$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 when GDB is moved.]) - ;; -esac +GDB_AC_WITH_DIR(SYSTEM_GDBINIT, system-gdbinit, + [Automatically load a system-wide gdbinit file], + []) AC_ARG_ENABLE(werror, [ --enable-werror treat compile warnings as errors], diff --git a/gdb/defs.h b/gdb/defs.h index 882a844..ee80659 100644 --- a/gdb/defs.h +++ b/gdb/defs.h @@ -153,6 +153,9 @@ extern int dbx_commands; /* System root path, used to find libraries etc. */ extern char *gdb_sysroot; +/* GDB datadir, used to store data files. */ +extern char *gdb_datadir; + /* Search path for separate debug files. */ extern char *debug_file_directory; diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo index 0dff6e0..dd26db8 100644 --- a/gdb/doc/gdb.texinfo +++ b/gdb/doc/gdb.texinfo @@ -12646,6 +12646,7 @@ program. To debug a core dump of a previous run, you must also tell * 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 @node Files @@ -13480,6 +13481,36 @@ it. @end table +@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 diff --git a/gdb/main.c b/gdb/main.c index 5d4640b..edfea30 100644 --- a/gdb/main.c +++ b/gdb/main.c @@ -62,6 +62,9 @@ int dbx_commands = 0; /* System root path, used to find libraries etc. */ char *gdb_sysroot = 0; +/* GDB datadir, used to store data files. */ +char *gdb_datadir = 0; + struct ui_file *gdb_stdout; struct ui_file *gdb_stderr; struct ui_file *gdb_stdlog; @@ -93,6 +96,57 @@ static void print_gdb_help (struct ui_file *); extern char *external_editor_command; +/* 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 = relocate_path (progname, initial, flag); + if (dir) + { + struct stat s; + + if (stat (dir, &s) != 0 || !S_ISDIR (s.st_mode)) + { + xfree (dir); + dir = NULL; + } + } + if (!dir) + dir = xstrdup (initial); + + /* Canonicalize the directory. */ + if (*dir) + { + char *canon_sysroot = lrealpath (dir); + if (canon_sysroot) + { + xfree (dir); + dir = 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 no system gdbinit (resp. home gdbinit and local gdbinit) to be loaded, @@ -113,24 +167,16 @@ get_init_files (char **system_gdbinit, struct stat homebuf, cwdbuf, s; char *homedir, *relocated_sysgdbinit; - sysgdbinit = SYSTEM_GDBINIT; - if (!sysgdbinit [0] || stat (sysgdbinit, &s) != 0) - sysgdbinit = NULL; - -#ifdef SYSTEM_GDBINIT_RELOCATABLE - relocated_sysgdbinit = make_relative_prefix (gdb_program_name, BINDIR, - SYSTEM_GDBINIT); - if (relocated_sysgdbinit) + if (SYSTEM_GDBINIT[0]) { - struct stat s; - int res = 0; - - if (stat (relocated_sysgdbinit, &s) == 0) + relocated_sysgdbinit = relocate_path (gdb_program_name, + SYSTEM_GDBINIT, + SYSTEM_GDBINIT_RELOCATABLE); + if (relocated_sysgdbinit && stat (relocated_sysgdbinit, &s) == 0) sysgdbinit = relocated_sysgdbinit; else xfree (relocated_sysgdbinit); } -#endif homedir = getenv ("HOME"); @@ -289,73 +335,14 @@ captured_main (void *data) current_directory = gdb_dirbuf; /* 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; + gdb_sysroot = relocate_directory (argv[0], TARGET_SYSTEM_ROOT, + TARGET_SYSTEM_ROOT_RELOCATABLE); - if (res == 0) - { - xfree (gdb_sysroot); - gdb_sysroot = xstrdup (TARGET_SYSTEM_ROOT); - } - } - else - gdb_sysroot = xstrdup (TARGET_SYSTEM_ROOT); -#else - gdb_sysroot = xstrdup (TARGET_SYSTEM_ROOT); -#endif - - /* Canonicalize the sysroot path. */ - if (*gdb_sysroot) - { - char *canon_sysroot = lrealpath (gdb_sysroot); - if (canon_sysroot) - { - xfree (gdb_sysroot); - gdb_sysroot = canon_sysroot; - } - } + debug_file_directory = relocate_directory (argv[0], DEBUGDIR, + DEBUGDIR_RELOCATABLE); -#ifdef DEBUGDIR_RELOCATABLE - debug_file_directory = make_relative_prefix (argv[0], BINDIR, DEBUGDIR); - if (debug_file_directory) - { - struct stat s; - int res = 0; - - if (stat (debug_file_directory, &s) == 0) - if (S_ISDIR (s.st_mode)) - res = 1; - - if (res == 0) - { - xfree (debug_file_directory); - debug_file_directory = xstrdup (DEBUGDIR); - } - } - else - debug_file_directory = xstrdup (DEBUGDIR); -#else - debug_file_directory = xstrdup (DEBUGDIR); -#endif - - /* Canonicalize the debugfile path. */ - if (*debug_file_directory) - { - char *canon_debug = lrealpath (debug_file_directory); - if (canon_debug) - { - xfree (debug_file_directory); - debug_file_directory = canon_debug; - } - } + gdb_datadir = relocate_directory (argv[0], GDB_DATADIR, + GDB_DATADIR_RELOCATABLE); get_init_files (&system_gdbinit, &home_gdbinit, &local_gdbinit); diff --git a/gdb/top.c b/gdb/top.c index 3aff25f..5654535 100644 --- a/gdb/top.c +++ b/gdb/top.c @@ -1619,6 +1619,15 @@ Use \"on\" to enable the notification, and \"off\" to disable it."), 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); } void ^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: Python pretty-printing [1/6] 2009-04-06 17:45 ` Tom Tromey @ 2009-04-06 20:38 ` Eli Zaretskii 2009-04-07 18:52 ` Daniel Jacobowitz 1 sibling, 0 replies; 19+ messages in thread From: Eli Zaretskii @ 2009-04-06 20:38 UTC (permalink / raw) To: Tom Tromey; +Cc: gdb-patches > Cc: gdb-patches@sourceware.org > From: Tom Tromey <tromey@redhat.com> > Date: Mon, 06 Apr 2009 11:45:17 -0600 > > >>>>> "Eli" == Eli Zaretskii <eliz@gnu.org> writes: > > Eli> Looks like a new node under "GDB Files" is in order. I don't see a > Eli> better place in any existing node. > > Here is an updated patch. Thanks, the patch for the manual is approved. ^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: Python pretty-printing [1/6] 2009-04-06 17:45 ` Tom Tromey 2009-04-06 20:38 ` Eli Zaretskii @ 2009-04-07 18:52 ` Daniel Jacobowitz 1 sibling, 0 replies; 19+ messages in thread From: Daniel Jacobowitz @ 2009-04-07 18:52 UTC (permalink / raw) To: Tom Tromey; +Cc: Eli Zaretskii, gdb-patches On Mon, Apr 06, 2009 at 11:45:17AM -0600, Tom Tromey wrote: > >>>>> "Eli" == Eli Zaretskii <eliz@gnu.org> writes: > > Eli> Looks like a new node under "GDB Files" is in order. I don't see a > Eli> better place in any existing node. > > Here is an updated patch. Thank you. I'm happy with this patch! -- Daniel Jacobowitz CodeSourcery ^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: Python pretty-printing [1/6] 2009-04-02 20:54 Python pretty-printing [1/6] Tom Tromey ` (2 preceding siblings ...) 2009-04-03 23:58 ` Tom Tromey @ 2009-04-07 18:24 ` Joel Brobecker 2009-04-07 18:43 ` Tom Tromey 3 siblings, 1 reply; 19+ messages in thread From: Joel Brobecker @ 2009-04-07 18:24 UTC (permalink / raw) To: Tom Tromey; +Cc: gdb-patches Hi Tom, I hope this isn't too late a review to bring this up. I looked at this series of patches last Friday, but I didn't have an internet connection back then. > 2009-01-25 Sergio Durigan Junior <sergiodj@linux.vnet.ibm.com> > Tom Tromey <tromey@redhat.com> > > * configure, config.in: Regenerate. > * configure.ac: Support for relocatable GDB datadir. Add > --with-pythondir. > * python/python.c (_initialize_python): Set pythondir or datadir > as needed. Update sys.path. > * maint.c (_initialize_maint_cmds): Add "maint set gdb_datadir". > * defs.h (gdb_datadir): Declare. > * main.c (gdb_datadir): New global. > (captured_main): Initialize gdb_datadir. I'm wondering whether we could implement this slightly differently. Right now, this patch adds code that is conditional on wether some macros are defined or not. For instance: > +#ifdef PYTHONDIR > + PyModule_AddStringConstant (gdb_module, "pythondir", PYTHONDIR); > +#else > + if (gdb_datadir) > + PyModule_AddStringConstant (gdb_module, "datadir", gdb_datadir); > +#endif Can we change that, for instance by assuming that we always have PYTHONDIR, and that by default, configure will set to the datadir? I was going to comment on the ..._RELOCATABLE macro, but I see that we're already using that idiom for at least the system gdbinit file. -- Joel ^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: Python pretty-printing [1/6] 2009-04-07 18:24 ` Joel Brobecker @ 2009-04-07 18:43 ` Tom Tromey 0 siblings, 0 replies; 19+ messages in thread From: Tom Tromey @ 2009-04-07 18:43 UTC (permalink / raw) To: Joel Brobecker; +Cc: gdb-patches >>>>> "Joel" == Joel Brobecker <brobecker@adacore.com> writes: >> +#ifdef PYTHONDIR >> + PyModule_AddStringConstant (gdb_module, "pythondir", PYTHONDIR); >> +#else >> + if (gdb_datadir) >> + PyModule_AddStringConstant (gdb_module, "datadir", gdb_datadir); >> +#endif Joel> Can we change that, for instance by assuming that we always have Joel> PYTHONDIR, and that by default, configure will set to the datadir? This code is gone from the latest revision of the patch. We don't actually need the pythondir stuff until we have a library of Python code installed with gdb, and this patch series doesn't add that. But, yes, I think we can clean this up when the time comes. Joel> I was going to comment on the ..._RELOCATABLE macro, but I see that Joel> we're already using that idiom for at least the system gdbinit file. Yeah. I cleaned all this up a bit in the latest patch as well. That is, I unified almost all of the cut-and-pasted code. Tom ^ permalink raw reply [flat|nested] 19+ messages in thread
end of thread, other threads:[~2009-04-07 18:52 UTC | newest] Thread overview: 19+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2009-04-02 20:54 Python pretty-printing [1/6] Tom Tromey 2009-04-03 14:23 ` Eli Zaretskii 2009-04-03 15:46 ` Tom Tromey 2009-04-03 17:13 ` Eli Zaretskii 2009-04-04 21:43 ` Thiago Jung Bauermann 2009-04-05 3:12 ` Eli Zaretskii 2009-04-03 18:29 ` Tom Tromey 2009-04-03 19:14 ` Daniel Jacobowitz 2009-04-03 20:39 ` Tom Tromey 2009-04-03 15:23 ` Daniel Jacobowitz 2009-04-03 23:58 ` Tom Tromey 2009-04-04 3:30 ` Daniel Jacobowitz 2009-04-04 16:16 ` Tom Tromey 2009-04-04 9:10 ` Eli Zaretskii 2009-04-06 17:45 ` Tom Tromey 2009-04-06 20:38 ` Eli Zaretskii 2009-04-07 18:52 ` Daniel Jacobowitz 2009-04-07 18:24 ` Joel Brobecker 2009-04-07 18:43 ` Tom Tromey
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox