开发者

See objc calls in call stack

开发者 https://www.devze.com 2023-03-01 05:36 出处:网络
I am debugging a Objective-C application开发者_Go百科 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

I am debugging a Objective-C application开发者_Go百科 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

or

// 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);
}

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消