Minimal debug/rep functionality

Bruce Dawson bruce_deletethis_dawson at cygnus-software.com
Sun Sep 22 01:19:25 EDT 2002


On a tangential note...

While doing some Python optimizing (for our about to ship Python based 
game) I tweaked the HAP Python debugger to count lines of Python code 
being executed. Then I displayed lines-of-code per frame in the game 
title bar. That turns out to be a very useful coarse indicator.

Then I added the expression HeDbg.GetLineCount()[1] to the watch window.
Since the GetLineCount() feature returns total lines executed and lines 
executed since the last call, and since the watch expression is 
evaluated each time control returns to the debugger, this simple 
expression tells me how many lines of code execute each time I step or go.

So, if I step over a trivial looking function and the watch window says 
700 then I investigate to find out whether 700 lines of Python executed 
for the function is reasonable.

For profiling of a game I found this feature set worked really well.

I don't think we've released an updated version of HAP that has this 
feature, but we certainly will - lots of other updates also.

Mark wrote:

> Hello all,
> 
> In a nutshell, what I'd like to do is develop a utility that would print out 
> every line in a python program as the program executes (I may even just 
> want to print line numbers).  I can see hints of how to do this in pdb (and 
> more directly in the underlying bdb class) and also in the code module.
> 
> So, 
> 
> 1) Should I try and inherit a class and override some methods or should I 
> just pull out the relevant code and hand spin a small interpreter.
> 
> 2) Anyone have a 20 liner solution for this?
> 
> Thanks.
> 
> Regards,
> Mark
> 




More information about the Python-list mailing list