Thread View: gnu.gdb.bug
3 messages
3 total messages
Started by Gill Bates
Wed, 06 Mar 2002 04:11
cygwin gdb does not pass along exported enviornment variables
Author: Gill Bates
Date: Wed, 06 Mar 2002 04:11
Date: Wed, 06 Mar 2002 04:11
66 lines
2766 bytes
2766 bytes
Does anyone know why the cygwin version of gdb doesn't pass exported
variables to the program being debugged? I have a simple test case
where the program can retrieve an environment variable via getenv().
The program works when NOT running with gdb. If I run the same
executable with gdb, either window or non-window mode, the same
variable is not defined -- not retrievable via getenv().
Thanks for any help!!
cat x.c
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
int
main (int argc, char *argv[])
{
char *env;
env = getenv ("Var1");
printf ("Var1=[%s]\n", env==NULL?"NULL":env);
return 0;
}
gcc -g x.c -o x
gcc -dumpversion
2.95.3-5
Maybe the problem is due to:
ntdll.dll: No such file or directory.
But, dunno what that means either...
Also:
bash --version
GNU bash, version 2.05a.0(2)-release (i686-pc-cygwin)
Copyright 2001 Free Software Foundation, Inc.
WEASEL:> export Var1=1
WEASEL:> x
Var1=[1]
WEASEL:> gdb -nw x
GNU gdb 5.0 (20010428-3)
Copyright 2001 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and
you are
welcome to change it and/or distribute copies of it under certain
conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB. Type "show warranty" for
details.
This GDB was configured as "i686-pc-cygwin"...
(gdb) run
Starting program: /home/harold/win32_1-0/mainsail/build/bin/x.exe
ntdll.dll: No such file or directory.
Var1=[NULL]
Program exited normally.
(gdb) quit
WEASEL:>
Re: cygwin gdb does not pass along exported enviornment variables
Author: Gill Bates
Date: Wed, 06 Mar 2002 23:03
Date: Wed, 06 Mar 2002 23:03
27 lines
2593 bytes
2593 bytes
gill_bates@hotmail.com (Gill Bates) wrote in message news:<8e6815bd.0203052011.4d0e2c0f@posting.google.com>... > Does anyone know why the cygwin version of gdb doesn't pass exported > variables to the program being debugged? I have a simple test case > where the program can retrieve an environment variable via getenv(). > The program works when NOT running with gdb. If I run the same > executable with gdb, either window or non-window mode, the same > variable is not defined -- not retrievable via getenv(). > > Thanks for any help!! > > OK; mystery mostly solved... After much arduous debugging gdb using gdb (that was pretty weird and confusing�), I found the function �child_create_inferior (char *exec_file, char *allargs, char **env)' in win32-nat.c was building the env string correctly then passed it to the win32api CreateProcess. It appears the win32 function is �limited' to the number of env variables it will accept and will silently discard any that are beyond this undocumented limit. Anyone know what the number is? I thought not� In any case, the problem appears to be isolated to this bogus win32 api function. But; it leaves me wondering how the cygwin exec function gets around the dilemma. What I plan to do is dump the variables into a file, then suck them into the exec'ed program and define them using putenv()� Thanks for the HELP!!!
Re: cygwin gdb does not pass along exported enviornment variables
Author: Andrew Cagney
Date: Wed, 06 Mar 2002 23:32
Date: Wed, 06 Mar 2002 23:32
37 lines
2685 bytes
2685 bytes
Hello, Can you file a bug report explaining this? See http://sources.redhat.com/gdb/bugs/ Andrew > gill_bates@hotmail.com (Gill Bates) wrote in message news:<8e6815bd.0203052011.4d0e2c0f@posting.google.com>... > >> Does anyone know why the cygwin version of gdb doesn't pass exported >> variables to the program being debugged? I have a simple test case >> where the program can retrieve an environment variable via getenv(). >> The program works when NOT running with gdb. If I run the same >> executable with gdb, either window or non-window mode, the same >> variable is not defined -- not retrievable via getenv(). >> >> Thanks for any help!! >> >> > > > OK; mystery mostly solved... > After much arduous debugging gdb using gdb (that was pretty weird and > confusing...), I found the function 'child_create_inferior (char > *exec_file, char *allargs, char **env)' in win32-nat.c was building > the env string correctly then passed it to the win32api CreateProcess. > It appears the win32 function is 'limited' to the number of env > variables it will accept and will silently discard any that are beyond > this undocumented limit. Anyone know what the number is? I thought > not... In any case, the problem appears to be isolated to this bogus > win32 api function. But; it leaves me wondering how the cygwin exec > function gets around the dilemma. What I plan to do is dump the > variables into a file, then suck them into the exec'ed program and > define them using putenv()... > > Thanks for the HELP!!! >
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads