diff options
author | Jeffrey Yasskin <jyasskin@gmail.com> | 2009-05-23 23:23:01 (GMT) |
---|---|---|
committer | Jeffrey Yasskin <jyasskin@gmail.com> | 2009-05-23 23:23:01 (GMT) |
commit | 655d835415800085cddbacecfc8a22111d70a5ef (patch) | |
tree | 313b44ddc5a8af0d3c1ec29cc2b1fb35b4b118c3 /Include | |
parent | 3724d6c3923f45f4c284e1b3d44a60c3090017d1 (diff) | |
download | cpython-655d835415800085cddbacecfc8a22111d70a5ef.zip cpython-655d835415800085cddbacecfc8a22111d70a5ef.tar.gz cpython-655d835415800085cddbacecfc8a22111d70a5ef.tar.bz2 |
Issue #6042:
lnotab-based tracing is very complicated and isn't documented very well. There
were at least 3 comment blocks purporting to document co_lnotab, and none did a
very good job. This patch unifies them into Objects/lnotab_notes.txt which
tries to completely capture the current state of affairs.
I also discovered that we've attached 2 layers of patches to the basic tracing
scheme. The first layer avoids jumping to instructions that don't start a line,
to avoid problems in if statements and while loops. The second layer
discovered that jumps backward do need to trace at instructions that don't
start a line, so it added extra lnotab entries for 'while' and 'for' loops, and
added a special case for backward jumps within the same line. I replaced these
patches by just treating forward and backward jumps differently.
Diffstat (limited to 'Include')
-rw-r--r-- | Include/code.h | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/Include/code.h b/Include/code.h index cbf00d8..260c5f0 100644 --- a/Include/code.h +++ b/Include/code.h @@ -23,7 +23,8 @@ typedef struct { PyObject *co_filename; /* string (where it was loaded from) */ PyObject *co_name; /* string (name, for reference) */ int co_firstlineno; /* first source line number */ - PyObject *co_lnotab; /* string (encoding addr<->lineno mapping) */ + PyObject *co_lnotab; /* string (encoding addr<->lineno mapping) See + Objects/lnotab_notes.txt for details. */ void *co_zombieframe; /* for optimization only (see frameobject.c) */ } PyCodeObject; @@ -90,15 +91,11 @@ typedef struct _addr_pair { int ap_upper; } PyAddrPair; -/* Check whether lasti (an instruction offset) falls outside bounds - and whether it is a line number that should be traced. Returns - a line number if it should be traced or -1 if the line should not. - - If lasti is not within bounds, updates bounds. +/* Update *bounds to describe the first and one-past-the-last instructions in the + same line as lasti. Return the number of that line. */ - -PyAPI_FUNC(int) PyCode_CheckLineNumber(PyCodeObject* co, - int lasti, PyAddrPair *bounds); +PyAPI_FUNC(int) _PyCode_CheckLineNumber(PyCodeObject* co, + int lasti, PyAddrPair *bounds); PyAPI_FUNC(PyObject*) PyCode_Optimize(PyObject *code, PyObject* consts, PyObject *names, PyObject *lineno_obj); |