This is the mail archive of the
gdb@sourceware.org
mailing list for the GDB project.
Re: How to pass empty string to program's argv[0] ?
- From: Paul Pluzhnikov <ppluzhnikov at google dot com>
- To: Ilya Basin <basinilya at gmail dot com>
- Cc: gdb at sourceware dot org
- Date: Fri, 7 Jan 2011 09:11:38 -0800
- Subject: Re: How to pass empty string to program's argv[0] ?
- References: <653669235.20110105134547@gmail.com>
On Wed, Jan 5, 2011 at 2:45 AM, Ilya Basin <basinilya@gmail.com> wrote:
> $ sh -c "exec -a '' bash -s a b c"
> echo "0: '$0'"; echo "1: '$1'"
> 0: ''
> 1: 'a'
>
> I want similar output from bash under gdb
FWIW, gdb insists on setting argv[0] to full path of the executable.
This caused me trouble when I was debugging a program that looked at
argv[0] and behaved differently depending on whether it was invoked
with relative or absolute path. I had to patch GDB to do what I
wanted. It would be nice if e.g. "set args" were able to set argv[0]
as well. Feel free to file a feature request bug in bugzilla (if
there isn't one already).
Cheers,
--
Paul Pluzhnikov