From a9dc06c08a7f1d12bd43794e58aa79b4b13bed4e Mon Sep 17 00:00:00 2001 From: Karim Hamidou Date: Tue, 18 Oct 2016 21:51:49 -0700 Subject: [PATCH] Better README. --- README.md | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 8ee8657..41d0072 100644 --- a/README.md +++ b/README.md @@ -42,13 +42,11 @@ vagrant@precise32:/vagrant$ That's it! After pressing Ctrl-C, the trace is removed and the program execution resumes normally. -# Installing +# Running lptrace lptrace was written to be run on production servers. Because of this, you only need `lptrace.py` to run the whole program. -We may have a pypi package in the near future. - # Usage ## Tracing a Python program @@ -74,22 +72,30 @@ successfully, and it should run on most recent Unices. # Technical details -lptrace is a relatively simple program but it uses some moderately crazy hacks to modify an already -running Python program. I encourage you to read the source (it's roughly 100 lines of Python), but -here's a 5 minute overview of how it works: - -1. gdb is an awesome debugger. It lets you attach to any running program, as long as you're root. It +gdb is an awesome debugger. It lets you attach to any running program, as long as you're root. It also lets you call any C function this program exposes. -2. Among the C functions the Python interpreter exposes, one function `PyRun\_SimpleString` lets you -run a single expression of Python code. +What's interesting is that among the C functions the Python interpreter exposes, +one function `PyRun\_SimpleString`, lets you run a single expression of Python code. + +We use this function to ask the Python process to read a temporary file `lptrace` created. This file +contains a hook to the `sys.settrace` function, which allows us to get notified whenever a function is +called. -3. +Finally, we need to output the tracing data somewhere. We could do this in the program we're tracing +but that wouldn't be very useful. Instead, we write it to a FIFO so that `lptrace` can display it in +its own window. + +That's about it. I encourage you to read the source --- it's short and pretty simple! # Issues Please open a ticket [here](https://github.com/khamidou/lptrace/issues) +# Security + +lptrace is a debugging tool. It uses temporary files, so it may be vulnerable to some race conditions. Caveat emptor! + # Special Thanks I'd like to thank the [Pyrasite project](http://pyrasite.com/) for coming up with -- 2.43.0