How to pass empty string to program's argv[0] ?

Paul Pluzhnikov ppluzhnikov@google.com
Fri Jan 7 17:12:00 GMT 2011


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



More information about the Gdb mailing list