Updated Debugging (markdown)
parent
8c6954589b
commit
ee9f28b789
14
Debugging.md
14
Debugging.md
|
@ -1,6 +1,6 @@
|
|||
Debugging mitmproxy is best done in "remote" mode, as the terminal that starts mitmproxy is used by the urwid library to render the interface.
|
||||
Debugging [`mitmproxy`](https://github.com/cortesi/mitmproxy) is best done in "remote" mode, as the terminal that starts `mitmproxy` is used by the [Urwid](http://excess.org/urwid/) library to render the interface.
|
||||
|
||||
Modify mitmproxy to connect to a remote debugger
|
||||
Modify `mitmproxy` to connect to a remote debugger
|
||||
|
||||
### Add the debugger import
|
||||
|
||||
|
@ -11,14 +11,14 @@ Modify mitmproxy to connect to a remote debugger
|
|||
if __name__ == '__main__':
|
||||
try:
|
||||
pydevd.settrace('localhost', port=1234, suspend=False)
|
||||
except Exception:
|
||||
except:
|
||||
print >> sys.stderr, "mitmproxy: failed to connect to remote debugger."
|
||||
|
||||
Here, `suspend=False` will allow mitmproxy to start up and run until hitting a breakpoint.
|
||||
Here, `suspend=False` will allow `mitmproxy` to start up and run until hitting a breakpoint.
|
||||
|
||||
### IDE Configuration
|
||||
|
||||
I've used IntelliJ IDEA Ultimate with the PyCharm plugin installed. PyCharm installs an egg with the required pydev module imported in the steps above.
|
||||
I've used [IntelliJ IDEA Ultimate](http://www.jetbrains.com/idea/) with the [Python (PyCharm)](http://www.jetbrains.net/confluence/display/PYH/) plugin installed. PyCharm installs an egg with the required `pydev` module imported in the steps above.
|
||||
|
||||
In "Run/Debug Configurations", add a new "Python Remote Debug" configuration with settings matching the `settrace()` added in the steps above. Name it "mitmproxy Remote"
|
||||
|
||||
|
@ -39,7 +39,7 @@ On Mac OS X, this looks like:
|
|||
|
||||
This environment variable will only persist for the current terminal session. Other terminals, including all new terminal sessions will not have this configuration. To make it permanent, add it to your shell configuration (typically ~/.profile).
|
||||
|
||||
Now starting mitmproxy should connect to the "mitmproxy Remote" configuration started in the IDE.
|
||||
Now starting `mitmproxy` should connect to the "mitmproxy Remote" configuration started in the IDE.
|
||||
|
||||
$ ./mitmproxy -p 8888 2>/tmp/mitmproxy.err
|
||||
|
||||
|
@ -64,4 +64,4 @@ Set a breakpoint somewhere to verify that the session is working. e.g. **libmpro
|
|||
key = None
|
||||
return urwid.ListBox.keypress(self, size, key)
|
||||
|
||||
Now, in `mitmproxy` show the event view "e", then clear it "C". Your debugger should now be triggered.
|
||||
Now, in `mitmproxy` show the event view "e", then clear it "C". Your debugger should now be triggered.
|
Loading…
Reference in New Issue