This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Pass --data-directory through gdb_realpath.


Hi.

gdb currently records the supplied --data-directory as is,
which if a relative path will be wrong if the user cd's
to a different directory.

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

	* main.c (captured_main): Pass --data-directory through gdb_realpath.

diff --git a/gdb/main.c b/gdb/main.c
index 59015f5..d269638 100644
--- a/gdb/main.c
+++ b/gdb/main.c
@@ -642,7 +642,15 @@ captured_main (void *data)
 	    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);
+	      }
+	    gdb_datadir = gdb_realpath (optarg);
 	    gdb_datadir_provided = 1;
 	    break;
 #ifdef GDBTK


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]