This is the mail archive of the gdb@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]