Skip to content

Commit d21fd88

Browse files
committed
Fix gdb support
1 parent b65e6ef commit d21fd88

2 files changed

Lines changed: 11 additions & 9 deletions

File tree

Lib/test/test_gdb/test_backtrace.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ def test_bt_full(self):
3737
'Verify that the "py-bt-full" command works'
3838
bt = self.get_stack_trace(script=SAMPLE_SCRIPT,
3939
cmds_after_breakpoint=['py-bt-full'])
40+
print(bt)
41+
4042
self.assertMultilineMatches(bt,
4143
r'''^.*
4244
#[0-9]+ Frame 0x-?[0-9a-f]+, for file .*gdb_sample.py, line 7, in bar \(a=1, b=2, c=3\)

Tools/gdb/libpython.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1115,9 +1115,9 @@ def is_shim(self):
11151115
return self._f_special("owner", int) == FRAME_OWNED_BY_INTERPRETER
11161116

11171117
def previous(self):
1118-
prev = self._gdbval["previous"]
1118+
prev = self._gdbval["previous"].cast(gdb.lookup_type('_PyInterpreterFrame').pointer())
11191119
try:
1120-
return PyFramePtr(prev["iframe"])
1120+
return PyFramePtr(prev)
11211121
except:
11221122
return None
11231123

@@ -1215,11 +1215,11 @@ def write_repr(self, out, visited):
12151215
return
12161216
lineno = self.current_line_num()
12171217
lineno = str(lineno) if lineno is not None else "?"
1218+
addr = self.as_address()
1219+
file = self.co_filename.proxyval(visited)
1220+
name = self.co_name.proxyval(visited)
12181221
out.write('Frame 0x%x, for file %s, line %s, in %s ('
1219-
% (self.as_address(),
1220-
self.co_filename.proxyval(visited),
1221-
lineno,
1222-
self.co_name.proxyval(visited)))
1222+
% (addr, file, lineno, name))
12231223
first = True
12241224
for pyop_name, pyop_value in self.iter_locals():
12251225
if not first:
@@ -1258,7 +1258,6 @@ def get_truncated_repr(self, maxlen):
12581258
except StringTruncated:
12591259
# Truncation occurred:
12601260
return out.getvalue() + '...(truncated)'
1261-
12621261
# No truncation occurred:
12631262
return out.getvalue()
12641263

@@ -1869,10 +1868,11 @@ def print_summary(self):
18691868
interp_frame = interp_frame.previous()
18701869
else:
18711870
info = self.is_other_python_frame()
1871+
index = self.get_index()
18721872
if info:
1873-
sys.stdout.write('#%i %s\n' % (self.get_index(), info))
1873+
sys.stdout.write('#%i %s\n' % (index, info))
18741874
else:
1875-
sys.stdout.write('#%i\n' % self.get_index())
1875+
sys.stdout.write('#%i\n' % index)
18761876

18771877
def print_traceback(self):
18781878
if self.is_evalframe():

0 commit comments

Comments
 (0)