snare / voltron

A hacky debugger UI for hackers
MIT License
6.16k stars 414 forks source link

lldb: voltron command never loaded through entry.invoke #234

Open ttimasdf opened 6 years ago

ttimasdf commented 6 years ago
$ lldb -p 41749
Voltron loaded.
(lldb) process attach --pid 41749
error: Aborting reading of commands after command #0: 'voltron stopped' failed with error: unable to execute script function
Process 41749 stopped
* thread #1, queue = 'com.apple.root.default-qos.overcommit', stop reason = signal SIGSTOP
    frame #0: 0x00007fff7ef7e2fa libsystem_kernel.dylib`__sigsuspend_nocancel + 10
libsystem_kernel.dylib`__sigsuspend_nocancel:
->  0x7fff7ef7e2fa <+10>: jae    0x7fff7ef7e304            ; <+20>
    0x7fff7ef7e2fc <+12>: movq   %rax, %rdi
    0x7fff7ef7e2ff <+15>: jmp    0x7fff7ef750b8            ; cerror_nocancel
    0x7fff7ef7e304 <+20>: retq
Target 0: (com.xunlei.Thunder.DownloadService) stopped.

Executable module set to "/Applications/Thunder.app/Contents/XPCServices/com.xunlei.Thunder.DownloadService.xpc/Contents/MacOS/com.xunlei.Thunder.DownloadService".
Architecture set to: x86_64h-apple-macosx.
(lldb) voltron init
error: unable to execute script function
(lldb) voltron view stask
error: unable to execute script function

And my environment, 10.13.3

$ lldb -v
lldb-902.0.79.2
  Swift-4.1
$ xcode-select -p
/Library/Developer/CommandLineTools

Could this be a cause of the problem?

ttimasdf commented 6 years ago

debugger.log

2018-04-07 23:40:33,757 INFO     __init__.py:84          setup_logging -- ======= VOLTRON - DEFENDER OF THE UNIVERSE [debug log] =======
2018-04-07 23:40:33,759 DEBUG      plugin.py:89        register_plugin -- Ignoring invalid plugin: <class 'voltron.plugin.VoltronPlugin'>
2018-04-07 23:40:33,760 DEBUG      plugin.py:89        register_plugin -- Ignoring invalid plugin: <class 'voltron.plugin.APIPlugin'>
2018-04-07 23:40:33,760 DEBUG      plugin.py:89        register_plugin -- Ignoring invalid plugin: <class 'voltron.plugin.DebuggerAdaptorPlugin'>
2018-04-07 23:40:33,760 DEBUG      plugin.py:89        register_plugin -- Ignoring invalid plugin: <class 'voltron.plugin.ViewPlugin'>
2018-04-07 23:40:33,760 DEBUG      plugin.py:89        register_plugin -- Ignoring invalid plugin: <class 'voltron.plugin.WebPlugin'>
2018-04-07 23:40:33,760 DEBUG      plugin.py:89        register_plugin -- Ignoring invalid plugin: <class 'voltron.plugin.CommandPlugin'>
2018-04-07 23:40:33,760 DEBUG      plugin.py:78        register_plugin -- Registering view plugin: <class 'disasm.DisasmViewPlugin'>
2018-04-07 23:40:33,761 DEBUG      plugin.py:78        register_plugin -- Registering view plugin: <class 'command.CommandViewPlugin'>
2018-04-07 23:40:33,761 DEBUG      plugin.py:78        register_plugin -- Registering view plugin: <class 'register.RegisterViewPlugin'>
2018-04-07 23:40:33,761 DEBUG      plugin.py:78        register_plugin -- Registering view plugin: <class 'memory.MemoryViewPlugin'>
2018-04-07 23:40:33,761 DEBUG      plugin.py:78        register_plugin -- Registering view plugin: <class 'memory.StackViewPlugin'>
2018-04-07 23:40:33,761 DEBUG      plugin.py:78        register_plugin -- Registering view plugin: <class 'breakpoints.BreakpointsViewPlugin'>
2018-04-07 23:40:33,761 DEBUG      plugin.py:78        register_plugin -- Registering view plugin: <class 'backtrace.BacktraceViewPlugin'>
2018-04-07 23:40:33,761 DEBUG      plugin.py:75        register_plugin -- Registering debugger plugin: <class 'dbg_lldb.LLDBAdaptorPlugin'>
2018-04-07 23:40:33,762 DEBUG      plugin.py:75        register_plugin -- Registering debugger plugin: <class 'dbg_mock.MockAdaptorPlugin'>
2018-04-07 23:40:33,762 DEBUG      plugin.py:72        register_plugin -- Registering API plugin: <class 'plugins.APIPluginsPlugin'>
2018-04-07 23:40:33,762 DEBUG      plugin.py:72        register_plugin -- Registering API plugin: <class 'registers.APIRegistersPlugin'>
2018-04-07 23:40:33,762 DEBUG      plugin.py:72        register_plugin -- Registering API plugin: <class 'command.APICommandPlugin'>
2018-04-07 23:40:33,762 DEBUG      plugin.py:72        register_plugin -- Registering API plugin: <class 'targets.APITargetsPlugin'>
2018-04-07 23:40:33,762 DEBUG      plugin.py:72        register_plugin -- Registering API plugin: <class 'write_memory.APIWriteMemoryPlugin'>
2018-04-07 23:40:33,762 DEBUG      plugin.py:72        register_plugin -- Registering API plugin: <class 'version.APIVersionPlugin'>
2018-04-07 23:40:33,763 DEBUG      plugin.py:72        register_plugin -- Registering API plugin: <class 'memory.APIReadMemoryPlugin'>
2018-04-07 23:40:33,763 DEBUG      plugin.py:72        register_plugin -- Registering API plugin: <class 'null.APINullPlugin'>
2018-04-07 23:40:33,763 DEBUG      plugin.py:72        register_plugin -- Registering API plugin: <class 'dereference.APIDerefPlugin'>
2018-04-07 23:40:33,763 DEBUG      plugin.py:72        register_plugin -- Registering API plugin: <class 'disassemble.APIDisassemblePlugin'>
2018-04-07 23:40:33,763 DEBUG      plugin.py:72        register_plugin -- Registering API plugin: <class 'stack.APIStackPlugin'>
2018-04-07 23:40:33,763 DEBUG      plugin.py:72        register_plugin -- Registering API plugin: <class 'breakpoints.APIBreakpointsPlugin'>
2018-04-07 23:40:33,763 DEBUG      plugin.py:72        register_plugin -- Registering API plugin: <class 'backtrace.APIBacktracePlugin'>
2018-04-07 23:40:33,763 DEBUG      plugin.py:72        register_plugin -- Registering API plugin: <class 'state.APIStatePlugin'>
2018-04-07 23:40:33,764 DEBUG    dbg_lldb.py:35               __init__ -- lldb.debugger is valid - probably running inside LLDB
2018-04-07 23:40:33,765 DEBUG      plugin.py:89        register_plugin -- Ignoring invalid plugin: <class 'voltron.plugin.CommandPlugin'>
ttimasdf commented 6 years ago

seems sys.path is clobbered by voltron.entry no its not.

$ lldb
Voltron loaded.
(lldb) voltron
error: unable to execute script function
(lldb) script
Python Interactive Interpreter. To exit, type 'quit()', 'exit()' or Ctrl-D.
>>> sys.path
['/Library/Developer/CommandLineTools/Library/PrivateFrameworks/LLDB.framework/Versions/A', '/Library/Developer/CommandLineTools/Library/PrivateFrameworks/LLDB.framework/Resources/Python', '/Users/user/.virtualenvs/sys/lib/python27.zip', '/Users/user/.virtualenvs/sys/lib/python2.7', '/Users/user/.virtualenvs/sys/lib/python2.7/plat-darwin', '/Users/user/.virtualenvs/sys/lib/python2.7/plat-mac', '/Users/user/.virtualenvs/sys/lib/python2.7/plat-mac/lib-scriptpackages', '/Users/user/.virtualenvs/sys/lib/python2.7/lib-tk', '/Users/user/.virtualenvs/sys/lib/python2.7/lib-old', '/Users/user/.virtualenvs/sys/lib/python2.7/lib-dynload', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-darwin', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac/lib-scriptpackages', '/Users/user/.virtualenvs/sys/lib/python2.7/site-packages', '/Library/Python/2.7/site-packages', '/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python', '/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/PyObjC', '.', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python27.zip', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-darwin', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac/lib-scriptpackages', '/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-old', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload']
>>> '/Users/user/.virtualenvs/sys/lib/python2.7/site-packages' in sys.path
True
ttimasdf commented 6 years ago

This patch fixed the issue but why??

diff --git a/voltron/plugins/debugger/dbg_lldb.py b/voltron/plugins/debugger/dbg_lldb.py
index 4dd8ec8..7281344 100644
--- a/voltron/plugins/debugger/dbg_lldb.py
+++ b/voltron/plugins/debugger/dbg_lldb.py
@@ -548,7 +548,7 @@ if HAVE_LLDB:

             # install the voltron command handler
             self.adaptor.command("script import voltron")
-            self.adaptor.command('command script add -f entry.invoke voltron')
+            self.adaptor.command('command script add -f voltron.command._invoke voltron')

             # try to register hooks automatically, as this works on new LLDB versions
             self.register_hooks(True)