🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.gdb.bug
Article #2582

cygwin gdb does not pass along exported enviornment variables

#2582
From: Gill Bates
Date: Wed, 06 Mar 2002 04:11
66 lines
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:>
Technical Details
Message-ID: <8e6815bd.0203052011.4d0e2c0f@posting.google.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!newsfeed.stanford.edu!cyclone.bc.net!torn!news-out.cwix.com!newsfeed.cwix.com!nntp.abs.net!uunet!dca.uu.net!ash.uu.net!spool0901.news.uu.net!wendy-fate.uu.net!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f5053,9088e1c11f9b4cc2,start
X-Google-Attributes: gidf5053,public
X-Google-ArrivalTime: 2002-03-05 20:12:04 PST
x-uunet-gateway: chi6sosrv11.alter.net from bug-gdb to gnu.gdb.bug; Wed, 6 Mar 2002 04:12:00 GMT
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!newsfeed.stanford.edu!cyclone.bc.net!torn!news-out.cwix.com!newsfeed.cwix.com!nntp.abs.net!uunet!dca.uu.net!ash.uu.net!spool0901.news.uu.net!wendy-fate.uu.net!not-for-mail
From: gill_bates@hotmail.com (Gill Bates)
Subject: cygwin gdb does not pass along exported enviornment variables
Date: 5 Mar 2002 20:11:56 -0800
Organization: http://groups.google.com/
Message-ID: <8e6815bd.0203052011.4d0e2c0f@posting.google.com>
NNTP-Posting-Host: 24.94.114.18
Content-Type: text/plain; charset=GB2312
Content-Transfer-Encoding: 8bit
X-Trace: posting.google.com 1015387916 3313 127.0.0.1 (6 Mar 2002 04:11:56 GMT)
X-Complaints-To: groups-abuse@google.com
NNTP-Posting-Date: 6 Mar 2002 04:11:56 GMT
Approved: bug-gdb-request@mail.gnu.org
Newsgroups: gnu.gdb.bug
Sender: bug-gdb-request@mail.gnu.org
Lines: 66