xiaoyu2006
xiaoyu2006

Reputation: 545

How to find where my code is running with lldb

I have a big project (more specifically LibO). While reading the whole docs and code costs too much time, I just want to know where my code is running without setting breakpoints because I know a little about the project.

That is, I want a command that pauses the program and shows the whole calling stack. Is there anything like it?

Upvotes: 0

Views: 430

Answers (1)

Jim Ingham
Jim Ingham

Reputation: 27110

This is pretty much the same between gdb and lldb. On the command line ^C interrupts the process, bt backtraces the current thread, bt all does the same for all the threads.

Note you can also easily get a picture over time of what code is used in an app by running the "sample" tool from the command line, like:

$ sample ProcessName

That will interrupt the program you specify every 10 milliseconds for 10 seconds (you can change those numbers by passing time and interval as extra arguments) and then write out a report of all the stacks it saw in that time.

Upvotes: 2

Related Questions