3

How do you trace all the methods invoked across different files in a particular user flow ?

Putting breakpoints at different points and observing the backtrace does not seem like the most efficient way.

Instead I would like to -

1) Put a breakpoint across all methods in the interested project.

2) Make all the breakpoints run a debugger command which prints out the file name and method name.

3) Edit the breakpoints such that the program continues to execute after a breakpoint is hit. (This option is available when you edit a particular breakpoint.) So we don't stop at any breakpoint.

4) Disable all the breakpoints until I reach the flow I need to work on.

5) Enable all the breakpoints right before starting the flow. With this approach, we don't have to manually put breakpoints at different places to understand the execution flow. Once the flow is complete, I can just look at the debugger console and figure out the execution flow.

Now, the question - How can we do this using lldb commands? Would appreciate any input/suggestions.

1
  • Consider dtrace (possibly w/ Instruments) Commented May 25, 2016 at 5:35

3 Answers 3

2

You can't do this with the Xcode breakpoint interface, but in the lldb console you can do:

(lldb) break set -r . -s AppName
Breakpoint 1: 478 locations.
(lldb) br com add
Enter your debugger command(s).  Type 'DONE' to end.
> bt 
> continue 
> DONE
(lldb)

That sets a "symbol name match regular expression breakpoint" on all names ("." matches everything) in the binary/shared library called AppName. If you leave off the -s option, it will match all symbols everywhere. That will work but quite slowly...

The command prints a backtrace and continues.

This makes just ONE breakpoint, so you can do:

(lldb) break disable 1

Till you need it, and then enable it with:

(lldb) break enable 1

If you only want to catch some methods, you can adjust the regular expression, and if you find you aren't interested in some of the places you are hitting, you can individually disable locations within the breakpoint you've made this way.

(lldb) break list 1

Will show you all the locations, and:

(lldb) break disable 1.2-1.10 1.15

etc. will disable the locations.

This might get a little slow, because your app will be starting & stopping all the time. But it will do what you are asking.

Sign up to request clarification or add additional context in comments.

Comments

0

You can put breakpoints on all methods in different files, and to trace how execution happens within that method click on Stepover.

Step over -  shortcut - f6, it stops execution at next loc.

Also alternatively you can check value of particular variable or array by typing "po VariableName" in output window.

Comments

0

you can add related methods name through adding the symbol exception breakpoints.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.