Pass --data-directory through gdb_realpath.

Message ID yjt2wqeqxzn3.fsf@ruffy.mtv.corp.google.com
State Superseded
Headers

Commit Message

Doug Evans April 15, 2014, 5:37 p.m. UTC
  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.
  

Patch

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