Reputation: 1336
The main open ended question is: how to use LLDB with languages that transpile to C/C++. What I want is to hook into default LLDB functions with python script, so that it
type summary add
. The "matching" should be performed by inspecting the struct.The ultimate goal is to provide a python script to LLDB to support that, so that numerous UI LLDB frontends (XCode, VSCode, etc) would automatically benefit from that.
EDIT: I have managed to solve the type question by getting all types from all SBCompileModules, inspecting them, and providing syntetic formatters. Symbol "demangling" and breakpoints mapping is still the question.
Upvotes: 0
Views: 507
Reputation: 27110
You can also add a regular-expression matching formatter that matches .*
. Since lldb will try all the non-regex matchers first, this won't supersede the built-in formatters. The regex matcher is slower than static pattern matches, but might still be acceptable for your purposes, and maybe not be much worse than the result of adding one formatter per type in your app, if the app is big. This might be simpler to implement.
You could use the script.thread.python_function
& script.frame.python
thread & frame formats (described here: http://lldb.llvm.org/formats.html) to make custom backtrace printing - including your demangling - to backtrace output.
There isn't a way to provide a custom demangler from Python. And symbol printing isn't done with a formatter the way thread & frame printing is, so there's no way to intervene. I can't see a good way to do this from the outside.
There isn't currently a pluggable way to write a breakpoint resolver kernel in Python though lldb is designed to allow that. However, if you can get your transcoder to emit #file & #line declarations into the C/C++ source, those remappings will get into the debug info so that lldb can pick them up.
Upvotes: 1