[issue9919] gdbinit lineno result is one line in excess

qpatata report at bugs.python.org
Wed Sep 22 22:44:23 CEST 2010


qpatata <qpatata at gmail.com> added the comment:

Hello,

Thanks for your colaboration.

Starting by the following python file, called "prueba.py":

> cat prueba.py
import time

def bar():
    time.sleep(10);
    print "hello";

def foo():
  while True:
    bar();

foo();




Open a gdb session with python2-6 as target:

> gdb /usr/bin/python2.6

and run the python program. 

gdb> run prueba.py

After a few seconds, type Ctrl-C to break the program. Usually, break will interrupt it when execution is in the "sleep" statement. A "bt" gives:

#0  0xb7fe2424 in __kernel_vsyscall ()
#1  0xb7d42fdd in select () from /lib/i686/cmov/libc.so.6
#2  0x08119a3f in floatsleep (self=0x0, args=(10,)) at ../Modules/timemodule.c:918
#3  time_sleep (self=0x0, args=(10,)) at ../Modules/timemodule.c:206
#4  0x080e0721 in call_function (f=Frame 0x82e17ac, for file prueba.py, line 4, in bar (), 
    throwflag=0) at ../Python/ceval.c:3750
#5  PyEval_EvalFrameEx (f=Frame 0x82e17ac, for file prueba.py, line 4, in bar (), throwflag=0)
    at ../Python/ceval.c:2412
...

If we go until C frame #5 (up, up, ...) and execute the lineno macro:

#5  PyEval_EvalFrameEx (f=Frame 0x82e17ac, for file prueba.py, line 4, in bar (), throwflag=0)
    at ../Python/ceval.c:2412
2412    in ../Python/ceval.c

(gdb) lineno
5
(gdb) 

It is clear the mismatch between the line reported by lineno (5), the one in the source file (4) and the one displayed by gdb (4).

In addition, if we look at the version history of the "gdbinit" file, we can see how version 39276 has an implementation of lineno who matches the related C code in Python project, but next version (39492) introduces a boolean to control the end of loop. This change is, probably, the origen of the mismatch.

Thanks a lot.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue9919>
_______________________________________


More information about the Python-bugs-list mailing list