[Python-Dev] SET_LINENO and python options
Vladimir Marangozov
Vladimir.Marangozov@inrialpes.fr
Mon, 31 Jul 2000 17:37:16 +0200 (CEST)
M.-A. Lemburg wrote:
>
> BTW, we already have "python -d" which sets the debugging
> flag. You could simply use that flag for generating the SET_LINENO
> opcodes.
You're right. In case someone is not on the patches list and wants
to test this, here's the log message of the latest patch update:
Date: 2000-Jul-31 07:57
By: marangoz
Comment:
Another rewrite, making this whole strategy b/w compatible according to
the 1st incompatibility point a) described in: http://www.python.org/pipermail/p
ython-dev/2000-July/014364.html
Changes:
1. f.f_lineno is computed and updated on f_lineno attribute requests for
f, given f.f_lasti. Correctness is ensured because f.f_lasti is updated
on *all* attribute accesses (in LOAD_ATTR in the main loop).
2. The standard setup does not generate SET_LINENO, but uses
co_lnotab for computing the source line number (e.g. tracebacks)
This is equivalent to the actual "python -O".
3. With "python -d", we fall back to the current version of the
interpreter (with SET_LINENO) thus making it easy to test whether
this patch fully replaces SET_LINENO's behavior.
(modulo f->f_lineno accesses from legacy C code, but this is insane).
IMO, this version already worths the pain to be truly tested and improved.
One improvement is to define a nicer public C API for breakpoints:
- PyCode_SetBreakPointAtLine(line)
- PyCode_SetBreakPointAtAddr(addr)
or similar, which would install a CALL_TRACE opcode in the appropriate
location of the copy of co_code.
Another idea is to avoid duplicating the entire co_code just for storing
the CALL_TRACE opcodes. We can store them in the original and keep
a table of breakpoints. Setting the breakpoints would occur whenever
the sys.settrace hook is set.
-------------------------------------------------------
-------------------------------------------------------
For more info, visit:
http://sourceforge.net/patch/?func=detailpatch&patch_id=101022&group_id=5470
--
Vladimir MARANGOZOV | Vladimir.Marangozov@inrialpes.fr
http://sirac.inrialpes.fr/~marangoz | tel:(+33-4)76615277 fax:76615252