Given a memory address, I would like to print it's content from a lldb script.
I tried different approaches to get a SBValue given an address but none of them worked for me, namely
buffer = lldb.SBData()
buffer.CreateDataFromCString(lldb.eByteOrderBig, 10, "0x00007fffe45e3000")
but when I go to query the object nothing it shown.
I also tried to assign the address to a convenience variable in lldb and then use FindVariable(), but the variable is empty
expr auto $buffer = function_returning_address();
>>> buffer = lldb.frame.FindVariable("$buffer")
but here again the variable has no name, type etc. I also tried with SBValue.SetValueFromCString()
>>> buffer.SetValueFromCString("0x00007fffe45e3000", error)
False
>>> print error
error: Could not get value: No value
I didn't find much documentation on Google and I'm just starting out with lldb scripts, any suggestion is appreciated.
Thanks.
There are two ways to do this. If you want the raw data, you can ask your SBProcess to read memory as a Python byte array using SBProcess.ReadMemory. If you want to present the data at that address as an instance of some type, you can use SBTarget.CreateValueFromAddress. To find the type to pass into this, use SBTarget.FindFirstType...