Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 5fe59f8

Browse files
authored
bpo-30983: [gdb] Fix py-bt, etc. for non-debug shared builds (#3153)
PEP 523 introduced _PyEval_EvalFrameDefault which inlines PyEval_EvalFrameEx on non-debug shared builds. This breaks the ability to use py-bt, py-up, and a few other Python-specific gdb integrations. This patch fixes the problem by only looking for _PyEval_EvalFrameDefault frames. test_gdb passes on both a debug and a non-debug build. Original patch by Bruno "Polaco" Penteado.
1 parent ea57923 commit 5fe59f8

File tree

3 files changed

+18
-9
lines changed

3 files changed

+18
-9
lines changed

Misc/ACKS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1185,6 +1185,7 @@ Berker Peksag
11851185
Andreas Pelme
11861186
Steven Pemberton
11871187
Bo Peng
1188+
Bruno "Polaco" Penteado
11881189
Santiago Peresón
11891190
George Peristerakis
11901191
Thomas Perl
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
gdb integration commands (py-bt, etc.) work on optimized shared builds now,
2+
too. PEP 523 introduced _PyEval_EvalFrameDefault which inlines
3+
PyEval_EvalFrameEx on non-debug shared builds. This broke the ability to
4+
use py-bt, py-up, and a few other Python-specific gdb integrations. The
5+
problem is fixed by only looking for _PyEval_EvalFrameDefault frames in
6+
python-gdb.py. Original patch by Bruno "Polaco" Penteado.

Tools/gdb/libpython.py

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,8 @@ def _sizeof_void_p():
9999

100100
ENCODING = locale.getpreferredencoding()
101101

102+
EVALFRAME = '_PyEval_EvalFrameDefault'
103+
102104
class NullPyObjectPtr(RuntimeError):
103105
pass
104106

@@ -1492,18 +1494,18 @@ def get_index(self):
14921494
# - everything else
14931495

14941496
def is_python_frame(self):
1495-
'''Is this a PyEval_EvalFrameEx frame, or some other important
1497+
'''Is this a _PyEval_EvalFrameDefault frame, or some other important
14961498
frame? (see is_other_python_frame for what "important" means in this
14971499
context)'''
1498-
if self.is_evalframeex():
1500+
if self.is_evalframe():
14991501
return True
15001502
if self.is_other_python_frame():
15011503
return True
15021504
return False
15031505

1504-
def is_evalframeex(self):
1505-
'''Is this a PyEval_EvalFrameEx frame?'''
1506-
if self._gdbframe.name() == 'PyEval_EvalFrameEx':
1506+
def is_evalframe(self):
1507+
'''Is this a _PyEval_EvalFrameDefault frame?'''
1508+
if self._gdbframe.name() == EVALFRAME:
15071509
'''
15081510
I believe we also need to filter on the inline
15091511
struct frame_id.inline_depth, only regarding frames with
@@ -1512,7 +1514,7 @@ def is_evalframeex(self):
15121514
So we reject those with type gdb.INLINE_FRAME
15131515
'''
15141516
if self._gdbframe.type() == gdb.NORMAL_FRAME:
1515-
# We have a PyEval_EvalFrameEx frame:
1517+
# We have a _PyEval_EvalFrameDefault frame:
15161518
return True
15171519

15181520
return False
@@ -1626,15 +1628,15 @@ def get_selected_bytecode_frame(cls):
16261628
frame = cls.get_selected_frame()
16271629

16281630
while frame:
1629-
if frame.is_evalframeex():
1631+
if frame.is_evalframe():
16301632
return frame
16311633
frame = frame.older()
16321634

16331635
# Not found:
16341636
return None
16351637

16361638
def print_summary(self):
1637-
if self.is_evalframeex():
1639+
if self.is_evalframe():
16381640
pyop = self.get_pyop()
16391641
if pyop:
16401642
line = pyop.get_truncated_repr(MAX_OUTPUT_LEN)
@@ -1653,7 +1655,7 @@ def print_summary(self):
16531655
sys.stdout.write('#%i\n' % self.get_index())
16541656

16551657
def print_traceback(self):
1656-
if self.is_evalframeex():
1658+
if self.is_evalframe():
16571659
pyop = self.get_pyop()
16581660
if pyop:
16591661
pyop.print_traceback()

0 commit comments

Comments
 (0)