diff options
| author | Jonas Devlieghere <jonas@devlieghere.com> | 2020-05-29 22:10:05 -0700 |
|---|---|---|
| committer | Jonas Devlieghere <jonas@devlieghere.com> | 2020-05-29 22:11:21 -0700 |
| commit | 0800529fe605a03e9da1aca241a377eebcaa8cad (patch) | |
| tree | 6f580a44acb04ce281d7c2594fee38dde2df86f5 /lldb/test/Shell/ScriptInterpreter/Python | |
| parent | 21fee0921d563f407e07b5e28592c2925da3704d (diff) | |
| download | llvm-0800529fe605a03e9da1aca241a377eebcaa8cad.zip llvm-0800529fe605a03e9da1aca241a377eebcaa8cad.tar.gz llvm-0800529fe605a03e9da1aca241a377eebcaa8cad.tar.bz2 | |
[lldb/Bindings] Raise exception when using properties that rely on lldb.target
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.
Differential revision: https://reviews.llvm.org/D80848
Diffstat (limited to 'lldb/test/Shell/ScriptInterpreter/Python')
| -rw-r--r-- | lldb/test/Shell/ScriptInterpreter/Python/Inputs/sbaddress.py | 7 | ||||
| -rw-r--r-- | lldb/test/Shell/ScriptInterpreter/Python/sb_address_exception.test | 8 |
2 files changed, 15 insertions, 0 deletions
diff --git a/lldb/test/Shell/ScriptInterpreter/Python/Inputs/sbaddress.py b/lldb/test/Shell/ScriptInterpreter/Python/Inputs/sbaddress.py new file mode 100644 index 0000000..132d284 --- /dev/null +++ b/lldb/test/Shell/ScriptInterpreter/Python/Inputs/sbaddress.py @@ -0,0 +1,7 @@ +import lldb + +def test(debugger, command, result, internal_dict): + return int(lldb.SBAddress()) + +def __lldb_init_module(debugger, internal_dict): + debugger.HandleCommand('command script add -f sbaddress.test test') diff --git a/lldb/test/Shell/ScriptInterpreter/Python/sb_address_exception.test b/lldb/test/Shell/ScriptInterpreter/Python/sb_address_exception.test new file mode 100644 index 0000000..ffcec11 --- /dev/null +++ b/lldb/test/Shell/ScriptInterpreter/Python/sb_address_exception.test @@ -0,0 +1,8 @@ +# REQUIRES: python +# UNSUPPORTED: lldb-repro +# +# Test that the SBAddress properties throw an exception when used outside of +# the interactive script interpreter. +# +# RUN: %lldb --script-language python -o 'command script import %S/Inputs/sbaddress.py' -o 'test' 2>&1 | FileCheck %s +# CHECK: RuntimeError: This resolves the SBAddress using the SBTarget from lldb.target so this property can ONLY be used in the interactive script interpreter (i.e. under the lldb script command). For things like Python based commands and breakpoint callbacks use GetLoadAddress instead. |
