Does LLDB have convenience variables ($var)?

风格不统一 提交于 2019-12-03 02:12:54

问题


Does LLDB have convenience variables? If so, how do I use them? If no, is there any similar things to use?

Reference: http://software.intel.com/sites/products/documentation/hpc/atom/application/debugger/commands143.html


回答1:


I finally figured it out myself. Run help expr in LLDB and you will see:

User defined variables: You can define your own variables for convenience or to be used in subsequent expressions. You define them the same way you would define variables in C. If the first character of your user defined variable is a $, then the variable's value will be available in future expressions, otherwise it will just be available in the current expression.

So expr int $foo = 5 is what I want.




回答2:


I struggled with this today. Here's what it looks like to deal with Objective-C variables in LLDB:

expr UIApplication *$app = (UIApplication *)[UIApplication sharedApplication]
expr UIWindow *$keyWindow = (UIWindow *)[$app keyWindow]

etc. I've found LLDB works best if you don't nest any calls, and you explicitly give a return type on every call.

Still I am getting a segmentation fault when I try to make initWithFrame: work on a UIView later on though. :/




回答3:


Just use the form:

(lldb) expr var

From their tutorial:

(lldb) expr self
$0 = (SKTGraphicView *) 0x0000000100135430
(lldb) expr self = 0x00
$1 = (SKTGraphicView *) 0x0000000000000000

You can also call functions:

(lldb) expr (int) printf ("I have a pointer 0x%llx.\n", self)
$2 = (int) 22
I have a pointer 0x0.
(lldb) expr self = $0
$4 = (SKTGraphicView *) 0x0000000100135430


来源:https://stackoverflow.com/questions/11192511/does-lldb-have-convenience-variables-var

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!