在Xcode中使用LLVM调试时如何更改变量值? [英] How to change variables value while debugging with LLVM in Xcode?
问题描述
在Xcode中,GDB允许您在调试时更改局部变量(请参阅如何在XCode中调试时更改NSString值? LLDB提供了类似的功能吗?如果是这样,我们该怎么用呢?
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
评估当前的C / ObjC / C ++表达式
程序上下文,使用当前范围内的变量。这个命令
采用'raw'输入(不需要引用东西)。
(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).
语法:expression -
Syntax: expression --
命令选项用法:表达式[-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 - (index * 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]
重要提示:由于此命令采用raw输入,如果使用任何命令选项,则必须在
命令选项和原始输入的开始。
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中使用LLVM调试时如何更改变量值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!