0

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?

xiaoyu2006
  • 507
  • 7
  • 20
  • 2
    I don't know lldb, but normally when running under a debugger there's a way to pause your program. In command-line gdb, this would be Ctrl+C, and in an IDE there's probably a button. Then you can inspect the call stack and continue running. – Thomas Jan 17 '20 at 08:49

1 Answers1

2

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.

Jim Ingham
  • 25,260
  • 2
  • 55
  • 63
  • If you are familiar with gdb, there's a page here: https://lldb.llvm.org/use/map.html that has a map from most of the common gdb commands to their lldb equivalents. – Jim Ingham Jan 17 '20 at 19:45