[PATCH] add-inferior: expand tilde in -exec FILENAME argument

Pedro Alves palves@redhat.com
Thu May 30 09:25:00 GMT 2013


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



More information about the Gdb-patches mailing list