www.delorie.com/djgpp/bugs/show.cgi   search  
Bug 000018

When Created: 08/25/1995 03:29:42
Against DJGPP version: 2.00.beta2
By whom: eliz@is.elta.co.il
Abstract: Incorrect argc, argv[] when running under debugger
When a program is run under GDB, you can't pass arguments to it.
Neither ``run args-list'' nor ``set args args-list'', then ``run''
work.  In any of these cases, the debuggee gets argc = 1 and
argv[0] = c:/whatever/gdb.exe.  It seems there is a bug in the
start-up code which prevents the correct arguments to be passed
to the debugged program.

I only saw this under GDB, but Charles Sandmann reports it also happens
under any other debugger.

Currently this means some programs can only be debugged by hard-wiring
the arguments into the program's source (yuck!).

Note added: 08/26/1995 13:15:10
By whom: sandmann@clio.rice.edu
argc and argv[1] up are set properly in edebug and fsdb, only argv[0]
is set wrong for those debuggers.
In debug/common/v2load.c the loading program's environment block is
shared with the loaded program, which causes argv0 to be incorrect,
and none of the 32-bit environment variables to be passed.  The fix
is to either create a new 16-bit environment block and set it 
correctly (much of this could be borrowed from the exec code - maybe
make it common code?).
GDB has additional problems in that the "set arg" type functionality
must modify the command line tail in the pseudo-PSP set up for the
program.  I don't know for sure, but I don't think this is currently
coded at all.

Fixed in version 2.00.beta3 on 09/07/1995 22:13:05
By whom: dj@delorie.com

Note added: 09/07/1995 22:14:33
By whom: dj@delorie.com
The solution in this case was to (1) modify the debug library to support
argv[0] and environments, and (2) modify gdb to use the debug library correctly.
This means that you can use "set env" in gdb, and "run args ..." to run the
program.



  webmaster     delorie software   privacy  
  Copyright © 2010   by DJ Delorie     Updated Jul 2010