* [patch] Expand tildes in solib-search-path entries.
@ 2012-05-22 18:17 Thiago Jung Bauermann
2012-05-24 15:31 ` Pedro Alves
0 siblings, 1 reply; 3+ messages in thread
From: Thiago Jung Bauermann @ 2012-05-22 18:17 UTC (permalink / raw)
To: gdb-patches ml
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*
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [patch] Expand tildes in solib-search-path entries.
2012-05-22 18:17 [patch] Expand tildes in solib-search-path entries Thiago Jung Bauermann
@ 2012-05-24 15:31 ` Pedro Alves
2012-05-30 3:44 ` Thiago Jung Bauermann
0 siblings, 1 reply; 3+ messages in thread
From: Pedro Alves @ 2012-05-24 15:31 UTC (permalink / raw)
To: Thiago Jung Bauermann; +Cc: gdb-patches ml
On 05/22/2012 07:17 PM, Thiago Jung Bauermann wrote:
> 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, '~'))
Seem to me this could be an "else if" above the "else" instead of
nested within the "else". The "Don't search $cdir" bit below
should never apply, even in the rare beyond belief case of the user's
home expanding to literal "$cdir". Okay with that change.
--
Pedro Alves
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [patch] Expand tildes in solib-search-path entries.
2012-05-24 15:31 ` Pedro Alves
@ 2012-05-30 3:44 ` Thiago Jung Bauermann
0 siblings, 0 replies; 3+ messages in thread
From: Thiago Jung Bauermann @ 2012-05-30 3:44 UTC (permalink / raw)
To: Pedro Alves; +Cc: gdb-patches ml
Hello Pedro,
On Thu, 2012-05-24 at 16:30 +0100, Pedro Alves wrote:
> On 05/22/2012 07:17 PM, Thiago Jung Bauermann wrote:
>
> > 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, '~'))
>
>
> Seem to me this could be an "else if" above the "else" instead of
> nested within the "else". The "Don't search $cdir" bit below
> should never apply, even in the rare beyond belief case of the user's
> home expanding to literal "$cdir". Okay with that change.
You are right, here's what I committed.
--
[]'s
Thiago Jung Bauermann
Linaro Toolchain Working Group
2012-05-30 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..7de86b4 100644
--- a/gdb/source.c
+++ b/gdb/source.c
@@ -769,6 +769,25 @@ openp (const char *path, int opts, const char *string,
}
strcpy (filename, current_directory);
}
+ else if (strchr(dir, '~'))
+ {
+ /* See whether we need to expand the tilde. */
+ 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. */
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2012-05-30 3:44 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-05-22 18:17 [patch] Expand tildes in solib-search-path entries Thiago Jung Bauermann
2012-05-24 15:31 ` Pedro Alves
2012-05-30 3:44 ` Thiago Jung Bauermann
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox