From ee9f28b789ccc89032048997b69089a9bf191ad7 Mon Sep 17 00:00:00 2001 From: ohhorob Date: Fri, 3 Aug 2012 09:04:38 -0700 Subject: [PATCH] Updated Debugging (markdown) --- Debugging.md | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/Debugging.md b/Debugging.md index b82b52a..0b5887c 100644 --- a/Debugging.md +++ b/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. \ No newline at end of file