[lldb-dev] Debugging Python scripts (backtraces, variables) with LLDB
Jim Ingham via lldb-dev
lldb-dev at lists.llvm.org
Mon Nov 26 11:43:57 PST 2018
lldb does have an affordance for synthetic threads, but at present, those have to be memory threads, and once you have the 0th frame, they are backtraced just like ordinary threads. So they are a start but don't provide a way to make up synthetic frames within a thread. So I don't think that they do what you want exactly.
Recently, Kuba added the notion of a "frame recognizer" that can detect certain frames and alter their presentation. The first use is adding variables to a frame - mostly to provide argument values to known functions for which you don't have debug information.
You could use that directly, recognizing the python "push a new stack frame" function and adding the Python locals as new variables. The problem you will run into here is that we don't have a Python type system, so you'd have to represent these variables as C types.
In my original notion of the frame recognizers, I thought we would have more the directives like: "hide the next X frames", and "redirect the source info for this frame" and "change the language of this frame". Then the higher layer frame printing code would follow the recognizer directives to produce a mixed stack frame. There isn't any support for this in what Kuba did, but I think the framework he put in place could be extended along these lines to do the sort of thing you are thinking of.
> On Nov 20, 2018, at 10:08 AM, Alexandru Croitor via lldb-dev <lldb-dev at lists.llvm.org> wrote:
> Thanks for the link. I'm aware that VS provides that functionality (although I forgot that it was open-source).
> My aim would be to implement something similar in LLDB though.
>> On 20. Nov 2018, at 18:49, Zachary Turner <zturner at google.com> wrote:
>> On Tue, Nov 20, 2018 at 8:51 AM Alexandru Croitor via lldb-dev <lldb-dev at lists.llvm.org> wrote:
>> I would appreciate, if someone could point me to some relevant code that does something similar to what I'm asking, so I could use it as a base point for exploration.
>> Many thanks.
>> Not sure how much it will help you, but on Windows if you're using MS Visual Studio, their debugger does this. You can seamlessly step between managed and native code and see Python callstacks interspersed with native callstacks. It's all open source but it's quite a lot of code to dig through, and unless you have a Windows machien, you won't be able to play around with it anyway.
> lldb-dev mailing list
> lldb-dev at lists.llvm.org
More information about the lldb-dev