[New-bugs-announce] [issue25460] Misc/.gdbinit uses preprocessor macro

Phil Weir report at bugs.python.org
Thu Oct 22 17:13:55 CEST 2015


New submission from Phil Weir:

When using the sample .gdbinit, use of the _PyUnicode_AsString macro gives "No symbol "_PyUnicode_AsString" in current context." from GDB.

This was first noticed when using downstream (Ubuntu) CPython 3.4/3.5 with debug symbols, and was reproduced by building current HEAD without optimization (to ensure co object not optimized out) 'CFLAGS="-g -O0" ./configure --with-pydebug && make -j2', based on instructions here [1].

This is fixable by switching _PyUnicode_AtString to PyUnicode_AsUTF8, the target of the macro in './Include/unicodeobject.h' (see attached patch)

1 - https://docs.python.org/devguide/setup.html#unix

====

TEST FILE (loop.py)
=========
import time

time.sleep(100)


GDB OUTPUT WITHOUT PATCH
========================

> gdb -args /usr/local/bin/python3.6dm loop.py

GNU gdb (GDB) 7.9.50.20150218-cvs
Copyright (C) 2015 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-unknown-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from /usr/local/bin/python3.6dm...done.
(gdb) r
Starting program: /usr/local/bin/python3.6dm loop.py
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
^C
Program received signal SIGINT, Interrupt.
0x00007ffff71df723 in select () from /lib/x86_64-linux-gnu/libc.so.6
(gdb) bt
#0  0x00007ffff71df723 in select () from /lib/x86_64-linux-gnu/libc.so.6
#1  0x000000000065f9eb in pysleep (secs=100000000000) at ./Modules/timemodule.c:1408
#2  0x000000000065d9a1 in time_sleep (self=0x7ffff6d318d8, obj=0x9ce7f0 <small_ints+5040>) at ./Modules/timemodule.c:231
#3  0x00000000005d8c96 in call_function (pp_stack=0x7fffffffbde0, oparg=1) at Python/ceval.c:4636
#4  0x00000000005d0a59 in PyEval_EvalFrameEx (f=0xa82198, throwflag=0) at Python/ceval.c:3181
#5  0x00000000005d6154 in _PyEval_EvalCodeWithName (_co=0x7ffff7e1c280, globals=0x7ffff7f1de58, locals=0x7ffff7f1de58, args=0x0, argcount=0, kws=0x0, kwcount=0, defs=0x0, defcount=0, kwdefs=0x0, closure=0x0,
    name=0x0, qualname=0x0) at Python/ceval.c:3962
#6  0x00000000005d629d in PyEval_EvalCodeEx (_co=0x7ffff7e1c280, globals=0x7ffff7f1de58, locals=0x7ffff7f1de58, args=0x0, argcount=0, kws=0x0, kwcount=0, defs=0x0, defcount=0, kwdefs=0x0, closure=0x0)
    at Python/ceval.c:3983
#7  0x00000000005c05aa in PyEval_EvalCode (co=0x7ffff7e1c280, globals=0x7ffff7f1de58, locals=0x7ffff7f1de58) at Python/ceval.c:777
#8  0x0000000000428790 in run_mod (mod=0xac0968, filename=0x7ffff6dd7c08, globals=0x7ffff7f1de58, locals=0x7ffff7f1de58, flags=0x7fffffffd690, arena=0xade380) at Python/pythonrun.c:970
#9  0x00000000004284c3 in PyRun_FileExFlags (fp=0xab8210, filename_str=0x7ffff7f0bd80 "loop.py", start=257, globals=0x7ffff7f1de58, locals=0x7ffff7f1de58, closeit=1, flags=0x7fffffffd690)
    at Python/pythonrun.c:923
#10 0x00000000004263c1 in PyRun_SimpleFileExFlags (fp=0xab8210, filename=0x7ffff7f0bd80 "loop.py", closeit=1, flags=0x7fffffffd690) at Python/pythonrun.c:396
#11 0x0000000000425127 in PyRun_AnyFileExFlags (fp=0xab8210, filename=0x7ffff7f0bd80 "loop.py", closeit=1, flags=0x7fffffffd690) at Python/pythonrun.c:80
#12 0x0000000000441b4b in run_file (fp=0xab8210, filename=0x9ee270 L"loop.py", p_cf=0x7fffffffd690) at Modules/main.c:318
#13 0x0000000000442aeb in Py_Main (argc=2, argv=0x9ec020) at Modules/main.c:768
#14 0x000000000041c26f in main (argc=2, argv=0x7fffffffd948) at ./Programs/python.c:69
(gdb) f 4
#4  0x00000000005d0a59 in PyEval_EvalFrameEx (f=0xa82198, throwflag=0) at Python/ceval.c:3181
3181                res = call_function(&sp, oparg);
(gdb) pystack
No symbol "_PyUnicode_AsString" in current context.
(gdb)


GDB OUTPUT WITH PATCH
=====================

> gdb -args /usr/local/bin/python3.6dm loop.py 


GNU gdb (GDB) 7.9.50.20150218-cvs
Copyright (C) 2015 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-unknown-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from /usr/local/bin/python3.6dm...done.
(gdb) r
Starting program: /usr/local/bin/python3.6dm loop.py
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
^C
Program received signal SIGINT, Interrupt.
0x00007ffff71df723 in select () from /lib/x86_64-linux-gnu/libc.so.6
(gdb) bt
#0  0x00007ffff71df723 in select () from /lib/x86_64-linux-gnu/libc.so.6
#1  0x000000000065f9eb in pysleep (secs=100000000000) at ./Modules/timemodule.c:1408
#2  0x000000000065d9a1 in time_sleep (self=0x7ffff6d318d8, obj=0x9ce7f0 <small_ints+5040>) at ./Modules/timemodule.c:231
#3  0x00000000005d8c96 in call_function (pp_stack=0x7fffffffbde0, oparg=1) at Python/ceval.c:4636
#4  0x00000000005d0a59 in PyEval_EvalFrameEx (f=0xa82198, throwflag=0) at Python/ceval.c:3181
#5  0x00000000005d6154 in _PyEval_EvalCodeWithName (_co=0x7ffff7e1c280, globals=0x7ffff7f1de58, locals=0x7ffff7f1de58, args=0x0, argcount=0, kws=0x0, kwcount=0, defs=0x0, defcount=0, kwdefs=0x0, closure=0x0,
    name=0x0, qualname=0x0) at Python/ceval.c:3962
#6  0x00000000005d629d in PyEval_EvalCodeEx (_co=0x7ffff7e1c280, globals=0x7ffff7f1de58, locals=0x7ffff7f1de58, args=0x0, argcount=0, kws=0x0, kwcount=0, defs=0x0, defcount=0, kwdefs=0x0, closure=0x0)
    at Python/ceval.c:3983
#7  0x00000000005c05aa in PyEval_EvalCode (co=0x7ffff7e1c280, globals=0x7ffff7f1de58, locals=0x7ffff7f1de58) at Python/ceval.c:777
#8  0x0000000000428790 in run_mod (mod=0xac0928, filename=0x7ffff6dd7c08, globals=0x7ffff7f1de58, locals=0x7ffff7f1de58, flags=0x7fffffffd690, arena=0xab9470) at Python/pythonrun.c:970
#9  0x00000000004284c3 in PyRun_FileExFlags (fp=0xab81d0, filename_str=0x7ffff7f0bd80 "loop.py", start=257, globals=0x7ffff7f1de58, locals=0x7ffff7f1de58, closeit=1, flags=0x7fffffffd690)
    at Python/pythonrun.c:923
#10 0x00000000004263c1 in PyRun_SimpleFileExFlags (fp=0xab81d0, filename=0x7ffff7f0bd80 "loop.py", closeit=1, flags=0x7fffffffd690) at Python/pythonrun.c:396
#11 0x0000000000425127 in PyRun_AnyFileExFlags (fp=0xab81d0, filename=0x7ffff7f0bd80 "loop.py", closeit=1, flags=0x7fffffffd690) at Python/pythonrun.c:80
#12 0x0000000000441b4b in run_file (fp=0xab81d0, filename=0x9ee270 L"loop.py", p_cf=0x7fffffffd690) at Modules/main.c:318
#13 0x0000000000442aeb in Py_Main (argc=2, argv=0x9ec020) at Modules/main.c:768
#14 0x000000000041c26f in main (argc=2, argv=0x7fffffffd948) at ./Programs/python.c:69
(gdb) f 4
#4  0x00000000005d0a59 in PyEval_EvalFrameEx (f=0xa82198, throwflag=0) at Python/ceval.c:3181
3181                res = call_function(&sp, oparg);
(gdb) pystack
loop.py (3): <module>
loop.py (3): <module>
(gdb)

----------
components: Demos and Tools
files: gdbinit-PyUnicode_AsUTF8.patch
keywords: patch
messages: 253333
nosy: philtweir
priority: normal
severity: normal
status: open
title: Misc/.gdbinit uses preprocessor macro
versions: Python 3.4, Python 3.5, Python 3.6
Added file: http://bugs.python.org/file40835/gdbinit-PyUnicode_AsUTF8.patch

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


More information about the New-bugs-announce mailing list