* can't handle command-line argument containing whitespace
@ 2019-01-21 4:50 Peng Yu
2019-01-21 10:19 ` Eli Zaretskii
0 siblings, 1 reply; 4+ messages in thread
From: Peng Yu @ 2019-01-21 4:50 UTC (permalink / raw)
To: gdb
Hi,
I got the following error. Is there a way to allow gdb accept
arguments with whitespaces? Thanks
$ ./main.exe 'a b c'
a b c
$ cat main.c
/* vim: set noexpandtab tabstop=2: */
#include <stdio.h>
int main(int argc, char *argv[]) {
puts(argv[1]);
return 0;
}
$ gdb -q --args main.exe 'a b c'
Reading symbols from main.exe...(no debugging symbols found)...done.
(gdb) r
Starting program: /root/linux/test/gnu/gdb/bin/--args/main.exe can't
handle command-line argument containing whitespace
(gdb)
--
Regards,
Peng
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: can't handle command-line argument containing whitespace
2019-01-21 4:50 can't handle command-line argument containing whitespace Peng Yu
@ 2019-01-21 10:19 ` Eli Zaretskii
2019-01-21 13:16 ` Peng Yu
0 siblings, 1 reply; 4+ messages in thread
From: Eli Zaretskii @ 2019-01-21 10:19 UTC (permalink / raw)
To: gdb, Peng Yu, gdb
On January 21, 2019 6:50:25 AM GMT+02:00, Peng Yu <pengyu.ut@gmail.com> wrote:
> Hi,
>
> I got the following error. Is there a way to allow gdb accept
> arguments with whitespaces? Thanks
>
> $ ./main.exe 'a b c'
> a b c
> $ cat main.c
> /* vim: set noexpandtab tabstop=2: */
> #include <stdio.h>
>
> int main(int argc, char *argv[]) {
> puts(argv[1]);
> return 0;
> }
> $ gdb -q --args main.exe 'a b c'
> Reading symbols from main.exe...(no debugging symbols found)...done.
> (gdb) r
> Starting program: /root/linux/test/gnu/gdb/bin/--args/main.exe can't
> handle command-line argument containing whitespace
> (gdb)
Try this GDB command:
(gdb) set startup-with-shell on
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: can't handle command-line argument containing whitespace
2019-01-21 10:19 ` Eli Zaretskii
@ 2019-01-21 13:16 ` Peng Yu
2019-01-21 15:49 ` Eli Zaretskii
0 siblings, 1 reply; 4+ messages in thread
From: Peng Yu @ 2019-01-21 13:16 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: gdb
> Try this GDB command:
>
> (gdb) set startup-with-shell on
But it doesn't work with the -batch option. It hangs there forever.
How to fix it? Thanks.
$ gdb -batch -ex 'set startup-with-shell on' -ex run --args ./main.exe 'a b c'
[New Thread 0x1803 of process 56945]
--
Regards,
Peng
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: can't handle command-line argument containing whitespace
2019-01-21 13:16 ` Peng Yu
@ 2019-01-21 15:49 ` Eli Zaretskii
0 siblings, 0 replies; 4+ messages in thread
From: Eli Zaretskii @ 2019-01-21 15:49 UTC (permalink / raw)
To: Peng Yu; +Cc: gdb
> From: Peng Yu <pengyu.ut@gmail.com>
> Date: Mon, 21 Jan 2019 07:16:41 -0600
> Cc: "gdb@sourceware.org" <gdb@sourceware.org>
>
> > Try this GDB command:
> >
> > (gdb) set startup-with-shell on
>
> But it doesn't work with the -batch option. It hangs there forever.
> How to fix it? Thanks.
Don't run your program from the command line, run it from a script
file that you load via the -x command-line switch. In that script,
put the "set startup-with-shell on" command first, then your "run"
command with the arguments for the program you want to debug.
(Why do you run GDB with -batch, btw? GDB is an interactive debugger,
so you should have a way of interacting with it.)
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2019-01-21 15:49 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-01-21 4:50 can't handle command-line argument containing whitespace Peng Yu
2019-01-21 10:19 ` Eli Zaretskii
2019-01-21 13:16 ` Peng Yu
2019-01-21 15:49 ` Eli Zaretskii
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).