Author Topic: Crazy breakpoints  (Read 4278 times)

Offline KirkD

  • Multiple posting newcomer
  • *
  • Posts: 77
Crazy breakpoints
« on: March 14, 2007, 04:54:11 pm »
I've got a project in which the breakpoints are behaving strangely.  If I set a breakpoint, the code actually stops about 4 lines below the indicated breakpoint, and I get lots of stops in library code (stl library files, etc.).  Is there a way to clear all breakpoints so that only my newly set ones behave properly?

Offline thomas

  • Administrator
  • Lives here!
  • *****
  • Posts: 3979
Re: Crazy breakpoints
« Reply #1 on: March 14, 2007, 07:39:58 pm »
If execution stops a few lines after your breakpoint, that is most likely because you set a breakpoint in a line that does not produce code. It sounds like a banality, but breakpoints really only work where there is a corresponding assembler instruction.

For example if you have this:
Code
int foo;
int bar;
foo = 5;
and you set a breakpoint in the first line, it will break in the third line, as this is the only one that actually maps to an instruction.

Regarding your second question, there is a "clear all" menu item in the context menu.
"We should forget about small efficiencies, say about 97% of the time: Premature quotation is the root of public humiliation."

Offline KirkD

  • Multiple posting newcomer
  • *
  • Posts: 77
Re: Crazy breakpoints
« Reply #2 on: March 14, 2007, 10:26:38 pm »
I agree 100% with the banality issue - I wouldn't expect a breakpoint to work on a declaration line or other non-code producing line.  I also still notice that some breakpoints remain active, even after they've been cleared (using the left border to clear them) and some newly set breakpoints don't function.

I'll give the "clear all breakpoints" option a try...

I looked in the context menu (right click, correct?) and I do not have a clear all breakpoints option.  I've using SVN3455 - is this option in a later version??

« Last Edit: March 14, 2007, 10:28:32 pm by KirkD »

Offline KirkD

  • Multiple posting newcomer
  • *
  • Posts: 77
Re: Crazy breakpoints
« Reply #3 on: March 15, 2007, 04:55:55 pm »
Here's an example as best as I can describe it.  If I set a breakpoint on line 2 the debugger actually stops there - no problem.  If I then click on Next Line in the debugger menu, you would expect it to go to Line 3, right?  But the file stl_iterator.h opens and I'm on line 603:

__normal_iterator(const _Iterator& __i) : _M_current(__i) { }

Next line then goes to line 666 in this file.  Next Line then opens stl_vector.h at line 375.  Next Line then ends up in my code corresponding to the call from line 194.  Next Line then goes to line 195.  I then make excursions through stl_iterator.h, stl_vector.h, new_allocator.h, basic_string.h.

If I then put a breakpoint on line 241, it is ignored.  Also, a breakpoint on line 245 is ignored despite the fact that the conditional on line 241 is guaranteed to succeeed.

To get the debugger to stop on line 245, I have to stop the debugger, clear higher breakpoints, put a breakpoint on line 245, and restart in Debug mode.  Next Line then follows this sequence of lines:  245, 246, 251, 245, 251, 252, another .h file of mine UNRELATED to Line 252 and not having any breakpoints set, 251, yet another file of mine with no breakpoints set, 252, a long excursion thorugh other files of mine unrelated to line 252, and eventually settling on line 81.

What is going on here???

Code
1	PowerUpControllers = *(m_pWorld->GetPowerUpControllers());
2     for (index = 0; index < PowerUpControllers.size(); index++)
3     {
4         if ( Params.GetLongParam("PowerUpXY") == 1 )
5         {
6             PowerUpControllers.at(index)->GetPosition(X,Y);
7             inputs.push_back(X/16);
8             inputs.push_back(Y/16);
9         }
10         if ( Params.GetLongParam("PowerUpState") == 1 )
11         {
12             PowerUpControllers.at(index)->GetState(state);
13             inputs.push_back(state);
14         }
15     }
16
17     m_pWorld->GetPacManController()->GetPosition(X,Y);
18     if ( Params.GetLongParam("PacManXY") == 1 )
19     {
20         inputs.push_back(X/16);
21         inputs.push_back(Y/16);
22     }
23
24     if ( Params.GetLongParam("CheckForWalls") == 1 )
25     {
26         if ( m_pWorld->GetMazeController()->CheckMapByPixels(X,X+31,Y-8,(Y-8)+31) )
27             inputs.push_back(0);  //nothing in the up direction
28         else
29             inputs.push_back(1);  //a wall is in the way
30
31         if ( m_pWorld->GetMazeController()->CheckMapByPixels(X,X+31,Y+8,(Y+8)+31) )
32             inputs.push_back(0);  //nothing in the down direction
33         else
34             inputs.push_back(1);  //a wall is in the way
35
36         if ( m_pWorld->GetMazeController()->CheckMapByPixels(X-8,(X-8)+31,Y,Y+31) )
37             inputs.push_back(0);  //nothing in the left direction
38         else
39             inputs.push_back(1);  //a wall is in the way
40
41         if ( m_pWorld->GetMazeController()->CheckMapByPixels(X+8,(X+8)+31,Y,Y+31) )
42             inputs.push_back(0);  //nothing in the right direction
43         else
44             inputs.push_back(1);  //a wall is in the way
45     }
46
47     //use the starting variables to limit the number of times we check the dot content
48     if ( Params.GetLongParam("CheckDots") == 1 )
49     {
50         if ( abs(StartingX - X) > 32 || abs(StartingY - Y) > 32 )
51         {
52             StartingX = X;
53             StartingY = Y;
54
55             //only update the number of dots every 8 steps
56             //profiling suggested this would be a good place to save computation time
57             rct.top = 0;
58             rct.bottom = (Y+31)/16;
59             rct.left = 0;
60             rct.right = m_pWorld->GetDotController()->GetWidth()-1;
61             DotsUp = m_pWorld->GetDotController()->CountTilesOfType(rct, 1);
62
63             rct.top = (Y/16);
64             rct.bottom = m_pWorld->GetDotController()->GetHeight()-1;
65             DotsDown = m_pWorld->GetDotController()->CountTilesOfType(rct, 1);
66
67             rct.top = 0;
68             rct.right = (X+31)/16;
69             DotsLeft = m_pWorld->GetDotController()->CountTilesOfType(rct, 1);
70
71             rct.left = (X/16);
72             rct.right = m_pWorld->GetDotController()->GetWidth()-1;
73             DotsRight = m_pWorld->GetDotController()->CountTilesOfType(rct, 1);
74         }
75
76         //push the number of dots in
77         inputs.push_back( DotsUp );
78         inputs.push_back( DotsDown );
79         inputs.push_back( DotsLeft );
80         inputs.push_back( DotsRight );
81     }