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

Skip to content

Commit 50eb60e

Browse files
author
Victor Stinner
committed
Merged revisions 80288 via svnmerge from
svn+ssh://[email protected]/python/trunk ........ r80288 | victor.stinner | 2010-04-21 00:28:31 +0200 (mer., 21 avril 2010) | 2 lines Issue #8437: Fix test_gdb failures, patch written by Dave Malcolm ........
1 parent 5e2be87 commit 50eb60e

3 files changed

Lines changed: 36 additions & 15 deletions

File tree

Lib/test/test_gdb.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,19 @@
3131
if gdbpy_version == b'':
3232
raise unittest.SkipTest("gdb not built with embedded python support")
3333

34+
def gdb_has_frame_select():
35+
# Does this build of gdb have gdb.Frame.select ?
36+
cmd = "--eval-command=python print(dir(gdb.Frame))"
37+
p = subprocess.Popen(["gdb", "--batch", cmd],
38+
stdout=subprocess.PIPE)
39+
stdout, _ = p.communicate()
40+
m = re.match(br'.*\[(.*)\].*', stdout)
41+
if not m:
42+
raise unittest.SkipTest("Unable to parse output from gdb.Frame.select test")
43+
gdb_frame_dir = m.group(1).split(b', ')
44+
return b"'select'" in gdb_frame_dir
45+
46+
HAS_PYUP_PYDOWN = gdb_has_frame_select()
3447

3548
class DebuggerTests(unittest.TestCase):
3649

@@ -554,6 +567,7 @@ def test_two_abs_args(self):
554567
bt)
555568

556569
class StackNavigationTests(DebuggerTests):
570+
@unittest.skipUnless(HAS_PYUP_PYDOWN, "test requires py-up/py-down commands")
557571
def test_pyup_command(self):
558572
'Verify that the "py-up" command works'
559573
bt = self.get_stack_trace(script='Lib/test/test_gdb_sample.py',
@@ -564,20 +578,23 @@ def test_pyup_command(self):
564578
baz\(a, b, c\)
565579
$''')
566580

581+
@unittest.skipUnless(HAS_PYUP_PYDOWN, "test requires py-up/py-down commands")
567582
def test_down_at_bottom(self):
568583
'Verify handling of "py-down" at the bottom of the stack'
569584
bt = self.get_stack_trace(script='Lib/test/test_gdb_sample.py',
570585
cmds_after_breakpoint=['py-down'])
571586
self.assertEndsWith(bt,
572587
'Unable to find a newer python frame\n')
573588

589+
@unittest.skipUnless(HAS_PYUP_PYDOWN, "test requires py-up/py-down commands")
574590
def test_up_at_top(self):
575591
'Verify handling of "py-up" at the top of the stack'
576592
bt = self.get_stack_trace(script='Lib/test/test_gdb_sample.py',
577593
cmds_after_breakpoint=['py-up'] * 4)
578594
self.assertEndsWith(bt,
579595
'Unable to find an older python frame\n')
580596

597+
@unittest.skipUnless(HAS_PYUP_PYDOWN, "test requires py-up/py-down commands")
581598
def test_up_then_down(self):
582599
'Verify "py-up" followed by "py-down"'
583600
bt = self.get_stack_trace(script='Lib/test/test_gdb_sample.py',
@@ -613,6 +630,7 @@ def test_basic_command(self):
613630
self.assertMultilineMatches(bt,
614631
r".*\nlocal 'args' = \(1, 2, 3\)\n.*")
615632

633+
@unittest.skipUnless(HAS_PYUP_PYDOWN, "test requires py-up/py-down commands")
616634
def test_print_after_up(self):
617635
bt = self.get_stack_trace(script='Lib/test/test_gdb_sample.py',
618636
cmds_after_breakpoint=['py-up', 'py-print c', 'py-print b', 'py-print a'])
@@ -638,6 +656,7 @@ def test_basic_command(self):
638656
self.assertMultilineMatches(bt,
639657
r".*\nargs = \(1, 2, 3\)\n.*")
640658

659+
@unittest.skipUnless(HAS_PYUP_PYDOWN, "test requires py-up/py-down commands")
641660
def test_locals_after_up(self):
642661
bt = self.get_stack_trace(script='Lib/test/test_gdb_sample.py',
643662
cmds_after_breakpoint=['py-up', 'py-locals'])

Misc/NEWS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,8 @@ C-API
318318
Library
319319
-------
320320

321+
- Issue #8437: Fix test_gdb failures, patch written by Dave Malcolm
322+
321323
- Issue #6547: Added the ignore_dangling_symlinks option to shutil.copytree.
322324

323325
- Issue #1540112: Now allowing the choice of a copy function in

Tools/gdb/libpython.py

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1133,18 +1133,17 @@ def get_index(self):
11331133
return index
11341134

11351135
def is_evalframeex(self):
1136-
if self._gdbframe.function():
1137-
if self._gdbframe.function().name == 'PyEval_EvalFrameEx':
1138-
'''
1139-
I believe we also need to filter on the inline
1140-
struct frame_id.inline_depth, only regarding frames with
1141-
an inline depth of 0 as actually being this function
1142-
1143-
So we reject those with type gdb.INLINE_FRAME
1144-
'''
1145-
if self._gdbframe.type() == gdb.NORMAL_FRAME:
1146-
# We have a PyEval_EvalFrameEx frame:
1147-
return True
1136+
if self._gdbframe.name() == 'PyEval_EvalFrameEx':
1137+
'''
1138+
I believe we also need to filter on the inline
1139+
struct frame_id.inline_depth, only regarding frames with
1140+
an inline depth of 0 as actually being this function
1141+
1142+
So we reject those with type gdb.INLINE_FRAME
1143+
'''
1144+
if self._gdbframe.type() == gdb.NORMAL_FRAME:
1145+
# We have a PyEval_EvalFrameEx frame:
1146+
return True
11481147

11491148
return False
11501149

@@ -1294,8 +1293,6 @@ def __init__(self):
12941293
def invoke(self, args, from_tty):
12951294
move_in_stack(move_up=True)
12961295

1297-
PyUp()
1298-
12991296
class PyDown(gdb.Command):
13001297
'Select and print the python stack frame called by this one (if any)'
13011298
def __init__(self):
@@ -1308,7 +1305,10 @@ def __init__(self):
13081305
def invoke(self, args, from_tty):
13091306
move_in_stack(move_up=False)
13101307

1311-
PyDown()
1308+
# Not all builds of gdb have gdb.Frame.select
1309+
if hasattr(gdb.Frame, 'select'):
1310+
PyUp()
1311+
PyDown()
13121312

13131313
class PyBacktrace(gdb.Command):
13141314
'Display the current python frame and all the frames within its call stack (if any)'

0 commit comments

Comments
 (0)