* [PATCH] add-inferior: expand tilde in -exec FILENAME argument
@ 2013-02-28 15:44 Sanimir Agovic
2013-02-28 15:54 ` Pedro Alves
0 siblings, 1 reply; 4+ messages in thread
From: Sanimir Agovic @ 2013-02-28 15:44 UTC (permalink / raw)
To: gdb-patches
I could not come up with a solid testcase, hints are welcome.
2013-02-28 Sanimir Agovic <sanimir.agovic@intel.com>
* inferior.c: Include "readline/readline.h".
(add_inferior_command): Tilde expand filename.
Signed-off-by: Sanimir Agovic <sanimir.agovic@intel.com>
---
gdb/inferior.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/gdb/inferior.c b/gdb/inferior.c
index ed6b626..abf0afa 100644
--- a/gdb/inferior.c
+++ b/gdb/inferior.c
@@ -35,6 +35,7 @@
#include "continuations.h"
#include "arch-utils.h"
#include "target-descriptions.h"
+#include "readline/readline.h"
void _initialize_inferiors (void);
@@ -850,7 +851,8 @@ add_inferior_command (char *args, int from_tty)
++argv;
if (!*argv)
error (_("No argument to -exec"));
- exec = *argv;
+ exec = tilde_expand (*argv);
+ make_cleanup (xfree, exec);
}
}
else
--
1.7.11.7
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH] add-inferior: expand tilde in -exec FILENAME argument
2013-02-28 15:44 [PATCH] add-inferior: expand tilde in -exec FILENAME argument Sanimir Agovic
@ 2013-02-28 15:54 ` Pedro Alves
2013-02-28 17:20 ` Agovic, Sanimir
0 siblings, 1 reply; 4+ messages in thread
From: Pedro Alves @ 2013-02-28 15:54 UTC (permalink / raw)
To: Sanimir Agovic; +Cc: gdb-patches
Thanks.
On 02/28/2013 02:48 PM, Sanimir Agovic wrote:
> I could not come up with a solid testcase, hints are welcome.
Not sure either.
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.
I wondered if other similar places expand the tilde early
or just before file open, and confirmed that at least "file"
and "info files" have expanded the tilde before any visible
strings is shown:
(gdb) file ~/gdb/tests/main
Load new symbol table from "/home/pedro/gdb/tests/main"? (y or n)
(gdb) info files
Symbols from "/home/pedro/gdb/tests/main".
Local exec file:
`/home/pedro/gdb/tests/main', file type elf64-x86-64.
> 2013-02-28 Sanimir Agovic <sanimir.agovic@intel.com>
>
> * inferior.c: Include "readline/readline.h".
> (add_inferior_command): Tilde expand filename.
OK.
Thanks again for the patch.
--
Pedro Alves
^ permalink raw reply [flat|nested] 4+ messages in thread* RE: [PATCH] add-inferior: expand tilde in -exec FILENAME argument
2013-02-28 15:54 ` Pedro Alves
@ 2013-02-28 17:20 ` Agovic, Sanimir
2013-05-30 9:25 ` Pedro Alves
0 siblings, 1 reply; 4+ messages in thread
From: Agovic, Sanimir @ 2013-02-28 17:20 UTC (permalink / raw)
To: Pedro Alves; +Cc: gdb-patches
> -----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.
-Sanimir
Intel GmbH
Dornacher Strasse 1
85622 Feldkirchen/Muenchen, Deutschland
Sitz der Gesellschaft: Feldkirchen bei Muenchen
Geschaeftsfuehrer: Christian Lamprechter, Hannes Schwaderer, Douglas Lusk
Registergericht: Muenchen HRB 47456
Ust.-IdNr./VAT Registration No.: DE129385895
Citibank Frankfurt a.M. (BLZ 502 109 00) 600119052
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] add-inferior: expand tilde in -exec FILENAME argument
2013-02-28 17:20 ` Agovic, Sanimir
@ 2013-05-30 9:25 ` Pedro Alves
0 siblings, 0 replies; 4+ messages in thread
From: Pedro Alves @ 2013-05-30 9:25 UTC (permalink / raw)
To: Agovic, Sanimir; +Cc: gdb-patches
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
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2013-05-30 9:25 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-02-28 15:44 [PATCH] add-inferior: expand tilde in -exec FILENAME argument Sanimir Agovic
2013-02-28 15:54 ` Pedro Alves
2013-02-28 17:20 ` Agovic, Sanimir
2013-05-30 9:25 ` Pedro Alves
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox