Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 330751

Summary: standard error output missing and environment not set, both when debugging (invoking gdb)
Product: [Tools] CDT Reporter: mijs tonen <mijstonen>
Component: cdt-debugAssignee: cdt-debug-inbox <cdt-debug-inbox>
Status: CLOSED DUPLICATE QA Contact:
Severity: normal    
Priority: P3 CC: cdtdoug, marc.khouzam, pawel.1.piech
Version: 8.0   
Target Milestone: ---   
Hardware: PC   
OS: Windows Vista   
Whiteboard:

Description mijs tonen CLA 2010-11-21 11:44:34 EST
-- Configuration Details --
Product: Eclipse 1.3.1.20100913-1228 (org.eclipse.epp.package.cpp.product)
Installed Features:
 org.eclipse.platform 3.6.1.r361_v20100909-9gF78GrkFqw7GrsZnvz0JWNTeb6fue6896L

Platform
Windows Vista Home (continuesly updated)

Build tools
mingw-get-inst-20101030.exe based. Includes MSys, gcc 4.5 (and 3.4 in msys), gdb 7.2

 
 1. Environment variables set in for debugging are not set in the debugged process,
    apperrently the command used to instruct GDB is wrong.

    gdb set env (or set environment) does not set the environment variable within the debugged process, not even if the gdb commandline insterface (without eclipse interference) is used.
Apperrently the wrong syntax is used:
gdb-set-env TRACE_MODE=4    does not work
set environment TRACE_MODE 4    without '=' does work

In fact a bug in Gdb since it's working syntax


2. Writing to standard error doees not work when debugging an application. This is an extremely annoying bug, since developpers depend on error message reporting from the program under development.

Bugs 1 and 2 can be reproduced with a simple modified Hello World program.

#include <cstdio>
#include <cstdlib>
#include <iostream>
using namespace std;

int main() {
	char *name= getenv("TRACE_MODE");
	fprintf(stderr, "fprintf C alike error reporting\n");
	cerr << "!!!Hello World!!! of errors  "<< name<< endl; 
	return 0;
}

Build and run and debug it. It works when running at full speed, but not when debugging it (invoking the gdb debugger)
Comment 1 mijs tonen CLA 2010-11-21 11:49:47 EST
#include <cstdio>
#include <cstdlib>
#include <iostream>
using namespace std;
int main() {
	char *name= getenv("TRACE_MODE");
	fprintf(stderr, "fprintf C alike error reporting\n");
	cerr << "!!!Hello World!!! of errors  "<< name<< endl; 
	return 0;
}
Comment 2 Doug Schaefer CLA 2011-05-24 11:04:41 EDT
Not sure why I'm assigned this bug.
Comment 3 Marc Khouzam CLA 2011-05-24 11:57:04 EDT
(In reply to comment #0)

For next time, please use two different bugs to report two different problems.

>  1. Environment variables set in for debugging are not set in the debugged
> process,
>     apperrently the command used to instruct GDB is wrong.
> 
>     gdb set env (or set environment) does not set the environment variable
> within the debugged process, not even if the gdb commandline insterface
> (without eclipse interference) is used.
> Apperrently the wrong syntax is used:
> gdb-set-env TRACE_MODE=4    does not work
> set environment TRACE_MODE 4    without '=' does work
> 
> In fact a bug in Gdb since it's working syntax

You can set environment variables for your debugged process by using the Environment tab of the launch.

> 2. Writing to standard error doees not work when debugging an application. 

This was just fixed in bug 327617.
I'm marking this bug as a duplicate.

If the environment part of the bug is still a problem, please open a new bug for that issue specifically.

*** This bug has been marked as a duplicate of bug 327617 ***