0

I have an array which I would like to print out in a breakpoint. I have read about how to do this with @exp@, so I've created a Log Message breakpoint like so:

%B %H count: @(NSUInteger)[myArray count]@ objects: @(const char *)[[myArray description] UTF8String]@

And here's what that prints:

-methodName: 33 count: 1 objects: 0x6dec5890

From everything I've read, this should print out a string containing the objects in myArray. And yet, clearly that's not happening. What am I doing wrong?

I'm using LLDB on Xcode 5.0.2. And if it matters, the app is 32-bit.

Nick K9
  • 3,885
  • 1
  • 29
  • 62
  • I could reproduce your problem. It seems that the "Breakpoint Log Message" feature has several problems. Compare http://stackoverflow.com/questions/8059919/how-to-create-a-breakpoints-log-message-action-in-xcode for another problem, with a possible workaround. – Martin R Dec 14 '13 at 16:16
  • Thanks for the commiseration. Indeed, I couldn't get the logging to work so this is what I ended up going with in a Debugger Command: `expr (void)NSLog(@"%@ -- count:%u objects [%@]", (NSString *)NSStringFromSelector(_cmd), (unsigned)[myArray count], myArray)` Of course, this doesn't give me the breakpoint count. `:-(` – Nick K9 Dec 14 '13 at 19:31
  • 2
    If anyone at Apple cares, I've filed radar://15663740. – Nick K9 Dec 14 '13 at 19:41

3 Answers3

1

This bug has been fixed in recent versions of Xcode. (I'm on 6.1.1) Now you just need to put an array's name in between @s to get the expected output. No casting needed!

%B %H count: @myArray.count@ objects: @myArray.description@

Output:

-applicationDidFinishLaunching: 1 count: 2 objects: @"(\n    one,\n    two\n)"

A little messy with the encoded newlines, but at least it works!

Nick K9
  • 3,885
  • 1
  • 29
  • 62
0

Why not create a Python breakpoint action that prints the variables you care about, and then automatically continues?

Enrico Granata
  • 3,303
  • 18
  • 25
  • Care to provide some code which explains what you mean? Be sure to specify whether it's using a Debugger Command action or a Log Message action. I'd prefer the latter, since it has access to the %B count variable. – Nick K9 Feb 01 '14 at 22:38
-2

I can't understand what you are doing. When I want to print or preview a variable in my code, I add a breakpoint just after my variable. When the breakpoint is reached, I just move the pointer over the name of the variable and a little window will appear where I can see the content of your variable.

Take a look at this answer: XCode 5 View Debugging Feature

Community
  • 1
  • 1
BalestraPatrick
  • 9,944
  • 4
  • 30
  • 43
  • 4
    Thank you, but the variables I'm looking for data about can be hit multiple times per second. Unfortunately, breaking on each one and hovering isn't practical in my case. – Nick K9 Dec 14 '13 at 19:29