skip to Main Content

I apologize in advance, this will be a very basic & general beginner’s question:

Why is my debugger "breaking" on a line where I have not set a breakpoint?

Some more detail:

I’m working on a large buggy C++ project in XCode 12.4.

I’ve set a single breakpoint on function A. The debugger refuses to break on function A. Instead, it breaks consistently on function B. Function A and B exist on the same cpp file. I believe function B is supposed to be called AFTER function A, but they definitely do not call each other and are not called simultaneously.

I’ve definitely experienced the debugger stopping on various errors, but with a RED highlight, not a GREEN one – as I understand it the GREEN highlight only happens on a breakpoint I set myself.

Is this expected behavior? Am I missing something obvious?

(First post, please tell me if I’m doing anything wrong!)

EDIT: I solved & answered my own question below!

2

Answers


  1. Chosen as BEST ANSWER

    These are all great responses and I learned a lot from them all - but it turns out the answer was much dumber.

    For whatever reason, when I compiled, XCode did not delete the previously compiled binary. As for my breakpoint issue, I'm still not 100% sure what was happening, but it is solved now.

    Here's how I noticed: Function A did not exist when I compiled it last time. I had created a String in function A. This string assignment returned a bad access error - so I assume it was assigned outside the program I was debugging!

    Thank you to responders!


  2. The most common cause of the debugger pausing at a place where you didn’t set a breakpoint is the throwing of an exception. Some exceptions crash the program, which is where you get the red highlight in the debugger. Some exceptions don’t crash the program. In those cases the debugger highlights the exception breakpoint in green.

    If the debugger pauses your program with a green highlight, click the Continue Execution button (it’s the second button from the left in the group of debugging buttons right below the source code editor) or choose Debug > Continue in Xcode to continue running the program.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search