[lldb-dev] Stepping in a breakpoint callback with Python
Jim Ingham via lldb-dev
lldb-dev at lists.llvm.org
Thu Sep 19 10:31:22 PDT 2019
lldb doesn’t currently support breakpoint callbacks that try to control running the target in the callback. I’m not sure how easy it would be to support that reliably, but anyway, that doesn’t work at present.
My model for this sort of tracing activity is that you are writing a fancy kind of “step” operation. You would write a fancy step & record plan that would proceed along however you wanted and log at each stop. Then your breakpoint callback would just queue up this step-and-trace plan as its last act. That’s what the Scripted ThreadPlans are for:
I’m not quite sure what you are describing with the process events approach. Are you trying to do this while also running in the lldb driver, or can you write a stand-alone tool to do this? If the latter, then it should be enough to program everything at the event loop level. You will know when your breakpoint is hit, then you can issue the steps one by one and do whatever logging you want each time you stop. I’m not sure why this would need events sent from the breakpoint callback.
> On Sep 18, 2019, at 7:59 PM, Nikita Karetnikov via lldb-dev <lldb-dev at lists.llvm.org> wrote:
> I'm trying to figure out how to write a simple tracer. Specifically, I want to
> perform some 'step's after a breakpoint callback fires. How do I do that in
> async mode?
> Here's my attempt:
> https://gist.github.com/nkaretnikov/6ee00afabf73332c5a89eacb610369c2 <https://gist.github.com/nkaretnikov/6ee00afabf73332c5a89eacb610369c2>
> The problem is that pc is not updated (pc: 0xffffffffffffffff) when the loop
> executes the second time.
> I've also attempted to refactor this code based on:
> http://llvm.org/svn/llvm-project/lldb/trunk/examples/python/process_events.py <http://llvm.org/svn/llvm-project/lldb/trunk/examples/python/process_events.py>
> My idea was to have a similar loop as the one that's after 'listener = ...'. It
> would sit there waiting for events, and I would somehow broadcast an event from
> the callback. Maybe with 'state == lldb.eStateStopped' and a global variable
> allowing me to distinguish this event type from the rest.
> But I can't find a way to do this. Either I get the same behavior as without
> events or my events are ignored completely (likely because I use them
> I haven't published the code of the event version, but I can do that later
> unless someone proposes a working solution right away.
> lldb-dev mailing list
> lldb-dev at lists.llvm.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the lldb-dev