[lldb-dev] Frame documentation
jason at molenda.com
Sat Nov 29 15:49:34 PST 2014
There is API documentation, I think it would help to answer some of these questions. From within lldb you can do
(lldb) script help (lldb.SBLineEntry)
There's a copy of the documentation at http://lldb.llvm.org/python_reference/index.html although the one in lldb is the most up-to-date.
The methods on the SBFrame object should do everything you want.
Process 98511 stopped
* thread #1: tid = 0x1b8a20, 0x0000000100000eba a.out`main(argc=1, argv=0x00007fff5fbffb40) + 122 at a.c:11, queue = 'com.apple.main-thread', stop reason = step over
#0: 0x0000000100000eba a.out`main(argc=1, argv=0x00007fff5fbffb40) + 122 at a.c:11
8 for (int i = 0; i < arrsize; i++)
9 for (int j = 0; j < arrsize; j++)
-> 11 buf[i*j] = accum++;
14 return buf[(arrsize * arrsize) - 2] + printf ("%d\n", buf[(arrsize * arrsize) - 3]);
(lldb) fr v
(int) argc = 1
(char **) argv = 0x00007fff5fbffb40
(const int) arrsize = 10
(int) accum = 1
(int) i = 0
(int) j = 0
>>> print lldb.frame.GetLineEntry().IsValid()
>>> print lldb.frame.GetLineEntry().GetFileSpec().GetFilename()
>>> print lldb.frame.GetLineEntry().GetLine()
>>> print lldb.frame.GetFunction().IsValid()
>>> print lldb.frame.GetFunction().GetName()
>>> print lldb.frame.GetFunctionName()
>>> print lldb.frame.GetPCAddress().GetLoadAddress(lldb.target) - lldb.frame.GetFunction().GetStartAddress().GetLoadAddress(lldb.target)
>>> vars = lldb.frame.GetVariables(True, True, False, True)
>>> print vars.IsValid()
>>> print vars.GetSize()
>>> print vars.GetValueAtIndex(0).GetName()
Note that I'm using "lldb.frame" in these examples. This is only defined in interactive scripting mode, along with lldb.thread, lldb.process, lldb.target. For Python commands that you're writing, you'll be passed in a 'debugger' object and you can do things like
if debugger and debugger.GetSelectedTarget() and debugger.GetSelectedTarget().GetProcess():
process = debugger.GetSelectedTarget().GetProcess()
if process and process.GetSelectedThread().IsValid():
thread = process.GetSelectedThread()
frame = thread.GetFrameAtIndex(0)
There's a newer alternate format for python commands where it gets passed in a symbol context (which would give you the frame, thread, process, target all in one) but I don't remember the format for that off-hand.
> On Nov 29, 2014, at 2:51 PM, Jose H <jose.francisco.hevia at gmail.com> wrote:
> Continuing with my GUI program, where can I find information or
> documentation about the frame format and what everything represents?
> There is a lack of documentation in the code, it makes a lot of
> assumptions about what every thing means. I wonder where this
> assumptions come from.
> For instance, what SBLineEntry means? The documentation lacks detail.
> If I do:
> line_entry = frame.GetLineEntry();
> uint32_t line = line_entry.GetLine();
> SBFileSpec source = line_entry.GetFileSpec();
> I suppose line_enty represents the line entry of the frame in the
> source code, and source the source code original file.
> I could follow all this code with script and guess most of the
> meaning, but it is a lot of work just manually traversing all possible
> combinations to know what everything means.
> Is there any better way?
> I want to travel around functions instead of code. I mean I want to
> display just a function and the line offset of the current program
> counter in source code with the start of the function as reference,
> probably pc-offset works with this.
> Also I need to display all the variables of the frame, and to know the
> type of every variable, the address pointers point to and a fast way
> to access those pointers(I mean getting the real address, not the
> ascii representation).
> I have this feeling that there is something obvious I don't know that
> makes my work unnecessary slow.
> lldb-dev mailing list
> lldb-dev at cs.uiuc.edu
More information about the lldb-dev