Bug 10989 - Debuggee doesn't see environment variables set with set environment
Summary: Debuggee doesn't see environment variables set with set environment
Status: RESOLVED FIXED
Alias: None
Product: gdb
Classification: Unclassified
Component: win32 (show other bugs)
Version: 7.0
: P2 normal
Target Milestone: 7.4
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-11-19 20:30 UTC by Vincent Snijders
Modified: 2011-10-03 18:16 UTC (History)
3 users (show)

See Also:
Host: mingw32
Target: mingw32
Build:
Last reconfirmed: 2010-10-16 13:28:09


Attachments
Pascal source code (142 bytes, text/plain)
2009-11-19 20:31 UTC, Vincent Snijders
Details
win32 executable with debug info (258.66 KB, application/octet-stream)
2009-11-19 20:32 UTC, Vincent Snijders
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Vincent Snijders 2009-11-19 20:30:13 UTC
If I set an environment variable in gdbm the debugged program does not see it.

C:\lazarus\bugs\gdbenv>..\..\source\binaries\i386-win32\gdb\bin\gdb.exe gdbenvbu
g.exe -n
GNU gdb (GDB) 7.0
Copyright (C) 2009 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "mingw32".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
Reading symbols from C:\lazarus\bugs\gdbenv/gdbenvbug.exe...done.
(gdb) set environment TEST_GDB_ENV=Hi
(gdb) show environment TEST_GDB_ENV
TEST_GDB_ENV = Hi
(gdb) r
Starting program: C:\lazarus\bugs\gdbenv/gdbenvbug.exe
[New Thread 2320.0xc8c]
warning: Can not parse XML library list; XML support was disabled at compile tim
e
TEST_GDB_ENV=


Program exited normally.
(gdb) q

Setting the environment variabele at the command prompt and running the program
works:
C:\lazarus\bugs\gdbenv>set TEST_GDB_ENV=Hi
C:\lazarus\bugs\gdbenv>gdbenvbug.exe
TEST_GDB_ENV=Hi

Source of the pascal program:
C:\lazarus\bugs\gdbenv>type gdbenvbug.lpr
program gdbenvbug;

{$mode objfpc}{$H+}

uses
  SysUtils;

begin
  writeln('TEST_GDB_ENV=',GetEnvironmentVariable('TEST_GDB_ENV'));
  readln;
end.
Comment 1 Vincent Snijders 2009-11-19 20:31:27 UTC
Created attachment 4398 [details]
Pascal source code
Comment 2 Vincent Snijders 2009-11-19 20:32:38 UTC
Created attachment 4399 [details]
win32 executable with debug info
Comment 3 Vincent Snijders 2009-11-27 08:22:10 UTC
This works correctly with gdb 6.3, that is distributed with the free pascal
compiler version 2.2.2:

C:\lazarus\bugs\gdbenv>c:\fpc\2.2.2\bin\i386-win32\gdb.exe gdbenvbug.exe
GNU gdb 6.3
Copyright 2004 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-mingw32"...
(gdb) set environment TEST_GDB_ENV=Hi
(gdb) r
Starting program: C:\lazarus\bugs\gdbenv/gdbenvbug.exe
TEST_GDB_ENV=Hi
Comment 4 Vincent Snijders 2010-10-16 08:59:42 UTC
This issue also has been reported at http://mantis.freepascal.org/view.php?id=17641
Comment 5 Pedro Alves 2010-10-16 13:28:09 UTC
> This works correctly with gdb 6.3, that is distributed with the free pascal
> compiler version 2.2.2:

That gdb most probably has local patches that never made it upstream.

This is more a missing feature than a bug.  There was a patch posted to attempt addressing it no so long ago.  See:

<http://sourceware.org/ml/gdb-patches/2010-08/msg00026.html>
Comment 6 Tom Tromey 2011-10-03 18:16:19 UTC
Fix checked in:

http://sourceware.org/ml/gdb-patches/2011-09/msg00468.html