Say I am debugging. Say I need to know what the value of [somevariable count]
How would I do so?
Evaluate a C/ObjC/C++ expression in the current program context, using user defined variables and variables currently in scope. This command takes 'raw' input (no need to quote stuff). -G <gdb-format> ( --gdb-format <gdb-format> ) Specify a format using a GDB format specifier string.
Right click in the local variables window to see the "Watch Expression" menu command. Type the variable name and the variable will be added.
LLDB is the system debugger on macOS, iPadOS, iOS, tvOS, and watchOS. It can also be used for Objective-C and Swift development for architectures: x86_64. i386, ARM and AArch64, and default debugger in Xcode on macOS. It supports debugging on desktop, in simulators and devices.
Use the bt command in (lldb). Once paused or after a crash, just type bt into the debug console. It will print the full stack trace. Awesome tip for tracking down a constraint issue after setting the symbolic breakpoint.
If what you want to do is know the value of the expression while program execution is halted, then do something like
> p (int)[somevariable count]
in the gdb console.
Note: People searching for the term "watch" might be expecting an answer about being able to observe when a value changes. For that question these are some answers that are more appropriate:
Watching variables in Xcode
Xcode LLDB watchpoints
Put a breakpoint on the relevant code line. When Xcode stops on that line, in the debug area (the bottom of the screen is splitted to two parts, look at the right one, if you don't see the bottom part, shift+cmd+Y, plus sometimes the right side or the left side are hidden and there are small buttons on the right bottom side to show them), you see all of the local and global variables. Right click (or two fingers) that debug area, and you will see a context menu with one of the options "add expression". Type in your expression.
Note: above previous user's comment about the word "watch" is pretty clear to whomever comes from any other IDE but not in Xcode.
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