This is an archive of the discontinued LLVM Phabricator instance.

[lldb/Bindings] Raise a Runtime error when using SBAddress properties that rely on lldb.target
ClosedPublic

Authored by JDevlieghere on May 29 2020, 3:17 PM.

Details

Summary

Several SBAddress properties use the lldb.target or lldb.process convenience variables which are only set under the interactive script interpreter. Unfortunately, users have been using these properties in Python script and commands. This patch raises a Python exception to force users to use GetLoadAddress instead.

Diff Detail

Event Timeline

JDevlieghere created this revision.May 29 2020, 3:17 PM

Explicitly point to GetLoadAddress

Seems like this should be easy enough to test, let me add one.

jingham accepted this revision.May 29 2020, 3:33 PM

I think "This resolves the SBAddress" is better than "This resolves SBAddress". Other than that LGTM.

It would be convenient if you could reuse the _runtime_err_str in the doc strings, but I can't see a way to do that in Python.

def Foo():

'''%s'''%(_runtime_err_str)
etc

doesn't raise an error, and defines the function correctly but help(Foo) doesn't show anything.

This revision is now accepted and ready to land.May 29 2020, 3:33 PM

Ooh, test would be good. Just use it in a python command.

JDevlieghere marked an inline comment as done.May 29 2020, 3:53 PM
JDevlieghere added inline comments.
lldb/test/Shell/ScriptInterpreter/Python/Inputs/sbaddress.py
5

This was for testing, I'll remove it before landing.

Looks even better.

This revision was automatically updated to reflect the committed changes.
Herald added a project: Restricted Project. · View Herald TranscriptMay 29 2020, 10:18 PM