I need help with the SBValue class
used in the lldb
Python module which is used for creating scripts for lldb debugging sessions.
I am in t
You're looking for SBValue::GetChildAtIndex()
but you need to use the long form of that API. For instance, with a standalone user process C file,
#include
#include
#include
typedef struct
{
int datum;
} TraceRec;
typedef struct
{
uint32_t fMaxNumberEntries;
uint32_t fNextEntryNumber;
TraceRec *fTraceRecArray;
} com_softraid_TraceLog;
com_softraid_TraceLog *com_softraid_gTraceLogPtr;
int main ()
{
com_softraid_TraceLog log;
com_softraid_gTraceLogPtr = &log;
log.fTraceRecArray = (TraceRec *) malloc (sizeof (TraceRec) * 100);
log.fMaxNumberEntries = 100;
log.fNextEntryNumber = 4;
log.fTraceRecArray[0].datum = 0;
log.fTraceRecArray[1].datum = 1;
log.fTraceRecArray[2].datum = 2;
log.fTraceRecArray[3].datum = 3;
puts ("break here");
return 0;
}
we can experiment a little in the interactive script mode:
(lldb) br s -p break
(lldb) r
(lldb) scri
>>> debugger = lldb.debugger
>>> target = debugger.GetSelectedTarget()
>>> traceLog = target.FindFirstGlobalVariable("com_softraid_gTraceLogPtr")
>>> traceRecordArray = traceLog.GetChildMemberWithName("fTraceRecArray")
>>> print traceRecordArray.GetChildAtIndex(1, lldb.eNoDynamicValues, 1)
(TraceRec) [1] = {
datum = 1
}
>>> print traceRecordArray.GetChildAtIndex(2, lldb.eNoDynamicValues, 1)
(TraceRec) [2] = {
datum = 2
}
>>>
There's also SBValue::GetPointeeData()
which would give you the raw bytes of each member of the array in an SBData
object but then you'd need to coerce those bytes back into your structure so I wouldn't go that way.