Can python be used to debug other languages?

Mitch Chapman Mitch.Chapman at bioreason.com
Tue Oct 1 18:25:16 CEST 2002


bumm3rm4n at yahoo.com wrote:
 > I am doing research in school and I was just wondering if python can
 > be used to debug other languages such as C++ and java. IF it does,
 > can anybody give me an info how?

This probably isn't what you had in mind, but...

I used to do a lot of C/C++ development.  For some applications
interactive debugging was impractical, and the most popular
alternative was to write diagnostic messages to a log file.

It was painful to interpret the log file manually.  Eventually
I realized that, instead of writing human-readable text to the
log file, one could write Python statements and then interpret the
log file using a Python-based, high-level model of the program.
My memory is fading now, but the log might include statements like
these:
     model.startRIP(10127, "/tmp/rip_me.ps")

This technique made it possible to detect invalid event sequences,
help find unbalanced resource allocation/release, identify slow
sections of code (given timestamps like the one above), etc., without
manually slogging through all of the messages.

Better yet, in many cases it was possible to record a single log
file and then re-interpret it many times, refining the Python model
on each pass so it could describe problems in greater detail.

There are better ways to do this sort of thing, but Python-intelligible
log files were a lot of fun.

--
Mitch
Mitch.Chapman at bioreason.com




More information about the Python-list mailing list