I am using Xcode and would like to set a breakpoint that speaks an NSString from my code. What I am doing is setting the breakpoint, then editing it. I add a "Shell Command" action. The first argument is say
and the second argument is where i'm having trouble.
NSString *myString = @"This is a test";
If I put @myString@
as the second argument, it reads out the memory address. ex. 0x0b4be130
If I try @[myString UTF8String]
, it gives me a another memory address.
If I dereference myString, @*[myString UTF8String]@
, it only gives me the first character of the string.
How do I do this properly?
LLDB actually has an inbuilt Python interpreter, with the entire LLDB library exposed to it. You can access this with the script
debugger command. With this, we can more easily grab a string representation of a variable in the frame, and send it to the OS say command. Add a debugger action:
script os.system("say " + lldb.frame.GetValueForVariablePath("myVariable").description)
to achieve what you want. You can even wrap up Python scripts as new LLDB "commands", so you can create a debugger command called say
that explicitly says the underlying objects description; have a look at http://lldb.llvm.org/python-reference.html for an introduction on setting these type of scripts up.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With