Search code examples
pythonclldb

how do i access C array float values from lldb python API


I am new using python scripting in lldb. I am debugging C code.

I want to copy the content of a C array of floats into a python variable in an lldb script. The ultimate goal goal is to plot the content array as is done here with gdb and python.

The C array in the program i'm debugging is declared as float* buffer;

In lldb python script if I do: buf = lldb.frame.FindVariable ("buffer") buf only contains the non dereferrenced pointer "buffer'" (the address of the array).

How do I access the actual values of the array (derefferenced) and copy them into a python variable? gdb has gdb_numpy.to_array. I looked at SBValue.h and tried GetChildAtIndex method but with no luck.


Solution

  • Actually:

    x[i]= float(buf.GetChildAtIndex(i,1,1).GetValue())

    Returns value of buf at index i