Xcode debugger stops when NOT going through break
195 MyModelItem *parentItem = thisItem->parent();
196 if(parentItem == NULL)
197 {
198 std::cout << "parentItem is NULL\n";
199 bool parentIsNull = true;
200 if(parentIsNull)
201 return QModelIndex();
202 return QModelIndex();
203 }
204 else if((unsigned int)parentItem == 0x4d0000)
205 {
206 std::cout << "parentItem is 0x4d0000\n";
207 return QModelIndex();
208 }
209 else if (parentItem == m_root)
210 return QModelIndex();
211
212 return createIndex(parentItem->row(), 0, parentItem);
213 }
I put a breakpoint on line 200 -- the one that is inside the if-clause and says:
bool parentIsNull = true;
There is a cout right above that line. So the breakpoint should not be triggered except when parentItem is NULL, and the debugger console should have the "parentItem is NULL" message logged to it.
But, in fact, the breakpoint gets triggered every single solitary time the function gets called. According to the GDB status reported on the debugger console, it claims that it has stopped at "Breakpoint 1" and that it is "Line 200". Line 200 is indeed the line that I put the breakpoint on, but the little red arrow is not on Line 200, it's on Line 204. If I single-step after the breakpoint stops, it goes to line 209, then the red arrow jumps to the "return" statement which is at the end of the previous function in the file, and then finally to line 213 -- which is one line after the actual return statement.
So does anyone know any way to get the debugger to behave? To only stop when the breakpoint in question actually gets triggered? It would be nice if the single-step behavior followed what code is supposed to be executing, but I would settle for not stopping at "phantom" triggers.
macbook pro, Mac OS X (10.5.4)