4
votes

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

3
I'm having the same problem. Do let me know if you find or have found a solution.Cliff

3 Answers

1
votes

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
0
votes

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

0
votes

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