public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [RFC] New option -B: simplify running gdb from build directory
@ 2013-12-27 19:42 Doug Evans
  2013-12-27 19:54 ` Doug Evans
                   ` (2 more replies)
  0 siblings, 3 replies; 14+ messages in thread
From: Doug Evans @ 2013-12-27 19:42 UTC (permalink / raw)
  To: gdb-patches

Hi.

The "make run" Makefile rule simplifies running gdb from the shell,
but it doesn't simplify running gdb from gdb: I'm always typing
"--data-directory=$(pwd)/data-directory".
And since we can't agree on a way to let gdb auto-detect being run
from the build directory, how about this?

This patch provides a new option, -B, which if provided tells gdb
it *may* have been run from the build directory.  If -B was provided
and --data-directory was not provided, use a heuristic to determine
if gdb was run from the build directory and if so set gdb_datadir
appropriately.

We can certainly discuss what's the best heuristic to use here.
We don't, IMO, have to employ too complicated a heuristic because
the user has explicitly passed -B.
OTOH, I'm sure one can improve a bit on the heuristic that's here.
One thought I have is to have the Makefile create a file with a name that
is reasonably obscure (maybe even pseudo-cryptographically secure and encode
the name in gdb?), and then simplify the test by just checking for that file.

If we can agree on this approach, I'll add NEWS and docs.

2013-12-27  Doug Evans  <dje@google.com>

	* main.c (maybe_run_from_builddir): New global.
	(get_builddir): New function.
	(captured_main): New option enum OPT_BATCH_SILENT, use it for
	--batch-silent instead of 'B'.  Add option -B: If -B is provided
	and --data-directory is not, see if being run from build directory
	and use that for gdb_datadir if so.

diff --git a/gdb/main.c b/gdb/main.c
index 7ff9183..7fa4168 100644
--- a/gdb/main.c
+++ b/gdb/main.c
@@ -58,6 +58,9 @@ int xdb_commands = 0;
 /* Whether dbx commands will be handled.  */
 int dbx_commands = 0;
 
+/* Whether GDB may have been run from the build directory.  */
+static int maybe_run_from_builddir = 0;
+
 /* System root path, used to find libraries etc.  */
 char *gdb_sysroot = 0;
 
@@ -161,6 +164,52 @@ relocate_gdb_directory (const char *initial, int flag)
   return dir;
 }
 
+/* Return the directory gdb was run from if we can reasonably determine that
+   it was the build directory, otherwise return NULL.
+   Space for the builddir is obtained with malloc, caller must free.
+
+   We say "reasonably" because gdb *could* be run from a place that *looks*
+   like the build directory, and we want to avoid false positives as much as
+   is reasonably possible.  This code is only used if the user passes -B to
+   gdb so our tests needn't be *perfect*.
+
+   The test is done by seeing if various files exist that we expect to find
+   in a build directory.  There are a few constraints on our choices:
+
+   1) We don't test for object files so that we don't have to deal with the
+      complexity of different suffixes (e.g., .o vs .obj).
+   2) If the file got removed for whatever reason the developer might choose,
+      does that break using gdb?  E.g., we could test for config.status or
+      some such, or deal with the complexity of different objfile suffixes,
+      but the file's absence doesn't actually break using gdb from the
+      build directory.
+   3) We can't test for files that only exist for a particular configuration.
+
+   In the end the files we choose are files in data-directory since those
+   files are needed by gdb, plus files that typically only exist in the
+   build tree: stamp-syscalls and gdb-syscalls.dtd.  */
+
+static char *
+get_builddir (void)
+{
+  char *gdb_dirname = ldirname (gdb_program_name);
+  char *datadir = xstrprintf ("%s/data-directory", gdb_dirname);
+  char *test_file1 = xstrprintf ("%s/stamp-syscalls", datadir);
+  char *test_file2 = xstrprintf ("%s/syscalls/gdb-syscalls.dtd", datadir);
+  int builddir_found;
+
+  builddir_found = (access (test_file1, R_OK) == 0
+		    && access (test_file2, R_OK) == 0);
+  xfree (gdb_dirname);
+  xfree (test_file1);
+  xfree (test_file2);
+
+  if (builddir_found)
+    return datadir;
+  xfree (datadir);
+  return NULL;
+}
+
 /* 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)
@@ -462,7 +511,8 @@ captured_main (void *data)
       OPT_NOWINDOWS,
       OPT_WINDOWS,
       OPT_IX,
-      OPT_IEX
+      OPT_IEX,
+      OPT_BATCH_SILENT
     };
     static struct option long_options[] =
     {
@@ -477,7 +527,7 @@ captured_main (void *data)
       {"nh", no_argument, &inhibit_home_gdbinit, 1},
       {"nx", no_argument, &inhibit_gdbinit, 1},
       {"n", no_argument, &inhibit_gdbinit, 1},
-      {"batch-silent", no_argument, 0, 'B'},
+      {"batch-silent", no_argument, 0, OPT_BATCH_SILENT},
       {"batch", no_argument, &batch_flag, 1},
 
     /* This is a synonym for "--annotate=1".  --annotate is now
@@ -531,6 +581,7 @@ captured_main (void *data)
       {"args", no_argument, &set_args, 1},
       {"l", required_argument, 0, 'l'},
       {"return-child-result", no_argument, &return_child_result, 1},
+      {"B", no_argument, &maybe_run_from_builddir, 1},
       {0, no_argument, 0, 0}
     };
 
@@ -642,7 +693,7 @@ captured_main (void *data)
 	      VEC_safe_push (cmdarg_s, cmdarg_vec, &cmdarg);
 	    }
 	    break;
-	  case 'B':
+	  case OPT_BATCH_SILENT:
 	    batch_flag = batch_silent = 1;
 	    gdb_stdout = ui_file_new();
 	    break;
@@ -755,6 +806,19 @@ captured_main (void *data)
       quiet = 1;
   }
 
+  /* If -B was provided and --data-directory was not, then see if we have been
+     run from the build directory and if so use the data-directory there.  */
+  if (maybe_run_from_builddir && !gdb_datadir_provided)
+    {
+      char *builddir = get_builddir ();
+
+      if (builddir != NULL)
+	{
+	  xfree (gdb_datadir);
+	  gdb_datadir = builddir;
+	}
+    }
+
   /* Initialize all files.  Give the interpreter a chance to take
      control of the console via the deprecated_init_ui_hook ().  */
   gdb_init (gdb_program_name);

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [RFC] New option -B: simplify running gdb from build directory
  2013-12-27 19:42 [RFC] New option -B: simplify running gdb from build directory Doug Evans
@ 2013-12-27 19:54 ` Doug Evans
  2013-12-27 20:15 ` Eli Zaretskii
  2014-03-06 21:41 ` [PATCH, doc RFA] " Doug Evans
  2 siblings, 0 replies; 14+ messages in thread
From: Doug Evans @ 2013-12-27 19:54 UTC (permalink / raw)
  To: gdb-patches

On Fri, Dec 27, 2013 at 11:42 AM, Doug Evans <dje@google.com> wrote:
> Hi.
>
> The "make run" Makefile rule simplifies running gdb from the shell,
> but it doesn't simplify running gdb from gdb: I'm always typing
> "--data-directory=$(pwd)/data-directory".
> And since we can't agree on a way to let gdb auto-detect being run
> from the build directory, how about this?
>
> This patch provides a new option, -B, which if provided tells gdb
> it *may* have been run from the build directory.  If -B was provided
> and --data-directory was not provided, use a heuristic to determine
> if gdb was run from the build directory and if so set gdb_datadir
> appropriately.
>
> We can certainly discuss what's the best heuristic to use here.
> We don't, IMO, have to employ too complicated a heuristic because
> the user has explicitly passed -B.
> OTOH, I'm sure one can improve a bit on the heuristic that's here.
> One thought I have is to have the Makefile create a file with a name that
> is reasonably obscure (maybe even pseudo-cryptographically secure and encode
> the name in gdb?), and then simplify the test by just checking for that file.
>
> If we can agree on this approach, I'll add NEWS and docs.
>
> 2013-12-27  Doug Evans  <dje@google.com>
>
>         * main.c (maybe_run_from_builddir): New global.
>         (get_builddir): New function.
>         (captured_main): New option enum OPT_BATCH_SILENT, use it for
>         --batch-silent instead of 'B'.  Add option -B: If -B is provided
>         and --data-directory is not, see if being run from build directory
>         and use that for gdb_datadir if so.

Blech, I shouldn't assume gdb_program_name is an absolute path.  I'll
fix that in the next revision.

[OTOH, the caller could be the one to ensure gdb_datadir is an
absolute path since we don't do that yet if a relative path is passed
to --data-directory.]

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [RFC] New option -B: simplify running gdb from build directory
  2013-12-27 19:42 [RFC] New option -B: simplify running gdb from build directory Doug Evans
  2013-12-27 19:54 ` Doug Evans
@ 2013-12-27 20:15 ` Eli Zaretskii
  2013-12-27 20:51   ` Doug Evans
  2014-03-06 21:41 ` [PATCH, doc RFA] " Doug Evans
  2 siblings, 1 reply; 14+ messages in thread
From: Eli Zaretskii @ 2013-12-27 20:15 UTC (permalink / raw)
  To: Doug Evans; +Cc: gdb-patches

> From: Doug Evans <dje@google.com>
> Date: Fri, 27 Dec 2013 11:42:29 -0800
> 
> The "make run" Makefile rule simplifies running gdb from the shell,
> but it doesn't simplify running gdb from gdb: I'm always typing
> "--data-directory=$(pwd)/data-directory".
> And since we can't agree on a way to let gdb auto-detect being run
> from the build directory, how about this?

Thanks.

However, if we cannot agree on the above, why would adding a new
option facilitate agreement?

Personally, this way of solving the issue makes little sense to me: if
I need to specify a special option to GDB, I can be expected to
specify --data-directory explicitly.

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [RFC] New option -B: simplify running gdb from build directory
  2013-12-27 20:15 ` Eli Zaretskii
@ 2013-12-27 20:51   ` Doug Evans
  0 siblings, 0 replies; 14+ messages in thread
From: Doug Evans @ 2013-12-27 20:51 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: gdb-patches

On Fri, Dec 27, 2013 at 12:15 PM, Eli Zaretskii <eliz@gnu.org> wrote:
>> From: Doug Evans <dje@google.com>
>> Date: Fri, 27 Dec 2013 11:42:29 -0800
>>
>> The "make run" Makefile rule simplifies running gdb from the shell,
>> but it doesn't simplify running gdb from gdb: I'm always typing
>> "--data-directory=$(pwd)/data-directory".
>> And since we can't agree on a way to let gdb auto-detect being run
>> from the build directory, how about this?
>
> Thanks.
>
> However, if we cannot agree on the above, why would adding a new
> option facilitate agreement?

It's a different question.
This proposal is different: It's suggesting having the user pass an
explicit option as opposed to gdb automagically deciding

> Personally, this way of solving the issue makes little sense to me: if
> I need to specify a special option to GDB, I can be expected to
> specify --data-directory explicitly.

-B is a lot less to type than --data-directory=$(pwd)/data-directory.
It's a convenience option.
Note that we already do similar kinds of things. e.g. -x,-ex,-ix,-iex
vs --command,--eval-command,--init-command,--init-eval-command.

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [PATCH, doc RFA] New option -B: simplify running gdb from build directory
  2013-12-27 19:42 [RFC] New option -B: simplify running gdb from build directory Doug Evans
  2013-12-27 19:54 ` Doug Evans
  2013-12-27 20:15 ` Eli Zaretskii
@ 2014-03-06 21:41 ` Doug Evans
  2014-03-07  7:10   ` Eli Zaretskii
  2 siblings, 1 reply; 14+ messages in thread
From: Doug Evans @ 2014-03-06 21:41 UTC (permalink / raw)
  To: gdb-patches, eliz

Doug Evans writes:
 > Hi.
 > 
 > The "make run" Makefile rule simplifies running gdb from the shell,
 > but it doesn't simplify running gdb from gdb: I'm always typing
 > "--data-directory=$(pwd)/data-directory".
 > And since we can't agree on a way to let gdb auto-detect being run
 > from the build directory, how about this?
 > 
 > This patch provides a new option, -B, which if provided tells gdb
 > it *may* have been run from the build directory.  If -B was provided
 > and --data-directory was not provided, use a heuristic to determine
 > if gdb was run from the build directory and if so set gdb_datadir
 > appropriately.
 > 
 > We can certainly discuss what's the best heuristic to use here.
 > We don't, IMO, have to employ too complicated a heuristic because
 > the user has explicitly passed -B.
 > OTOH, I'm sure one can improve a bit on the heuristic that's here.
 > One thought I have is to have the Makefile create a file with a name that
 > is reasonably obscure (maybe even pseudo-cryptographically secure and encode
 > the name in gdb?), and then simplify the test by just checking for that file.
 > 
 > If we can agree on this approach, I'll add NEWS and docs.

I believe I've addressed Eli's comments,
[ref: https://sourceware.org/ml/gdb-patches/2013-12/msg00969.html]
and I didn't see any other discussion, so here's the patch.

2014-03-06  Doug Evans  <dje@google.com>

	New option -B.
	* NEWS: Mention it.
	* main.c (maybe_run_from_builddir): New static global.
	(get_build_data_directory): New function.
	(captured_main): New enum value OPT_BATCH_SILENT.  Use it instead of
	'B' for --batch-silent.  Recognize and handle -B option.

	doc/
	* gdb.texinfo (Mode Options): Document -B.

	testsuite/
	* gdb.base/dash-b.exp: New file.

diff --git a/gdb/NEWS b/gdb/NEWS
index 2a384ba..a1561e7 100644
--- a/gdb/NEWS
+++ b/gdb/NEWS
@@ -3,6 +3,11 @@
 
 *** Changes since GDB 7.7
 
+* New command line options:
+
+-B  Indicates GDB may have been run from its build directory, and GDB
+    should first look for its ancillary files there.
+
 * Guile scripting
 
   GDB now has support for scripting using Guile.  Whether this is
diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo
index de5ac63..ab6a643 100644
--- a/gdb/doc/gdb.texinfo
+++ b/gdb/doc/gdb.texinfo
@@ -1169,6 +1169,18 @@ Run @value{GDBN} using @var{directory} as its data directory.
 The data directory is where @value{GDBN} searches for its
 auxiliary files.  @xref{Data Files}.
 
+@item -B
+@cindex @code{-B}
+This option tells @value{GDBN} it may have been run from its build directory,
+and it should first look for its auxiliary files there.  @xref{Data Files}.
+If @value{GDBN} cannot determine it has been run from its build directory,
+then it will expect to find its auxiliary files in their installed
+location as specified by the @code{--prefix} option when @value{GDBN} was
+configured.
+
+This option is ignored if the data directory has been explicitly specified
+with @code{--data-directory}.
+
 @item -fullname
 @itemx -f
 @cindex @code{--fullname}
diff --git a/gdb/main.c b/gdb/main.c
index 59015f5..536f9b7 100644
--- a/gdb/main.c
+++ b/gdb/main.c
@@ -57,6 +57,9 @@ int xdb_commands = 0;
 /* Whether dbx commands will be handled.  */
 int dbx_commands = 0;
 
+/* Whether GDB may have been run from the build directory.  */
+static int maybe_run_from_builddir = 0;
+
 /* System root path, used to find libraries etc.  */
 char *gdb_sysroot = 0;
 
@@ -160,6 +163,60 @@ relocate_gdb_directory (const char *initial, int flag)
   return dir;
 }
 
+/* Return the path of the data directory in the build tree if we can
+   reasonably determine that gdb was run from the build directory.
+   Otherwise return NULL.
+   Space for the result is obtained with malloc, caller must free.
+
+   We say "reasonably" because gdb *could* be run from a place that *looks*
+   like the build directory, and we want to avoid false positives as much as
+   is reasonably possible.  This code is only used if the user passes -B to
+   gdb so our tests needn't be *perfect*.
+
+   The test is done by seeing if various files that we expect to find in a
+   build directory exist.  There are a few constraints on our choices:
+
+   1) We don't test for object files so that we don't have to deal with the
+      complexity of different suffixes (e.g., .o vs .obj).
+   2) We can't (easily) test for files that only exist for a particular
+      configuration.
+
+   In the end we choose three files from the data-directory since it's the
+   data-directory that we need to find:
+   1) Makefile - only exists in build tree,
+   2) stamp-syscalls - only exists in build tree that has been built,
+   3) syscalls/amd64-linux.xml - gdb needs this
+      (installed regardless of platform so it doesn't matter if the current
+      platform is not amd64-linux).  */
+
+static char *
+get_build_data_directory (void)
+{
+  char *gdb_dirname = ldirname (gdb_program_name);
+  char *full_gdb_dirname = gdb_realpath (gdb_dirname);
+  char *datadir = concat (full_gdb_dirname, SLASH_STRING "data-directory",
+			  NULL);
+  char *test_file1 = concat (datadir, SLASH_STRING, "Makefile", NULL);
+  char *test_file2 = concat (datadir, SLASH_STRING, "stamp-syscalls", NULL);
+  char *test_file3 = concat (datadir, SLASH_STRING, "syscalls",
+			     SLASH_STRING, "amd64-linux.xml", NULL);
+  int builddir_found;
+
+  builddir_found = (access (test_file1, R_OK) == 0
+		    && access (test_file2, R_OK) == 0
+		    && access (test_file3, R_OK) == 0);
+  xfree (gdb_dirname);
+  xfree (full_gdb_dirname);
+  xfree (test_file1);
+  xfree (test_file2);
+  xfree (test_file3);
+
+  if (builddir_found)
+    return datadir;
+  xfree (datadir);
+  return NULL;
+}
+
 /* 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)
@@ -461,7 +518,8 @@ captured_main (void *data)
       OPT_NOWINDOWS,
       OPT_WINDOWS,
       OPT_IX,
-      OPT_IEX
+      OPT_IEX,
+      OPT_BATCH_SILENT
     };
     static struct option long_options[] =
     {
@@ -476,7 +534,7 @@ captured_main (void *data)
       {"nh", no_argument, &inhibit_home_gdbinit, 1},
       {"nx", no_argument, &inhibit_gdbinit, 1},
       {"n", no_argument, &inhibit_gdbinit, 1},
-      {"batch-silent", no_argument, 0, 'B'},
+      {"batch-silent", no_argument, 0, OPT_BATCH_SILENT},
       {"batch", no_argument, &batch_flag, 1},
 
     /* This is a synonym for "--annotate=1".  --annotate is now
@@ -530,6 +588,7 @@ captured_main (void *data)
       {"args", no_argument, &set_args, 1},
       {"l", required_argument, 0, 'l'},
       {"return-child-result", no_argument, &return_child_result, 1},
+      {"B", no_argument, &maybe_run_from_builddir, 1},
       {0, no_argument, 0, 0}
     };
 
@@ -636,7 +695,7 @@ captured_main (void *data)
 	      VEC_safe_push (cmdarg_s, cmdarg_vec, &cmdarg);
 	    }
 	    break;
-	  case 'B':
+	  case OPT_BATCH_SILENT:
 	    batch_flag = batch_silent = 1;
 	    gdb_stdout = ui_file_new();
 	    break;
@@ -742,6 +801,20 @@ captured_main (void *data)
       quiet = 1;
   }
 
+  /* If -B was provided and --data-directory was not, then see if we have been
+     run from the build directory and if so use the data-directory there.  */
+  if (maybe_run_from_builddir && !gdb_datadir_provided)
+    {
+      char *builddir = get_build_data_directory ();
+
+      if (builddir != NULL)
+	{
+	  xfree (gdb_datadir);
+	  gdb_datadir = builddir;
+	  gdb_datadir_provided = 1;
+	}
+    }
+
   /* Initialize all files.  Give the interpreter a chance to take
      control of the console via the deprecated_init_ui_hook ().  */
   gdb_init (gdb_program_name);
diff --git a/gdb/testsuite/gdb.base/dash-b.exp b/gdb/testsuite/gdb.base/dash-b.exp
new file mode 100644
index 0000000..24ac6f9
--- /dev/null
+++ b/gdb/testsuite/gdb.base/dash-b.exp
@@ -0,0 +1,34 @@
+# Copyright 2014 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
+
+# Test the -B option.
+# The test here needs to handle the case where gdb has already been installed,
+# in which case if -B isn't working probably the test might still pass whereas
+# it should fail.  The way we test this is to verify the value of the
+# "data-directory" parameter after gdb has started.
+
+set save_INTERNAL_GDBFLAGS $INTERNAL_GDBFLAGS
+set INTERNAL_GDBFLAGS "-nw -nx -B"
+
+gdb_exit
+gdb_start
+gdb_reinitialize_dir $srcdir/$subdir
+
+set normalized_objdir [file normalize $objdir]
+verbose -log "normalized objdir: $normalized_objdir"
+gdb_test "show data-directory" \
+    "GDB's data directory is \"[file dirname $normalized_objdir]/data-directory\"\."
+
+set INTERNAL_GDBFLAGS $save_INTERNAL_GDBFLAGS

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH, doc RFA] New option -B: simplify running gdb from build directory
  2014-03-06 21:41 ` [PATCH, doc RFA] " Doug Evans
@ 2014-03-07  7:10   ` Eli Zaretskii
       [not found]     ` <CADPb22RKaBx1p2vF4-wGODZVe-QqdGc93Ax-bD82xb9Adr5EJw@mail.gmail.com>
  0 siblings, 1 reply; 14+ messages in thread
From: Eli Zaretskii @ 2014-03-07  7:10 UTC (permalink / raw)
  To: Doug Evans; +Cc: gdb-patches

> From: Doug Evans <dje@google.com>
> Date: Thu, 6 Mar 2014 13:41:21 -0800
> 
> I believe I've addressed Eli's comments,
> [ref: https://sourceware.org/ml/gdb-patches/2013-12/msg00969.html]

No, I don't think you have.

> 2014-03-06  Doug Evans  <dje@google.com>
> 
> 	New option -B.
> 	* NEWS: Mention it.
> 	* main.c (maybe_run_from_builddir): New static global.
> 	(get_build_data_directory): New function.
> 	(captured_main): New enum value OPT_BATCH_SILENT.  Use it instead of
> 	'B' for --batch-silent.  Recognize and handle -B option.
> 
> 	doc/
> 	* gdb.texinfo (Mode Options): Document -B.
> 
> 	testsuite/
> 	* gdb.base/dash-b.exp: New file.

OK for the documentation parts.

Thanks.

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH, doc RFA] New option -B: simplify running gdb from build directory
       [not found]     ` <CADPb22RKaBx1p2vF4-wGODZVe-QqdGc93Ax-bD82xb9Adr5EJw@mail.gmail.com>
@ 2014-03-07 18:41       ` Eli Zaretskii
  2014-03-07 18:54         ` Doug Evans
  0 siblings, 1 reply; 14+ messages in thread
From: Eli Zaretskii @ 2014-03-07 18:41 UTC (permalink / raw)
  To: Doug Evans; +Cc: gdb-patches

> Date: Fri, 7 Mar 2014 09:37:28 -0800
> From: Doug Evans <dje@google.com>
> Cc: gdb-patches <gdb-patches@sourceware.org>
> 
> On Thu, Mar 6, 2014 at 11:10 PM, Eli Zaretskii <eliz@gnu.org> wrote:
> 
> > > From: Doug Evans <dje@google.com>
> > > Date: Thu, 6 Mar 2014 13:41:21 -0800
> > >
> > > I believe I've addressed Eli's comments,
> > > [ref: https://sourceware.org/ml/gdb-patches/2013-12/msg00969.html]
> >
> > No, I don't think you have.
> 
> That's not much to go on. :-)

"Address the comments" in my book means to make changes to accommodate
those comments.  In contrast, what you did was express your
disagreement with my comments.  That doesn't seem to fit the bill.

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH, doc RFA] New option -B: simplify running gdb from build directory
  2014-03-07 18:41       ` Eli Zaretskii
@ 2014-03-07 18:54         ` Doug Evans
  2014-03-25  1:02           ` Doug Evans
  0 siblings, 1 reply; 14+ messages in thread
From: Doug Evans @ 2014-03-07 18:54 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: gdb-patches

On Fri, Mar 7, 2014 at 10:41 AM, Eli Zaretskii <eliz@gnu.org> wrote:
>> Date: Fri, 7 Mar 2014 09:37:28 -0800
>> From: Doug Evans <dje@google.com>
>> Cc: gdb-patches <gdb-patches@sourceware.org>
>>
>> On Thu, Mar 6, 2014 at 11:10 PM, Eli Zaretskii <eliz@gnu.org> wrote:
>>
>> > > From: Doug Evans <dje@google.com>
>> > > Date: Thu, 6 Mar 2014 13:41:21 -0800
>> > >
>> > > I believe I've addressed Eli's comments,
>> > > [ref: https://sourceware.org/ml/gdb-patches/2013-12/msg00969.html]
>> >
>> > No, I don't think you have.
>>
>> That's not much to go on. :-)
>
> "Address the comments" in my book means to make changes to accommodate
> those comments.  In contrast, what you did was express your
> disagreement with my comments.  That doesn't seem to fit the bill.

Ah.  Definition mismatch..
I'll try to remember to phrase "Address the comments" differently next time.
Thanks.

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH, doc RFA] New option -B: simplify running gdb from build directory
  2014-03-07 18:54         ` Doug Evans
@ 2014-03-25  1:02           ` Doug Evans
  2014-03-25  1:20             ` Doug Evans
  0 siblings, 1 reply; 14+ messages in thread
From: Doug Evans @ 2014-03-25  1:02 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: gdb-patches

On Fri, Mar 7, 2014 at 10:54 AM, Doug Evans <dje@google.com> wrote:
> On Fri, Mar 7, 2014 at 10:41 AM, Eli Zaretskii <eliz@gnu.org> wrote:
>>> Date: Fri, 7 Mar 2014 09:37:28 -0800
>>> From: Doug Evans <dje@google.com>
>>> Cc: gdb-patches <gdb-patches@sourceware.org>
>>>
>>> On Thu, Mar 6, 2014 at 11:10 PM, Eli Zaretskii <eliz@gnu.org> wrote:
>>>
>>> > > From: Doug Evans <dje@google.com>
>>> > > Date: Thu, 6 Mar 2014 13:41:21 -0800
>>> > >
>>> > > I believe I've addressed Eli's comments,
>>> > > [ref: https://sourceware.org/ml/gdb-patches/2013-12/msg00969.html]
>>> >
>>> > No, I don't think you have.
>>>
>>> That's not much to go on. :-)
>>
>> "Address the comments" in my book means to make changes to accommodate
>> those comments.  In contrast, what you did was express your
>> disagreement with my comments.  That doesn't seem to fit the bill.
>
> Ah.  Definition mismatch..
> I'll try to remember to phrase "Address the comments" differently next time.
> Thanks.

Hi. I'm not sure where this patch stands.
I have OK for the documentation parts and I am a Global Maintainer.

I just want to stop having to type --data-directory all the time when
I run gdb under gdb in emacs (without doing hacks like having a
special emacs command just for debugging gdb).  It's unlikely ISTM the
community is going to agree on a heuristic for determining whether gdb
is being run from the build directory any time soon, so let's just let
it go for now.  Typing "./gdb -B" is fine by me.  I can think of
alternatives (eg., name the binary in the build directory as xgdb and
have gdb check argv[0]) but I prefer -B.

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH, doc RFA] New option -B: simplify running gdb from build directory
  2014-03-25  1:02           ` Doug Evans
@ 2014-03-25  1:20             ` Doug Evans
  2014-03-25  1:28               ` Doug Evans
  0 siblings, 1 reply; 14+ messages in thread
From: Doug Evans @ 2014-03-25  1:20 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: gdb-patches

On Mon, Mar 24, 2014 at 6:02 PM, Doug Evans <dje@google.com> wrote:
> I just want to stop having to type --data-directory all the time when
> I run gdb under gdb in emacs (without doing hacks like having a
> special emacs command just for debugging gdb).  It's unlikely ISTM the
> community is going to agree on a heuristic for determining whether gdb
> is being run from the build directory any time soon, so let's just let
> it go for now.  Typing "./gdb -B" is fine by me.  I can think of
> alternatives (eg., name the binary in the build directory as xgdb and
> have gdb check argv[0]) but I prefer -B.

Hah!  Gotta love the crystalization of thinking that happens after one
clicks Send.

For the moment running from the build directory only requires passing
--data-directory.
I'm going to add a -D shortcut for --data-directory and make gdb
expand out relative paths for data-directory (it's kinda a bug that it
doesn't now).

That way I can type ./gdb -D .
which is good enough. :-)

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH, doc RFA] New option -B: simplify running gdb from build directory
  2014-03-25  1:20             ` Doug Evans
@ 2014-03-25  1:28               ` Doug Evans
  2014-04-28 22:35                 ` [PATCH, doc RFA] New option -D: alias for --data-directory Doug Evans
  0 siblings, 1 reply; 14+ messages in thread
From: Doug Evans @ 2014-03-25  1:28 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: gdb-patches

On Mon, Mar 24, 2014 at 6:20 PM, Doug Evans <dje@google.com> wrote:
> On Mon, Mar 24, 2014 at 6:02 PM, Doug Evans <dje@google.com> wrote:
>> I just want to stop having to type --data-directory all the time when
>> I run gdb under gdb in emacs (without doing hacks like having a
>> special emacs command just for debugging gdb).  It's unlikely ISTM the
>> community is going to agree on a heuristic for determining whether gdb
>> is being run from the build directory any time soon, so let's just let
>> it go for now.  Typing "./gdb -B" is fine by me.  I can think of
>> alternatives (eg., name the binary in the build directory as xgdb and
>> have gdb check argv[0]) but I prefer -B.
>
> Hah!  Gotta love the crystalization of thinking that happens after one
> clicks Send.
>
> For the moment running from the build directory only requires passing
> --data-directory.
> I'm going to add a -D shortcut for --data-directory and make gdb
> expand out relative paths for data-directory (it's kinda a bug that it
> doesn't now).
>
> That way I can type ./gdb -D .
> which is good enough. :-)

Bleah.
That would have to be typed as ./gdb -D da<TAB>
or ../gdb -D ../da<TAB> if run from the testsuite directory
which maybe I can live with.

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [PATCH, doc RFA] New option -D: alias for --data-directory
  2014-03-25  1:28               ` Doug Evans
@ 2014-04-28 22:35                 ` Doug Evans
  2014-04-29  2:37                   ` Eli Zaretskii
  0 siblings, 1 reply; 14+ messages in thread
From: Doug Evans @ 2014-04-28 22:35 UTC (permalink / raw)
  To: Eli Zaretskii, gdb-patches

Hi Eli.
Doc RFA please. :-)

2014-04-28  Doug Evans  <dje@google.com>

	New command line option -D.
	* NEWS: Mention it.
	* main.c (set_gdb_data_directory): New function.
	(captured_main): Recognize -D.  Flag error for --data-directory "".
	Call set_gdb_data_directory.
	* main.h (set_gdb_data_directory): Declare.
	* top.c (staged_gdb_datadir): New static global.
	(set_gdb_datadir): Call set_gdb_data_directory
	(show_gdb_datadir): New function.
	(init_main): Update init of data-directory parameter.

	testsuite/
	* gdb.base/catch-syscall.exp (test_catch_syscall_fail_nodatadir):
	Update.
	(do_syscall_tests_without_xml): Update.

	doc/
	* gdb.texinfo (Mode Options): Add -D.

diff --git a/gdb/NEWS b/gdb/NEWS
index d0c44ea..00ec8b9 100644
--- a/gdb/NEWS
+++ b/gdb/NEWS
@@ -3,6 +3,11 @@
 
 *** Changes since GDB 7.7
 
+* New command line options
+
+-D data-directory
+  This is an alias for the --data-directory option.
+
 * GDB supports printing and modifying of variable length automatic arrays
   as specified in ISO C99.
 
diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo
index 9d91075..7795964 100644
--- a/gdb/doc/gdb.texinfo
+++ b/gdb/doc/gdb.texinfo
@@ -1164,7 +1164,9 @@ Run @value{GDBN} using @var{directory} as its working directory,
 instead of the current directory.
 
 @item -data-directory @var{directory}
+@itemx -D @var{directory}
 @cindex @code{--data-directory}
+@cindex @code{-D}
 Run @value{GDBN} using @var{directory} as its data directory.
 The data directory is where @value{GDBN} searches for its
 auxiliary files.  @xref{Data Files}.
diff --git a/gdb/main.c b/gdb/main.c
index 59015f5..9652cba 100644
--- a/gdb/main.c
+++ b/gdb/main.c
@@ -106,6 +106,41 @@ get_gdb_program_name (void)
 
 static void print_gdb_help (struct ui_file *);
 
+/* Set the data-directory parameter to NEW_DATADIR.
+   If NEW_DATADIR is not a directory then a warning is printed.
+   We don't signal an error for backward compatibility.  */
+
+void
+set_gdb_data_directory (const char *new_datadir)
+{
+  struct stat st;
+
+  if (stat (new_datadir, &st) < 0)
+    {
+      int save_errno = errno;
+
+      fprintf_unfiltered (gdb_stderr, "Warning: ");
+      print_sys_errmsg (new_datadir, save_errno);
+    }
+  else if (!S_ISDIR (st.st_mode))
+    warning (_("%s is not a directory."), new_datadir);
+
+  xfree (gdb_datadir);
+  gdb_datadir = gdb_realpath (new_datadir);
+
+  /* gdb_realpath won't return an absolute path if the path doesn't exist,
+     but we still want to record an absolute path here.  If the user entered
+     "../foo" and "../foo" doesn't exist then we'll record $(pwd)/../foo which
+     isn't canonical, but that's ok.  */
+  if (!IS_ABSOLUTE_PATH (gdb_datadir))
+    {
+      char *abs_datadir = gdb_abspath (gdb_datadir);
+
+      xfree (gdb_datadir);
+      gdb_datadir = abs_datadir;
+    }
+}
+
 /* 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
@@ -517,6 +552,7 @@ captured_main (void *data)
       {"directory", required_argument, 0, 'd'},
       {"d", required_argument, 0, 'd'},
       {"data-directory", required_argument, 0, 'D'},
+      {"D", required_argument, 0, 'D'},
       {"cd", required_argument, 0, OPT_CD},
       {"tty", required_argument, 0, 't'},
       {"baud", required_argument, 0, 'b'},
@@ -641,8 +677,15 @@ captured_main (void *data)
 	    gdb_stdout = ui_file_new();
 	    break;
 	  case 'D':
-	    xfree (gdb_datadir);
-	    gdb_datadir = xstrdup (optarg);
+	    if (optarg[0] == '\0')
+	      {
+		fprintf_unfiltered (gdb_stderr,
+				    _("%s: empty path for"
+				      " `--data-directory'\n"),
+				    argv[0]);
+		exit (1);
+	      }
+	    set_gdb_data_directory (optarg);
 	    gdb_datadir_provided = 1;
 	    break;
 #ifdef GDBTK
diff --git a/gdb/main.h b/gdb/main.h
index 089e1c8..502ca30 100644
--- a/gdb/main.h
+++ b/gdb/main.h
@@ -47,4 +47,6 @@ extern char *windows_get_absolute_argv0 (const char *argv0);
    parse the argv array.  */
 extern const char *get_gdb_program_name (void);
 
+extern void set_gdb_data_directory (const char *new_data_dir);
+
 #endif
diff --git a/gdb/testsuite/gdb.base/catch-syscall.exp b/gdb/testsuite/gdb.base/catch-syscall.exp
index da838f7..a70534c 100644
--- a/gdb/testsuite/gdb.base/catch-syscall.exp
+++ b/gdb/testsuite/gdb.base/catch-syscall.exp
@@ -256,7 +256,8 @@ proc test_catch_syscall_fail_nodatadir {} {
 
 	# Make sure GDB doesn't load the syscalls xml from the system
 	# data directory.
-	gdb_test_no_output "set data-directory /the/path/to/nowhere"
+	gdb_test "set data-directory /the/path/to/nowhere" \
+	    "Warning: /the/path/to/nowhere: .*"
 
 	# Testing to see if we receive a warning when calling "catch
 	# syscall" without XML support (without datadir).
@@ -374,7 +375,8 @@ proc test_catch_syscall_with_wrong_args_noxml {} {
 proc do_syscall_tests_without_xml {} {
     # Make sure GDB doesn't load the syscalls xml from the system data
     # directory.
-    gdb_test_no_output "set data-directory /the/path/to/nowhere"
+    gdb_test "set data-directory /the/path/to/nowhere" \
+	"Warning: /the/path/to/nowhere: .*"
 
     # Let's test if we can catch syscalls without XML support.
     # We should succeed, but GDB is not supposed to print syscall names.
diff --git a/gdb/top.c b/gdb/top.c
index fa20025..186b05f 100644
--- a/gdb/top.c
+++ b/gdb/top.c
@@ -1668,14 +1668,28 @@ show_exec_done_display_p (struct ui_file *file, int from_tty,
 		    value);
 }
 
+/* New values of the "data-directory" parameter are staged here.  */
+static char *staged_gdb_datadir;
+
 /* "set" command for the gdb_datadir configuration variable.  */
 
 static void
 set_gdb_datadir (char *args, int from_tty, struct cmd_list_element *c)
 {
+  set_gdb_data_directory (staged_gdb_datadir);
   observer_notify_gdb_datadir_changed ();
 }
 
+/* "show" command for the gdb_datadir configuration variable.  */
+
+static void
+show_gdb_datadir (struct ui_file *file, int from_tty,
+		  struct cmd_list_element *c, const char *value)
+{
+  fprintf_filtered (file, _("GDB's data directory is \"%s\".\n"),
+		    gdb_datadir);
+}
+
 static void
 set_history_filename (char *args, int from_tty, struct cmd_list_element *c)
 {
@@ -1793,11 +1807,11 @@ Use \"on\" to enable the notification, and \"off\" to disable it."),
 			   &setlist, &showlist);
 
   add_setshow_filename_cmd ("data-directory", class_maintenance,
-                           &gdb_datadir, _("Set GDB's data directory."),
+                           &staged_gdb_datadir, _("Set GDB's data directory."),
                            _("Show GDB's data directory."),
                            _("\
 When set, GDB uses the specified path to search for data files."),
-                           set_gdb_datadir, NULL,
+                           set_gdb_datadir, show_gdb_datadir,
                            &setlist,
                            &showlist);
 }

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH, doc RFA] New option -D: alias for --data-directory
  2014-04-28 22:35                 ` [PATCH, doc RFA] New option -D: alias for --data-directory Doug Evans
@ 2014-04-29  2:37                   ` Eli Zaretskii
  2014-05-16 19:17                     ` Doug Evans
  0 siblings, 1 reply; 14+ messages in thread
From: Eli Zaretskii @ 2014-04-29  2:37 UTC (permalink / raw)
  To: Doug Evans; +Cc: gdb-patches

> From: Doug Evans <dje@google.com>
> Date: Mon, 28 Apr 2014 15:35:33 -0700
> 
> Hi Eli.
> Doc RFA please. :-)

The documentation parts are OK.

Thanks.

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH, doc RFA] New option -D: alias for --data-directory
  2014-04-29  2:37                   ` Eli Zaretskii
@ 2014-05-16 19:17                     ` Doug Evans
  0 siblings, 0 replies; 14+ messages in thread
From: Doug Evans @ 2014-05-16 19:17 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: gdb-patches

Eli Zaretskii writes:
 > > From: Doug Evans <dje@google.com>
 > > Date: Mon, 28 Apr 2014 15:35:33 -0700
 > > 
 > > Hi Eli.
 > > Doc RFA please. :-)
 > 
 > The documentation parts are OK.
 > 
 > Thanks.

Thanks.
Here's what I committed.
I forgot to add a blurb to the output of --help.
The rest of the patch is unchanged.

2014-05-16  Doug Evans  <dje@google.com>

	New command line option -D.
	* NEWS: Mention it.
	* main.c (set_gdb_data_directory): New function.
	(captured_main): Recognize -D.  Flag error for --data-directory "".
	Call set_gdb_data_directory.
	(print_gdb_help): Print --data-directory, -D.
	* main.h (set_gdb_data_directory): Declare.
	* top.c (staged_gdb_datadir): New static global.
	(set_gdb_datadir): Call set_gdb_data_directory
	(show_gdb_datadir): New function.
	(init_main): Update init of data-directory parameter.

	testsuite/
	* gdb.base/catch-syscall.exp (test_catch_syscall_fail_nodatadir):
	Update.
	(do_syscall_tests_without_xml): Update.

	doc/
	* gdb.texinfo (Mode Options): Add -D.

diff --git a/gdb/NEWS b/gdb/NEWS
index d0c44ea..00ec8b9 100644
--- a/gdb/NEWS
+++ b/gdb/NEWS
@@ -3,6 +3,11 @@
 
 *** Changes since GDB 7.7
 
+* New command line options
+
+-D data-directory
+  This is an alias for the --data-directory option.
+
 * GDB supports printing and modifying of variable length automatic arrays
   as specified in ISO C99.
 
diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo
index 2aff5e5..49a0602 100644
--- a/gdb/doc/gdb.texinfo
+++ b/gdb/doc/gdb.texinfo
@@ -1164,7 +1164,9 @@ Run @value{GDBN} using @var{directory} as its working directory,
 instead of the current directory.
 
 @item -data-directory @var{directory}
+@itemx -D @var{directory}
 @cindex @code{--data-directory}
+@cindex @code{-D}
 Run @value{GDBN} using @var{directory} as its data directory.
 The data directory is where @value{GDBN} searches for its
 auxiliary files.  @xref{Data Files}.
diff --git a/gdb/main.c b/gdb/main.c
index 59015f5..a9fc378 100644
--- a/gdb/main.c
+++ b/gdb/main.c
@@ -106,6 +106,41 @@ get_gdb_program_name (void)
 
 static void print_gdb_help (struct ui_file *);
 
+/* Set the data-directory parameter to NEW_DATADIR.
+   If NEW_DATADIR is not a directory then a warning is printed.
+   We don't signal an error for backward compatibility.  */
+
+void
+set_gdb_data_directory (const char *new_datadir)
+{
+  struct stat st;
+
+  if (stat (new_datadir, &st) < 0)
+    {
+      int save_errno = errno;
+
+      fprintf_unfiltered (gdb_stderr, "Warning: ");
+      print_sys_errmsg (new_datadir, save_errno);
+    }
+  else if (!S_ISDIR (st.st_mode))
+    warning (_("%s is not a directory."), new_datadir);
+
+  xfree (gdb_datadir);
+  gdb_datadir = gdb_realpath (new_datadir);
+
+  /* gdb_realpath won't return an absolute path if the path doesn't exist,
+     but we still want to record an absolute path here.  If the user entered
+     "../foo" and "../foo" doesn't exist then we'll record $(pwd)/../foo which
+     isn't canonical, but that's ok.  */
+  if (!IS_ABSOLUTE_PATH (gdb_datadir))
+    {
+      char *abs_datadir = gdb_abspath (gdb_datadir);
+
+      xfree (gdb_datadir);
+      gdb_datadir = abs_datadir;
+    }
+}
+
 /* 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
@@ -517,6 +552,7 @@ captured_main (void *data)
       {"directory", required_argument, 0, 'd'},
       {"d", required_argument, 0, 'd'},
       {"data-directory", required_argument, 0, 'D'},
+      {"D", required_argument, 0, 'D'},
       {"cd", required_argument, 0, OPT_CD},
       {"tty", required_argument, 0, 't'},
       {"baud", required_argument, 0, 'b'},
@@ -641,8 +677,15 @@ captured_main (void *data)
 	    gdb_stdout = ui_file_new();
 	    break;
 	  case 'D':
-	    xfree (gdb_datadir);
-	    gdb_datadir = xstrdup (optarg);
+	    if (optarg[0] == '\0')
+	      {
+		fprintf_unfiltered (gdb_stderr,
+				    _("%s: empty path for"
+				      " `--data-directory'\n"),
+				    argv[0]);
+		exit (1);
+	      }
+	    set_gdb_data_directory (optarg);
 	    gdb_datadir_provided = 1;
 	    break;
 #ifdef GDBTK
@@ -1146,6 +1189,8 @@ Remote debugging options:\n\n\
   -l TIMEOUT         Set timeout in seconds for remote debugging.\n\n\
 Other options:\n\n\
   --cd=DIR           Change current directory to DIR.\n\
+  --data-directory=DIR, -D\n\
+                     Set GDB's data-directory to DIR.\n\
 "), stream);
   fputs_unfiltered (_("\n\
 At startup, GDB reads the following init files and executes their commands:\n\
diff --git a/gdb/main.h b/gdb/main.h
index 089e1c8..502ca30 100644
--- a/gdb/main.h
+++ b/gdb/main.h
@@ -47,4 +47,6 @@ extern char *windows_get_absolute_argv0 (const char *argv0);
    parse the argv array.  */
 extern const char *get_gdb_program_name (void);
 
+extern void set_gdb_data_directory (const char *new_data_dir);
+
 #endif
diff --git a/gdb/testsuite/gdb.base/catch-syscall.exp b/gdb/testsuite/gdb.base/catch-syscall.exp
index da838f7..a70534c 100644
--- a/gdb/testsuite/gdb.base/catch-syscall.exp
+++ b/gdb/testsuite/gdb.base/catch-syscall.exp
@@ -256,7 +256,8 @@ proc test_catch_syscall_fail_nodatadir {} {
 
 	# Make sure GDB doesn't load the syscalls xml from the system
 	# data directory.
-	gdb_test_no_output "set data-directory /the/path/to/nowhere"
+	gdb_test "set data-directory /the/path/to/nowhere" \
+	    "Warning: /the/path/to/nowhere: .*"
 
 	# Testing to see if we receive a warning when calling "catch
 	# syscall" without XML support (without datadir).
@@ -374,7 +375,8 @@ proc test_catch_syscall_with_wrong_args_noxml {} {
 proc do_syscall_tests_without_xml {} {
     # Make sure GDB doesn't load the syscalls xml from the system data
     # directory.
-    gdb_test_no_output "set data-directory /the/path/to/nowhere"
+    gdb_test "set data-directory /the/path/to/nowhere" \
+	"Warning: /the/path/to/nowhere: .*"
 
     # Let's test if we can catch syscalls without XML support.
     # We should succeed, but GDB is not supposed to print syscall names.
diff --git a/gdb/top.c b/gdb/top.c
index fa20025..186b05f 100644
--- a/gdb/top.c
+++ b/gdb/top.c
@@ -1668,14 +1668,28 @@ show_exec_done_display_p (struct ui_file *file, int from_tty,
 		    value);
 }
 
+/* New values of the "data-directory" parameter are staged here.  */
+static char *staged_gdb_datadir;
+
 /* "set" command for the gdb_datadir configuration variable.  */
 
 static void
 set_gdb_datadir (char *args, int from_tty, struct cmd_list_element *c)
 {
+  set_gdb_data_directory (staged_gdb_datadir);
   observer_notify_gdb_datadir_changed ();
 }
 
+/* "show" command for the gdb_datadir configuration variable.  */
+
+static void
+show_gdb_datadir (struct ui_file *file, int from_tty,
+		  struct cmd_list_element *c, const char *value)
+{
+  fprintf_filtered (file, _("GDB's data directory is \"%s\".\n"),
+		    gdb_datadir);
+}
+
 static void
 set_history_filename (char *args, int from_tty, struct cmd_list_element *c)
 {
@@ -1793,11 +1807,11 @@ Use \"on\" to enable the notification, and \"off\" to disable it."),
 			   &setlist, &showlist);
 
   add_setshow_filename_cmd ("data-directory", class_maintenance,
-                           &gdb_datadir, _("Set GDB's data directory."),
+                           &staged_gdb_datadir, _("Set GDB's data directory."),
                            _("Show GDB's data directory."),
                            _("\
 When set, GDB uses the specified path to search for data files."),
-                           set_gdb_datadir, NULL,
+                           set_gdb_datadir, show_gdb_datadir,
                            &setlist,
                            &showlist);
 }

^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2014-05-16 19:17 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-12-27 19:42 [RFC] New option -B: simplify running gdb from build directory Doug Evans
2013-12-27 19:54 ` Doug Evans
2013-12-27 20:15 ` Eli Zaretskii
2013-12-27 20:51   ` Doug Evans
2014-03-06 21:41 ` [PATCH, doc RFA] " Doug Evans
2014-03-07  7:10   ` Eli Zaretskii
     [not found]     ` <CADPb22RKaBx1p2vF4-wGODZVe-QqdGc93Ax-bD82xb9Adr5EJw@mail.gmail.com>
2014-03-07 18:41       ` Eli Zaretskii
2014-03-07 18:54         ` Doug Evans
2014-03-25  1:02           ` Doug Evans
2014-03-25  1:20             ` Doug Evans
2014-03-25  1:28               ` Doug Evans
2014-04-28 22:35                 ` [PATCH, doc RFA] New option -D: alias for --data-directory Doug Evans
2014-04-29  2:37                   ` Eli Zaretskii
2014-05-16 19:17                     ` Doug Evans

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).