ghidra-jython-kernel
                                
                                
                                
                                    ghidra-jython-kernel copied to clipboard
                            
                            
                            
                        Fixes timeout issues and garbled output issues
I've been using this code recently to shoehorn some things into Ghidra by way of Jupyter and have come across a few issues.
- The default pexpect.TIMEOUT value causes long-running commands to break the kernel with an exception such as:
 
[IPKernelApp] ERROR | Exception in message handler:
Traceback (most recent call last):
...
pexpect.exceptions.TIMEOUT: Timeout exceeded.
<pexpect.pty_spawn.spawn object at 0x7f8e787d9a20>
command: /usr/lib/jvm/java-11-openjdk/bin/java
...
This can be resolved by adding a very large timeout or catching the exception and retrying the expect call.
- A few issues with matching the Python repl prompts ("..." or ">>>") and terminal control characters can quickly cause the Kernel to become de-synchronized and start inserting garbled result blocks into notebooks. This can be resolved with some extra logic around execution and output matching.