1

How can I trace the method calls and their sequence while a iPhone app is running? Which Instrument I should use?

Abhinav
  • 37,684
  • 43
  • 191
  • 309

2 Answers2

0

you can also use

NSLog(@"%s",__PRETTY_FUNCTION__);

to print the method that is currently running

Johnykutty
  • 12,091
  • 13
  • 59
  • 100
0

No Instrument does this directly. A couple of options to get this kind of information:

1) Set a breakpoint in the debugger. You can then trace the execution with the "step over" "step into" and "step out" buttons.

2) Put NSLogs at the places in your code that interest you:

-(void) someMethod {
  NSLog (@"Starting someMethod");
  // rest of the method is here
}

You can then read the NSLogs in the console.

William Jockusch
  • 26,513
  • 49
  • 182
  • 323
  • That is fine with situation where I am tracing my own code. Actually, I wanted to delve into a code written by someone else and wanted to understand the code flow. Since it is a huge code base none of these approaches will help me. Any other alternative please? – Abhinav Sep 16 '10 at 19:43
  • Diving into other peoples' code is always a challenge. There are no easy answers. In addition to the above techniques, I often try tweaking small stuff to see if the impact is what I think it is. Start with really small stuff like string constants and #defines; then move up to changing utility functions, and from there to the larger methods of the code. – William Jockusch Sep 16 '10 at 19:59
  • Using the debugger will work just as well when tracing debug builds with source code written by someone else. – hotpaw2 Sep 16 '10 at 20:12