Author Topic: breakpoint error on the debugger branch  (Read 2999 times)

Offline killerbot

  • Administrator
  • Lives here!
  • *****
  • Posts: 5491
breakpoint error on the debugger branch
« on: June 11, 2011, 01:19:13 pm »
Code
#include <iostream>

using namespace std;

int main()
{
int x = 0;
while(true)
{
if(x % 10)
{
cout << "Hello world!" << endl;
}
++x;
}
    return 0;
}

* put breakpoint on line 16 [return 0;]
* start debugger
==> it stops twice at line 17 [}]

Code
Active debugger config: GDB debugger:Default
Building to ensure sources are up-to-date
Selecting target:
Debug
Adding source dir: C:\Projects\BreakPointTest\
Adding source dir: C:\Projects\BreakPointTest\
Adding file: C:\Projects\BreakPointTest\bin\Debug\BreakPointTest.exe
Changing directory to: C:/Projects/BreakPointTest/.
Starting debugger: C:\MinGW32\bin\gdb.exe -nx -fullname  -quiet -args C:/Projects/BreakPointTest/bin/Debug/BreakPointTest.exe
done
Registered new type: wxString
Registered new type: STL String
Registered new type: STL Vector
Setting breakpoints
Debugger name and version: GNU gdb (GDB) 7.2
Child process PID: 3452
At C:\Projects\BreakPointTest\main.cpp:17
Continuing...
At C:\Projects\BreakPointTest\main.cpp:17
Continuing...

This only happens when there's a breakpoint at that line 16 (I guess, the line before the end). When you remove the breakpoint at line 16, and put it somewhere else, all is fine.

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: breakpoint error on the debugger branch
« Reply #1 on: June 11, 2011, 01:58:40 pm »
What is the raw/debug log looking like?

Also what happens in the trunk version or when you try gdb from command line?

p.s. You can look at the callstack to see if there are more functions above main.
      Sometimes stepping out of the main function goes to other system/runtime functions, but there are no symbols for them and C::B tries to be smart by setting the active frame the one with valid symbols.
« Last Edit: June 11, 2011, 02:01:20 pm by oBFusCATed »
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5915
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: breakpoint error on the debugger branch
« Reply #2 on: June 11, 2011, 02:09:30 pm »
@killerbot, I can confirm this bug.
The strange thing is the breakpoint was reached before the while loop, and the breakpoint meet twice.
I think it is a gcc error which give wrong symbol/line information. :D
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.