Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 369720 - gdb messed up with standard output
Summary: gdb messed up with standard output
Status: CLOSED DUPLICATE of bug 327766
Alias: None
Product: CDT
Classification: Tools
Component: cdt-debug (show other bugs)
Version: 8.1.0   Edit
Hardware: PC Windows 7
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: cdt-debug-inbox@eclipse.org CLA
QA Contact: Doug Schaefer CLA
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-01-25 13:27 EST by Andreas Emmerling CLA
Modified: 2012-02-23 11:30 EST (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Andreas Emmerling CLA 2012-01-25 13:27:10 EST
Build Identifier: 20110916-0149

Hi!

I have the problem that after printing something to the standard out without a newline, a following breakpoint is not hit by gdb. Actually it is hit by gdb but Eclipse doesn't recognize it.

example code

#include <stdio.h>
#include <stdlib.h>
int main(int argc, char** argv)
{
	setvbuf(stdout, NULL, _IONBF, 0);
	setvbuf(stderr, NULL, _IONBF, 0);

	printf("Hello");
	printf("\n");
	printf("Hello\n");

	return 0;
}

If you put a breakpoint at line "printf("\n");" it will not be hit. Instead I have the following output in the console:

Hello*stopped,reason="breakpoint-hit",disp="keep",bkptno="2",frame={addr="0x00401421",func="main",args=[{name="argc",value="1"},{name="argv",value="0x8f16e0"}],file="..\main.c",fullname="<mypath>\main.c",line="15"},thread-id="1",stopped-threads="all"

and then gdb stops the program but eclipse doesn't think the breakpoint was hit so I have no chance to run it further and I have to terminate the program.

I can be solved bei either the following:
Comment the setvbuf calls like the following (this is actually not an option for me)
	//setvbuf(stdout, NULL, _IONBF, 0);
	//setvbuf(stderr, NULL, _IONBF, 0);

or changing the prints such that all prints have a newline:
	printf("Hello\n");
	printf("\n");
	printf("Hello\n");

I'm using MinGW toolchain (the latest from the installer, with gdb 7.3.1) on Windows.

Reproducible: Always

Steps to Reproduce:
See description
Comment 1 Marc Khouzam CLA 2012-01-26 09:41:30 EST
Try adding 
  set new-console on
to you gdbinit file.

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