I wrote a lldb type summary provider for wstring with 16bit wchar on Ubuntu 16.04.
Things work fine if I manually do the following in lldb:
(lldb) script import mytypes
(lldb) type summary add -F mytypes.wstring_SummaryProvider "std::__1::wstring"
I tried to make things easier with auto-loading by adding the following to .lldbinit:
script import mytypes
type summary add -F mytypes.wstring_SummaryProvider "std::__1::wstring"
Then I got a failure of "SBProcess is invalid" when printing a wstring variable.
My type summary function has the following, which I believe is where the error is encountered:
content = lldb.process.ReadMemory(bufferAddr, byteCount, error)
Maybe this is because "process" is not assigned yet when the type summary is added during auto-loading?
Does anyone know how to make auto loading work for my script?
Thanks much
Enrico already answered this on lldb-dev:
http://lists.llvm.org/pipermail/lldb-dev/2016-September/011236.html
but for those following along here:
The lldb.process
, lldb.thread
etc variables are only meant as a convenience for use in the interactive python interpreter, and not for Python code that gets run for breakpoints, data formatters, commands, etc.
It doesn't make sense in a multi-threaded debugger to try to present a global notion of "current thread" to any bits of script code that might get run. Instead, each context in which the script gets run knows the process/thread/frame that are relevant to it. In the case of data formatters, they always get passed the value they are working on, and that knows the relevant process through the SBValue.GetProcess()
API.