This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PATCH] add-inferior: expand tilde in -exec FILENAME argument
- From: Pedro Alves <palves at redhat dot com>
- To: "Agovic, Sanimir" <sanimir dot agovic at intel dot com>
- Cc: "gdb-patches at sourceware dot org" <gdb-patches at sourceware dot org>
- Date: Thu, 30 May 2013 10:25:08 +0100
- Subject: Re: [PATCH] add-inferior: expand tilde in -exec FILENAME argument
- References: <1362062885-6620-1-git-send-email-sanimir dot agovic at intel dot com> <512F7897 dot 5000705 at redhat dot com> <0377C58828D86C4588AEEC42FC3B85A7162A0A3C at IRSMSX102 dot ger dot corp dot intel dot com>
Hi, sorry for the delay in getting back to this.
On 02/28/2013 05:15 PM, Agovic, Sanimir wrote:
>> -----Original Message-----
>> From: Pedro Alves [mailto:palves@redhat.com]
>> Sent: Thursday, February 28, 2013 04:33 PM
>
> Thanks for your feedback.
>
>> I assume this fixes:
>>
>> (gdb) add-inferior -exec ~/gdb/tests/main
>> Added inferior 2
>> ~/gdb/tests/main: No such file or directory.
>>
>> even though the file does exist.
> Yes. Sorry for not being clear about the cause.
>
>> I wondered if other similar places expand the tilde early
>> or just before file open [...]
> I found at least one another case:
>
> % gdb -batch \~/gdb/tests/main # or --exec=~/gdb/tests/main
> ~/gdb/tests/main: No such file or directory.
>
> Whereas:
> % gdb -batch --symbols=\~/gdb/tests/main
> Succeeds.
>
> Seems like gdb relies on the shell to expand its executable name.
>
> As an alternative approach I can expand tilde in exec_file_attach
> which is what symbol_file_add and core_file_command do.
Yes, I think that makes sense. We could then remove it from exec.c:
filename = tilde_expand (*argv);
make_cleanup (xfree, filename);
exec_file_attach (filename, from_tty);
--
Pedro Alves