在 Xcode 中使用 LLDB 进行调试时如何更改变量值? [英] How to change variables value while debugging with LLDB in Xcode?
问题描述
在 Xcode 中,GDB 允许您在调试时更改局部变量(参见 如何在 XCode 中调试时更改 NSString 值?).LLDB 是否提供类似的功能?如果是这样,我们如何使用它?
expr myString = @"Foo"
<块引用>
(lldb) 帮助表达式
评估当前的 C/ObjC/C++ 表达式程序上下文,使用当前范围内的变量.这个命令接受原始"输入(无需引用内容).
语法:表达式 --
命令选项用法:表达式 [-f ] [-G ][-d ] [-u ] -- 表达式 [-o] [-d] [-u ] -- 表达式
-G ( --gdb-format <gdb-format> )使用 GDB 格式说明符字符串指定格式.-d <布尔值>( --dynamic-value <boolean> )将表达式产生的值向上转换为其动态类型如果可供使用的话.-f <格式>( --format <格式> )指定用于显示的格式.-o ( --object-description )打印产生的值的对象描述表达.-u <布尔值>( --unwind-on-error <boolean> )如果表达式导致崩溃、断点,则清理程序状态击中或发出信号.
示例:
expr my_struct->a = my_array[3]
expr -f bin -- (index * 8) + 5
expr char c[] = "foo";c[0]
重要说明:因为此命令接受原始"输入,如果您使用任何命令选项,则必须在结尾之间使用--"命令选项和原始输入的开头.
'expr'是'表达式'的缩写
In Xcode, GDB allows you to change local variables while debugging (see how to change NSString value while debugging in XCode?). Does LLDB offer a similar functionality? If so, how can we use it?
expr myString = @"Foo"
(lldb) help expr
Evaluate a C/ObjC/C++ expression in the current program context, using variables currently in scope. This command takes 'raw' input (no need to quote stuff).Syntax: expression --
Command Options Usage: expression [-f ] [-G ] [-d ] [-u ] -- expression [-o] [-d ] [-u ] -- expression
-G <gdb-format> ( --gdb-format <gdb-format> ) Specify a format using a GDB format specifier string. -d <boolean> ( --dynamic-value <boolean> ) Upcast the value resulting from the expression to its dynamic type if available. -f <format> ( --format <format> ) Specify a format to be used for display. -o ( --object-description ) Print the object description of the value resulting from the expression. -u <boolean> ( --unwind-on-error <boolean> ) Clean up program state if the expression causes a crash, breakpoint hit or signal.
Examples:
expr my_struct->a = my_array[3]
expr -f bin -- (index * 8) + 5
expr char c[] = "foo"; c[0]IMPORTANT NOTE: Because this command takes 'raw' input, if you use any command options you must use ' -- ' between the end of the command options and the beginning of the raw input.
'expr' is an abbreviation for 'expression'
这篇关于在 Xcode 中使用 LLDB 进行调试时如何更改变量值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!