presterjohn
presterjohn

Reputation: 101

lldb python API access to getting and setting breakpoint commands (of the non python variety)

I am attempting to write a python command extension for lldb which can export the current set of breakpoints to a plist file, and restore the exported breakpoints from the file complete with conditions and commands (presumably in a new session.)

I looked over the lldb python API and searched the web (and stack overflow) but have not found answers to the following issues:

  1. Is there any way to get the list of breakpoint commands associated with an SBBreakpoint object via the Python API? (I overcame this issue by issuing a command line style "breakpoint list" to the HandleCommand API and parsing the results for commands - but it would be nice to be able to do it via the API.)
  2. Is there any way to set multiple commands on an SBBreakPoint object via the python API? The command line alternative only has an affordance for a singe line command. Other than setting an python method callback, there does not appear to be a way to set multiple lldb command line style breakpoint commands (non python) on a breakpoint object?

Upvotes: 1

Views: 324

Answers (1)

Jim Ingham
Jim Ingham

Reputation: 27110

There isn't a good way to do #1. It does seem gross to have to parse the output of break list...

You can sort of do #2 by making a python method callback with a bunch of "HandleCommand" lines in it.

It wouldn't be hard to add SB API methods that do either of these tasks. We already have SBStringList as a convenient container for the command text either coming in or going out. If you want to try your hand at lldb hacking, a patch to this effect would be warmly accepted.

Otherwise, file a bug with the lldb.llvm.org bugzilla, and somebody will get around to it when they have a free moment.

Upvotes: 1

Related Questions