【问题标题】:Get method name and selectors in LLDB breakpoint获取 LLDB 断点中的方法名称和选择器
【发布时间】:2015-09-12 21:58:32
【问题描述】:

我正在像这样在 lldb 中添加一个断点:

(lldb) breakpoint set -s MyApp --func-regex .
(lldb) breakpoint command add 1
Enter your debugger command(s).  Type 'DONE' to end.
> p __PRETTY_FUNCTION__
> continue
> DONE
(lldb) process attach --name MyApp --waitfor
(lldb) continue

我的目标是打印我的应用程序中调用的每个方法。结果如下:

(lldb)  p __PRETTY_FUNCTION__
(const char [26]) $0 = "void $__lldb_expr(void *)"
(lldb)  continue
Process 96238 resuming
Command #1 'continue' continued the target.
(lldb)  p __PRETTY_FUNCTION__
(const char [47]) $1 = "-[AppDelegate($__lldb_category) $__lldb_expr:]"
(lldb)  continue
Process 96238 resuming
Command #1 'continue' continued the target.
(lldb)  p __PRETTY_FUNCTION__
(const char [47]) $2 = "-[AppDelegate($__lldb_category) $__lldb_expr:]"
(lldb)  continue
Process 96238 resuming
Command #1 'continue' continued the target.
(lldb)  p __PRETTY_FUNCTION__
(const char [47]) $3 = "-[AppDelegate($__lldb_category) $__lldb_expr:]"
(lldb)  continue
Process 96238 resuming
Command #1 'continue' continued the target.
(lldb)  p __PRETTY_FUNCTION__
(const char [47]) $4 = "-[AppDelegate($__lldb_category) $__lldb_expr:]"
(lldb)  continue

问题是如何删除 $__lldb_category$__lldb_expr: 以及方法名称的实际值及其选择器?

【问题讨论】:

  • @rmaddy 他没有“查看”任何堆栈跟踪:这些是打印并继续的断点
  • @matt 是的,现在我明白了。
  • 我希望获得函数调用的年表,并以一种简单的方式完成它,而不是在我的代码中放置大量 NSLog 语句。

标签: ios objective-c lldb


【解决方案1】:

我会使用 lldb 命令来打印这些信息,例如:

(lldb) frame info
frame #0: 0x0000000100018dc7 Sketch`main(argc=1, argv=0x00007fff5fbff628) + 55 at SKTMain.m:17

我会做你想做的事。如果您想要更多或更少的信息,您还可以按照此处所述定制帧信息的输出:

http://lldb.llvm.org/formats.html

【讨论】:

  • 你让我走上了正轨。我在 LLDB 中更改了frame info 格式,如下所示:settings set frame-format "${function.name}",然后将断点更改为具有命令frame info,我得到了我想要的。
猜你喜欢
  • 2015-01-12
  • 2020-03-15
  • 2017-05-10
  • 2020-01-04
  • 2020-11-11
  • 1970-01-01
  • 2013-09-12
  • 2017-07-27
  • 2012-11-24
相关资源
最近更新 更多