在Xcode中使用LLDB调试时如何更改变量值? [英] How to change variables value while debugging with LLDB in Xcode?
问题描述
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)帮助expr
计算当前的C/ObjC/C ++表达式 程序上下文,使用当前作用域中的变量.这个命令 接受原始"输入(无需引用内容).
(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).
语法:表达式-
命令选项的用法:表达式[-f] [-G] [-d] [-u]-表达式[-o] [-d ] [-u]-表达式
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.
示例:
expr my_struct-> a = my_array [3]
expr -f bin-(索引* 8)+ 5
expr char c [] ="foo"; c [0]
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'是'expression'的缩写
'expr' is an abbreviation for 'expression'
这篇关于在Xcode中使用LLDB调试时如何更改变量值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!