查看调用堆栈中的 objc 调用 [英] See objc calls in call stack

查看:71
本文介绍了查看调用堆栈中的 objc 调用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在调试一个 Objective-C 应用程序,并希望看到 ObjC 库中的方法调用(用于教育目的!).这样做的最佳方法是什么?

I am debugging a Objective-C application and would like to see the method calls in the ObjC library (for educational purposes!). What is the best way of doing this?

推荐答案

// print a stacktrace
NSLog(@"%@", [NSThread callStackSymbols]); // requires iOS 4

// print stacktrace using C functions
#import <execinfo.h>
#import <unistd.h>
void PrintStackTrace() {
  void *stackAdresses[32];
  int stackSize = backtrace(stackAdresses, 32);
  backtrace_symbols_fd(stackAdresses, stackSize, STDOUT_FILENO);
}

或在 XCode 中设置断点以暂停执行,然后在控制台中键入 GDB 命令或仅查看调试导航器选项卡中的堆栈.

or set a breakpoint in XCode to pause the execution and then type GDB commands in the console or just look at the stack in the debug navigator tab.

这篇关于查看调用堆栈中的 objc 调用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆