@@ -724,24 +724,36 @@ def test_two_abs_args(self):
724
724
' 3 def foo(a, b, c):\n ' ,
725
725
bt )
726
726
727
+ SAMPLE_WITH_C_CALL = """
728
+
729
+ from _testcapi import pyobject_fastcall
730
+
731
+ def foo(a, b, c):
732
+ bar(a, b, c)
733
+
734
+ def bar(a, b, c):
735
+ pyobject_fastcall(baz, (a, b, c))
736
+
737
+ def baz(*args):
738
+ id(42)
739
+
740
+ foo(1, 2, 3)
741
+
742
+ """
743
+
744
+
727
745
class StackNavigationTests (DebuggerTests ):
728
746
@unittest .skipUnless (HAS_PYUP_PYDOWN , "test requires py-up/py-down commands" )
729
747
@unittest .skipIf (python_is_optimized (),
730
748
"Python was compiled with optimizations" )
731
749
def test_pyup_command (self ):
732
750
'Verify that the "py-up" command works'
733
- bt = self .get_stack_trace (script = self . get_sample_script () ,
751
+ bt = self .get_stack_trace (source = SAMPLE_WITH_C_CALL ,
734
752
cmds_after_breakpoint = ['py-up' , 'py-up' ])
735
753
self .assertMultilineMatches (bt ,
736
754
r'''^.*
737
- #[0-9]+ Frame 0x-?[0-9a-f]+, for file .*gdb_sample.py, line 10, in baz \(args=\(1, 2, 3\)\)
738
- id\(42\)
739
- #[0-9]+ Frame 0x-?[0-9a-f]+, for file .*gdb_sample.py, line 7, in bar \(a=1, b=2, c=3\)
740
- baz\(a, b, c\)
741
- #[0-9]+ Frame 0x-?[0-9a-f]+, for file .*gdb_sample.py, line 4, in foo \(a=1, b=2, c=3\)
742
- bar\(a=a, b=b, c=c\)
743
- #[0-9]+ Frame 0x-?[0-9a-f]+, for file .*gdb_sample.py, line 12, in <module> \(\)
744
- foo\(1, 2, 3\)
755
+ #[0-9]+ Frame 0x-?[0-9a-f]+, for file <string>, line 12, in baz \(args=\(1, 2, 3\)\)
756
+ #[0-9]+ <built-in method pyobject_fastcall of module object at remote 0x[0-9a-f]+>
745
757
$''' )
746
758
747
759
@unittest .skipUnless (HAS_PYUP_PYDOWN , "test requires py-up/py-down commands" )
@@ -765,22 +777,13 @@ def test_up_at_top(self):
765
777
"Python was compiled with optimizations" )
766
778
def test_up_then_down (self ):
767
779
'Verify "py-up" followed by "py-down"'
768
- bt = self .get_stack_trace (script = self . get_sample_script () ,
780
+ bt = self .get_stack_trace (source = SAMPLE_WITH_C_CALL ,
769
781
cmds_after_breakpoint = ['py-up' , 'py-up' , 'py-down' ])
770
782
self .assertMultilineMatches (bt ,
771
783
r'''^.*
772
- #[0-9]+ Frame 0x-?[0-9a-f]+, for file .*gdb_sample.py, line 10, in baz \(args=\(1, 2, 3\)\)
773
- id\(42\)
774
- #[0-9]+ Frame 0x-?[0-9a-f]+, for file .*gdb_sample.py, line 7, in bar \(a=1, b=2, c=3\)
775
- baz\(a, b, c\)
776
- #[0-9]+ Frame 0x-?[0-9a-f]+, for file .*gdb_sample.py, line 4, in foo \(a=1, b=2, c=3\)
777
- bar\(a=a, b=b, c=c\)
778
- #[0-9]+ Frame 0x-?[0-9a-f]+, for file .*gdb_sample.py, line 12, in <module> \(\)
779
- foo\(1, 2, 3\)
780
- #[0-9]+ Frame 0x-?[0-9a-f]+, for file .*gdb_sample.py, line 10, in baz \(args=\(1, 2, 3\)\)
781
- id\(42\)
782
- #[0-9]+ Frame 0x-?[0-9a-f]+, for file .*gdb_sample.py, line 7, in bar \(a=1, b=2, c=3\)
783
- baz\(a, b, c\)
784
+ #[0-9]+ Frame 0x-?[0-9a-f]+, for file <string>, line 12, in baz \(args=\(1, 2, 3\)\)
785
+ #[0-9]+ <built-in method pyobject_fastcall of module object at remote 0x[0-9a-f]+>
786
+ #[0-9]+ Frame 0x-?[0-9a-f]+, for file <string>, line 12, in baz \(args=\(1, 2, 3\)\)
784
787
$''' )
785
788
786
789
class PyBtTests (DebuggerTests ):
@@ -970,13 +973,12 @@ def __init__(self):
970
973
self .assertRegex (gdb_output ,
971
974
r"<method-wrapper u?'__init__' of MyList object at " )
972
975
973
-
974
976
class PyPrintTests (DebuggerTests ):
975
977
@unittest .skipIf (python_is_optimized (),
976
978
"Python was compiled with optimizations" )
977
979
def test_basic_command (self ):
978
980
'Verify that the "py-print" command works'
979
- bt = self .get_stack_trace (script = self . get_sample_script () ,
981
+ bt = self .get_stack_trace (source = SAMPLE_WITH_C_CALL ,
980
982
cmds_after_breakpoint = ['py-up' , 'py-print args' ])
981
983
self .assertMultilineMatches (bt ,
982
984
r".*\nlocal 'args' = \(1, 2, 3\)\n.*" )
@@ -985,7 +987,7 @@ def test_basic_command(self):
985
987
"Python was compiled with optimizations" )
986
988
@unittest .skipUnless (HAS_PYUP_PYDOWN , "test requires py-up/py-down commands" )
987
989
def test_print_after_up (self ):
988
- bt = self .get_stack_trace (script = self . get_sample_script () ,
990
+ bt = self .get_stack_trace (source = SAMPLE_WITH_C_CALL ,
989
991
cmds_after_breakpoint = ['py-up' , 'py-up' , 'py-print c' , 'py-print b' , 'py-print a' ])
990
992
self .assertMultilineMatches (bt ,
991
993
r".*\nlocal 'c' = 3\nlocal 'b' = 2\nlocal 'a' = 1\n.*" )
0 commit comments