4

I just discovered (thanks to another very helpful post) that I can use GDB commands to create breakpoints that log information to the GDB console, whether debugging on the device or simulator. This is like NSLog, but much nicer in that you don't have to wait for the console to catch up, you don't have annoying timestamps, and you can turn them on/off at run time via the XCode breakpoint view).

Very nice, and I invested time figuring out how best to log messages and variables together. (Use the GDB command po [NSString stringWithFormat: @"Your message: %d %@",variable,[[object expression] description]]) for maximum versatility.

Everything worked wonderfully in the simulator. When I finally got around to device debugging, I was getting the messages just fine, but GDB was STOPPING on every breakpoint despite the fact that I configured them to auto-continue by checking the box in the breakpoint view.

I tried adding a "continue" commmand to each breakpoint, and it worked but GDB also started spewing information about every breakpoint hit and telling me "Continuing" after every line.

My questions:

  1. Does this happen for you?
  2. Can I change something so that auto-continue also works on the device
  3. Can I tell GDB to be less verbose and only give me the output I print?

Please help!!

David

1
  • I'm having the same problem. Do let me know if you find or have found a solution. Commented Jun 30, 2011 at 22:40

3 Answers 3

1

I've run into the same behavior. It turned out that XCode had duplicated the breakpoint at the intended line. Perhaps there's a bug where a left click occasionally adds a hidden breakpoint rather than disabling?

The solution was this:

  1. Select the "Breakpoint Navigator" tab of the Navigator frame on the left
  2. Look for duplicate breakpoints either manually or by entering the class name in the search box at the bottom of the Navigator. (remember that multiple project sections of the list may both contain a breakpoint for the same class)
  3. Right-click on one and select Edit to figure out if it's the continue or not.
  4. Right-click on the unwanted breakpoint and delete
Sign up to request clarification or add additional context in comments.

Comments

0

David,

There are some useful console commands that you might want to familiarize yourself with.

info b (lists all breakpoints)
ena (enables all breakpoints)
dis (disables all breakpoints)
ena X (enable breakpoint number X)
dis X (disable breakpoint number X)

GDB also supports conditional breakpoints:

cond X [condition]

And, commands to execute automatically when a breakpoint is hit:

command X 

Aaron

4 Comments

what would the gdb syntax be for logging a varaible "var" and executing the continue command in a given breakpoint?
p var (and on a new line) cont
I'm sorry, I already know how to log vars. I was actually looking for the gdb auto-continue syntax.
you would enter: command [breakpoint number] followed by the prior commands that I provided.
0

Another very useful option is a watchpoint - break only when given expression changes.

1 Comment

watchpoints and conditionals are extremely unreliable in current XCode. I've also had hit or miss issues with auto-continue.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.