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] Expand tildes in solib-search-path entries.


Hello,

GDB will expand the tilde when using the "set directories", "set
sysroot", "source" and "file" commands, possibly others. But it doesn't
expand the tilde on "set solib-search-path". This made me lose some time
wondering what was going on when I was debugging another issue.

This patch fixes it. "set directories" expands the tilde in a much more
elaborate way by calling mod_path which calls add_path. "set sysroot",
"source" and "file" just call tilde_expand like I do here.

There are no regressions in i386-linux. Ok?

-- 
[]'s
Thiago Jung Bauermann
Linaro Toolchain Working Group


2012-05-22  Thiago Jung Bauermann  <thiago.bauermann@linaro.org>

	* source.c (openp): Expand tilde in path entries.


diff --git a/gdb/source.c b/gdb/source.c
index 27c5b0e..af68ebd 100644
--- a/gdb/source.c
+++ b/gdb/source.c
@@ -771,8 +771,28 @@ openp (const char *path, int opts, const char *string,
 	}
       else
 	{
-	  /* Normal file name in path -- just use it.  */
-	  strcpy (filename, dir);
+	  /* See whether we need to expand the tilde.  */
+	  if (strchr(dir, '~'))
+	    {
+	      int newlen;
+	      char *tilde_expanded;
+
+	      tilde_expanded  = tilde_expand (dir);
+
+	      /* First, realloc the filename buffer if too short.  */
+	      len = strlen (tilde_expanded);
+	      newlen = len + strlen (string) + 2;
+	      if (newlen > alloclen)
+		{
+		  alloclen = newlen;
+		  filename = alloca (alloclen);
+		}
+	      strcpy (filename, tilde_expanded);
+	      xfree (tilde_expanded);
+	    }
+	  else
+	    /* Normal file name in path -- just use it.  */
+	    strcpy (filename, dir);
 
 	  /* Don't search $cdir.  It's also a magic path like $cwd, but we
 	     don't have enough information to expand it.  The user *could*



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