[lldb-dev] Stepping in a breakpoint callback with Python

Nikita Karetnikov via lldb-dev lldb-dev at lists.llvm.org
Sat Sep 21 11:11:16 PDT 2019


Jim,

> 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:
>
>
https://lldb.llvm.org/use/python-reference.html#using-the-python-api-to-create-custom-stepping-logic

How do I queue up the thread plan in the callback?

Here's my attempt:
https://gist.github.com/nkaretnikov/6ee00afabf73332c5a89eacb610369c2#file-scripted_step-py

This is based on:
https://github.com/llvm/llvm-project/blob/master/lldb/examples/python/scripted_step.py

The original 'SimpleStep' class implementation works when run as:
thread step-scripted -C scripted_step.SimpleStep

Not sure if my current version of 'SimpleStep' is correct (I've made a few
changes since testing via 'thread step-scripted'), but nothing happens (no
prints on '__init__') when I add the class via
'StepUsingScriptedThreadPlan' in
the callback.

What's the proper way to do this?

Or do I need to mimic one of the classes with a
'thread_plan.QueueThreadPlan*'
method call?  I couldn't figure out how to trace with anything besides the
'SimpleStep' class when running via 'thread step-scripted', so I stuck with
it.

> 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.

Nevermind the events thing, then.  I just run the lldb command and then do:
command script import $FILE

Ideally, I want to keep it this way so I could debug manually if needed.

Thanks,
Nikita
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/lldb-dev/attachments/20190921/a0ede0d7/attachment.html>


More information about the lldb-dev mailing list