Previously, you could only have a list of command-line commands as the reaction to a stop hook.
This patch adds the ability to define the stop hooks directly in Python, which allows you to do logging and add logic to the stop hook more easily.
Paths
| Differential D88123
Add the ability to write 'target stop-hooks' in Python ClosedPublic Authored by jingham on Sep 22 2020, 4:46 PM.
Details Summary Previously, you could only have a list of command-line commands as the reaction to a stop hook. This patch adds the ability to define the stop hooks directly in Python, which allows you to do logging and add logic to the stop hook more easily.
Diff Detail
Event Timelinekastiglione added inline comments.
Comment Actions I'm very excited about this feature. Great job on the documentation, both in the help output as for the website. Do you have a potential use case in mind that we could add to the examples?
Comment Actions Addressed review comments.
JDevlieghere added inline comments.
This revision is now accepted and ready to land.Sep 25 2020, 8:34 AM This revision was landed with ongoing or failed builds.Sep 25 2020, 3:45 PM Closed by commit rGb65966cff65b: Add the ability to write target stop-hooks using the ScriptInterpreter. (authored by jingham). · Explain Why This revision was automatically updated to reflect the committed changes. jingham marked 5 inline comments as done. Comment Actions Hi Jim, this change broke my Fedora 33 Linux (x86) box. Do you think we can get a quick fix or revert this? FAIL: lldb-shell :: Commands/command-stop-hook-output.test (69796 of 70913) ******************** TEST 'lldb-shell :: Commands/command-stop-hook-output.test' FAILED ******************** Script: -- : 'RUN: at line 1'; /tmp/_update_lc/r/bin/clang --target=specify-a-target-or-use-a-_host-substitution --target=x86_64-unknown-linux-gnu -pthread -fmodules-cache-path=/tmp/_update_lc/r/lldb-test-build.noindex/module-cache-clang/lldb-shell -g /home/dave/ro_s/lp/lldb/test/Shell/Commands/Inputs/main.c -o /tmp/_update_lc/r/tools/lldb/test/Commands/Output/command-stop-hook-output.test.tmp : 'RUN: at line 2'; /tmp/_update_lc/r/bin/lldb --no-lldbinit -S /tmp/_update_lc/r/tools/lldb/test/Shell/lit-lldb-init /tmp/_update_lc/r/tools/lldb/test/Commands/Output/command-stop-hook-output.test.tmp -O 'command script import /home/dave/ro_s/lp/lldb/test/Shell/Commands/Inputs/stop_hook.py' -s /home/dave/ro_s/lp/lldb/test/Shell/Commands/command-stop-hook-output.test -o exit | /tmp/_update_lc/r/bin/FileCheck /home/dave/ro_s/lp/lldb/test/Shell/Commands/command-stop-hook-output.test -- Exit Code: 1 Command Output (stderr): -- clang-12: warning: argument unused during compilation: '-fmodules-cache-path=/tmp/_update_lc/r/lldb-test-build.noindex/module-cache-clang/lldb-shell' [-Wunused-command-line-argument] error: module importing failed: This script interpreter does not support importing modules. /home/dave/ro_s/lp/lldb/test/Shell/Commands/command-stop-hook-output.test:5:16: error: CHECK-LABEL: expected string not found in input # CHECK-LABEL: b main ^ <stdin>:1:1: note: scanning from here (lldb) command source -s 0 '/tmp/_update_lc/r/tools/lldb/test/Shell/lit-lldb-init' ^ <stdin>:1:8: note: possible intended match here (lldb) command source -s 0 '/tmp/_update_lc/r/tools/lldb/test/Shell/lit-lldb-init' ^ Input file: <stdin> Check file: /home/dave/ro_s/lp/lldb/test/Shell/Commands/command-stop-hook-output.test -dump-input=help explains the following input dump. Input was: <<<<<< 1: (lldb) command source -s 0 '/tmp/_update_lc/r/tools/lldb/test/Shell/lit-lldb-init' label:5'0 X~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ error: no match found label:5'1 ? possible intended match 2: Executing commands in '/tmp/_update_lc/r/tools/lldb/test/Shell/lit-lldb-init'. label:5'0 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3: (lldb) # LLDB init file for the LIT tests. label:5'0 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4: (lldb) settings set symbols.enable-external-lookup false label:5'0 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5: (lldb) settings set plugin.process.gdb-remote.packet-timeout 60 label:5'0 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6: (lldb) settings set interpreter.echo-comment-commands false label:5'0 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ . . . >>>>>> -- ******************** ******************** Failed Tests (1): lldb-shell :: Commands/command-stop-hook-output.test Testing Time: 66.80s Unsupported : 10853 Passed : 59957 Expectedly Failed: 102 Failed : 1 FAILED: CMakeFiles/check-all Comment Actions This also doesn't work on my macOS system: FAIL: LLDB (/Users/teemperor/1llvm/rel/bin/clang-x86_64) :: test_stop_hooks_scripted_return_false (TestStopHookScripted.TestStopHooks) ====================================================================== FAIL: test_stop_hooks_scripted_return_false (TestStopHookScripted.TestStopHooks) Test that the returning False from a stop hook works ---------------------------------------------------------------------- Traceback (most recent call last): File "/Users/teemperor/1llvm/llvm-project/lldb/test/API/commands/target/stop-hooks/TestStopHookScripted.py", line 54, in test_stop_hooks_scripted_return_false self.do_test_auto_continue(True) File "/Users/teemperor/1llvm/llvm-project/lldb/test/API/commands/target/stop-hooks/TestStopHookScripted.py", line 91, in do_test_auto_continue self.assertEqual("main", func_name, "Didn't stop at the expected function.") AssertionError: 'main' != 'step_out_of_me' - main+ step_out_of_me : Didn't stop at the expected function. Config=x86_64-/Users/teemperor/1llvm/rel/bin/clang ----------------------------------------------------------------------
Revision Contents
Diff 294444 lldb/bindings/python/python-swigsafecast.swig
lldb/bindings/python/python-wrapper.swig
lldb/docs/use/python-reference.rst
lldb/include/lldb/Interpreter/ScriptInterpreter.h
lldb/include/lldb/Symbol/SymbolContext.h
lldb/include/lldb/Target/Target.h
lldb/source/Commands/CommandObjectTarget.cpp
lldb/source/Commands/Options.td
lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPythonImpl.h
lldb/source/Symbol/SymbolContext.cpp
lldb/source/Target/Target.cpp
lldb/test/API/commands/target/stop-hooks/TestStopHookScripted.py
lldb/test/API/commands/target/stop-hooks/TestStopHooks.py
lldb/test/API/commands/target/stop-hooks/main.c
lldb/test/API/commands/target/stop-hooks/stop_hook.py
lldb/test/Shell/Commands/Inputs/stop_hook.py
lldb/test/Shell/Commands/command-stop-hook-output.test
lldb/unittests/ScriptInterpreter/Python/PythonTestSuite.cpp
|
Any reason for the double empty lines?