You could currently do this by writing a ShowImage() function in python and then dropping into the embedded python interpreter within LLDB:
(lldb) breakpoint set --file make_image.c --line 123
(lldb) run
stop at breakpoint...
(lldb) script
Now you are in the script interpreter with access to the current program. You should be able to get ahold of the current process and thread and then evaluate an expression:
debugger = lldb.SBDebugger().FindDebuggerWithID(lldb.debugger_unique_id)
target = debugger.GetCurrentTarget()
process = target.GetProcess()
thread = process.GetThreadAtIndex (0)
if thread.IsValid():
frame = thread.GetFrameAtIndex (0)
if frame.IsValid():
image_data_expr = frame.EvaluateExpression ("my_struct->image_data");
image_size_expr = frame.EvaluateExpression ("my_struct->image_size");
if image_data_expr.GetError().Success() && image_size_expr.GetError().Success():
image_addr = int(image_data_expr.GetValue(frame), 16);
image_size = int(image_size_expr.GetValue(frame), 16);
lldb::SBError error;
process.ReadMemory (image_addr, image_bytes, image_size, error);
... then save the bytes to a file and then call some display functions....
We need to make convenience variables in the embedded interpreter to make getting the current target/process/thread/frame much easier, but this should at least be a start. The one issue is that in our SBProcess::ReadMemory() function call the C++ API looks like:
size_t
SBProcess::ReadMemory (addr_t addr, void *buf, size_t size, lldb::SBError &error);
I am not sure how SWIG will handle the "void *buf". We might need to add some conversion functions so that any functions that take a "void *buf, size_t size" pair of arguments, can take a reference to a python array that can be filled in.
If wrote the above code in a function, you could them import your module and just call your function with a few parameters.
Greg Clayton