DerekSelander / LLDB

A collection of LLDB aliases/regexes and Python scripts to aid in your debugging sessions
GNU General Public License v2.0
1.77k stars 198 forks source link

Add and use exe_ctx parameter to commands #4

Closed kastiglione closed 6 years ago

kastiglione commented 6 years ago

This change adds the exe_ctx parameter to each command. This parameter is a SBExecutionContext which provides direct access to the target, frame, process, and thread.

In particular, this reduces the use of ds.getTarget(), which relied on the global lldb.target. The lldb documentation (see "EMBEDDED PYTHON INTERPRETER") states this about the globals:

they are only defined and meaningful while in the interactive Python interpreter. There is no guarantee on their value in any other situation, hence you should not use them when defining Python formatters, breakpoint scripts and commands

For information about the exe_ctx parameter, see "CREATE A NEW LLDB COMMAND USING A PYTHON FUNCTION" at https://lldb.llvm.org/python-reference.html

kastiglione commented 6 years ago

The change you'll want to review are 2e76bf7. As for testing these changes, got any ideas…?

DerekSelander commented 6 years ago

Hey @kastiglione, thanks for opening this PR up. I totally agree with you on we shouldn't use the globals especially if others are viewing this as a reference for how to work w/ the lldb module. Think I did that just out of laziness since the SBTarget rarely ever changes (unlike SBFrame or SBThread...) Anyways, I'll merge that in after work

As for regression testing and all that, we definitely ain't up to Chisel's standards yet so testing just encompasses me using these scripts day in and day out.

Glad to see you're still keeping up w/ all this stuff even at the new jerb :]

kastiglione commented 6 years ago

reference for how to work w/ the lldb module

This was one of the motivators for me. I'll be doing similar changes to chisel once my CLA is approved.

DerekSelander commented 6 years ago

Damn. You even went through the dclass code. 👏 I don't ever want to touch that again