0

Seems lldb can only use frame variable to introspect variable whether with debug info or on the start of the method call.

But sometimes our code will break on some system or third lib, we may want to introspect the variable or stack. I find a solution for this, Disassemble the frame, read the assemble code and introspect the stack manually.

But I can't find a quick way to get the frame's stack when it's not on the topmost. Any simple way to do this in lldb or in Xcode.


I found a project in github claimed that can dump all stack memory. So can I use some native lldb command to dump the stack memory of a method call?

Karl
  • 665
  • 4
  • 19

1 Answers1

0

It sounds to me like the Python API's to lldb will be best suited to the kind of investigation you want to do:

http://lldb.llvm.org/python_reference/index.html

You want the CFA, then, which you can get from the Python API with SBStackFrame.GetCFA(). The CFA (Call Frame Address) will be the stack frame address when the function was entered. From there to the next younger frame's CFA is the stack memory used by this frame.

You can use SBProcess.ReadMemory to get at the memory.

Jim Ingham
  • 25,260
  • 2
  • 55
  • 63
  • No reason but resources. It's not all that common thing to do; this is the first request I've heard for this as a command. If you file a enhancement request for it at the lldb.llvm.org bug reporter, somebody will get to it when they have time. But one of the motivations for the LLDB Python API's was so that you could add this sort of functionality w/o having to wait on the resources of the lldb developers. – Jim Ingham Dec 19 '16 at 20:13