[Python-Dev] seeing off SET_LINENO
Michael Hudson
mwh@python.net
30 Jul 2002 13:31:53 +0100
barry@python.org (Barry A. Warsaw) writes:
> >>>>> "MH" == Michael Hudson <mwh@python.net> writes:
>
> MH> 3) The patch changes behaviour -- for the better! You're now
> MH> rather less likely to get the trace function called several
> MH> times per line.
>
> Does this change affect debugging?
Hmm, I hadn't actually dared to run pdb with my patch... have now, and
it seems OK.
There is a difference:
The bytecode for, say,
def f():
print 1
begins with two SET_LINENO's. One is for the line containing "def
f():", one is for "print 1". My patch means the debugger doesn't stop
on the "def f():" line -- unsurprisingly, given that no execution ever
takes place on that line.
It would be possible to force a call to the trace function on entry to
the function. In fact, there's a commented out block for this in my
patch. Another approach would presuambly be for pdb to stop on 'call'
trace events as well as 'line' ones. I don't really understand, or
use all that often, pdb.
Also, you currently stop twice on the first line of a for loop, but
only once with my patch. There are probably other situations of
excessive SET_LINENO emission. I know Skip (think it was him) killed
a couple last week. Bug compatibility is possible here too, but I
don't see the advantage.
> Have you tested how this change might interact with e.g. hotshot?
test_hotshot was very important to me as evidence I was making
progress!
It currently fails due to the not-calling-trace-on-def-line issue, but
as I said, I think this is a *good* thing...
Cheers,
M.
--
The ability to quote is a serviceable substitute for wit.
-- W. Somerset Maugham