summaryrefslogtreecommitdiffstats
path: root/Tools/gdb
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@python.org>2020-03-20 07:23:26 (GMT)
committerGitHub <noreply@github.com>2020-03-20 07:23:26 (GMT)
commit7bf069b6110278102c8f4719975a5eb5a5af25f9 (patch)
tree6af58fb5f34591d1f08c47e8aad28a71ed7f8e0f /Tools/gdb
parenta36adfa6bbf5e612a4d4639124502135690899b8 (diff)
downloadcpython-7bf069b6110278102c8f4719975a5eb5a5af25f9.zip
cpython-7bf069b6110278102c8f4719975a5eb5a5af25f9.tar.gz
cpython-7bf069b6110278102c8f4719975a5eb5a5af25f9.tar.bz2
bpo-40019: Skip test_gdb if Python was optimized (GH-19081)
test_gdb now skips tests if it detects that gdb failed to read debug information because the Python binary is optimized.
Diffstat (limited to 'Tools/gdb')
-rwxr-xr-xTools/gdb/libpython.py16
1 files changed, 9 insertions, 7 deletions
diff --git a/Tools/gdb/libpython.py b/Tools/gdb/libpython.py
index cd7ae10..33bf5ac 100755
--- a/Tools/gdb/libpython.py
+++ b/Tools/gdb/libpython.py
@@ -99,6 +99,8 @@ hexdigits = "0123456789abcdef"
ENCODING = locale.getpreferredencoding()
+FRAME_INFO_OPTIMIZED_OUT = '(frame information optimized out)'
+UNABLE_READ_INFO_PYTHON_FRAME = 'Unable to read information on python frame'
EVALFRAME = '_PyEval_EvalFrameDefault'
class NullPyObjectPtr(RuntimeError):
@@ -918,7 +920,7 @@ class PyFrameObjectPtr(PyObjectPtr):
def filename(self):
'''Get the path of the current Python source file, as a string'''
if self.is_optimized_out():
- return '(frame information optimized out)'
+ return FRAME_INFO_OPTIMIZED_OUT
return self.co_filename.proxyval(set())
def current_line_num(self):
@@ -949,7 +951,7 @@ class PyFrameObjectPtr(PyObjectPtr):
'''Get the text of the current source line as a string, with a trailing
newline character'''
if self.is_optimized_out():
- return '(frame information optimized out)'
+ return FRAME_INFO_OPTIMIZED_OUT
lineno = self.current_line_num()
if lineno is None:
@@ -970,7 +972,7 @@ class PyFrameObjectPtr(PyObjectPtr):
def write_repr(self, out, visited):
if self.is_optimized_out():
- out.write('(frame information optimized out)')
+ out.write(FRAME_INFO_OPTIMIZED_OUT)
return
lineno = self.current_line_num()
lineno = str(lineno) if lineno is not None else "?"
@@ -993,7 +995,7 @@ class PyFrameObjectPtr(PyObjectPtr):
def print_traceback(self):
if self.is_optimized_out():
- sys.stdout.write(' (frame information optimized out)\n')
+ sys.stdout.write(' %s\n' % FRAME_INFO_OPTIMIZED_OUT)
return
visited = set()
lineno = self.current_line_num()
@@ -1744,7 +1746,7 @@ class PyList(gdb.Command):
pyop = frame.get_pyop()
if not pyop or pyop.is_optimized_out():
- print('Unable to read information on python frame')
+ print(UNABLE_READ_INFO_PYTHON_FRAME)
return
filename = pyop.filename()
@@ -1904,7 +1906,7 @@ class PyPrint(gdb.Command):
pyop_frame = frame.get_pyop()
if not pyop_frame:
- print('Unable to read information on python frame')
+ print(UNABLE_READ_INFO_PYTHON_FRAME)
return
pyop_var, scope = pyop_frame.get_var_by_name(name)
@@ -1938,7 +1940,7 @@ class PyLocals(gdb.Command):
pyop_frame = frame.get_pyop()
if not pyop_frame:
- print('Unable to read information on python frame')
+ print(UNABLE_READ_INFO_PYTHON_FRAME)
return
for pyop_name, pyop_value in pyop_frame.iter_locals():