@@ -34,19 +34,58 @@ def testDebugging(self):
34
34
"""Test Swift macros"""
35
35
self .build (dictionary = {'SWIFT_SOURCES' : 'main.swift' })
36
36
self .setupPluginServerForTesting ()
37
+ main_spec = lldb .SBFileSpec ('main.swift' )
37
38
target , process , thread , bkpt = lldbutil .run_to_source_breakpoint (
38
- self , 'break here' , lldb .SBFileSpec ('main.swift' ))
39
+ self , 'break here' , main_spec
40
+ )
41
+
42
+ # We're testing line breakpoint setting here:
43
+ call_site_line = lldbtest .line_number ("main.swift" , "#no_return(a / b)" )
44
+ call_site_bp = target .BreakpointCreateByLocation (main_spec , call_site_line )
39
45
40
46
thread .StepOver ()
41
47
thread .StepInto ()
48
+
42
49
# This is the expanded macro source, we should be able to step into it.
43
- self .expect ('reg read pc' , substrs = [
44
- '[inlined] freestanding macro expansion #1 of stringify in module a file main.swift line 5 column 11' ,
45
- 'stringify'
46
- ])
50
+ # Don't check the actual line number so we are line independent
51
+ self .assertIn (
52
+ 'freestanding macro expansion #1 of stringify in module a file main.swift line 5 column 11' ,
53
+ thread .frames [0 ].name ,
54
+ "Stopped in stringify macro"
55
+ )
47
56
48
57
self .expect ('expression -- #stringify(1)' , substrs = ['0 = 1' , '1 = "1"' ])
49
58
59
+ # Step out should get us out of stringify, then in to the next macro:
60
+ thread .StepOut ()
61
+ self .assertIn ("a.testStringify" , thread .frames [0 ].name , "Step out back to origin" )
62
+ thread .StepInto ()
63
+ self .assertIn (
64
+ "freestanding macro expansion #1 of no_return in module a file main.swift line 6 column 3" ,
65
+ thread .frames [0 ].name ,
66
+ "Step out and in gets to no_return"
67
+ )
68
+
69
+ # We've set a breakpoint on the call site for another instance - run to that:
70
+ threads = lldbutil .continue_to_breakpoint (process , call_site_bp )
71
+ self .assertEqual (len (threads ), 1 , "Stopped at one thread" )
72
+ thread = threads [0 ]
73
+ frame_0 = thread .frames [0 ]
74
+ line_entry_0 = frame_0 .line_entry
75
+ self .assertEqual (line_entry_0 .line , call_site_line , "Got the right line attribution" )
76
+ self .assertEqual (line_entry_0 .file , main_spec , "Got the right file attribution" )
77
+
78
+ # Now test stepping in and back out again:
79
+ thread .StepInto ()
80
+ self .assertIn (
81
+ "freestanding macro expansion #3 of no_return in module a file main.swift line 8 column 3" ,
82
+ thread .frames [0 ].name ,
83
+ "Step out and in gets to no_return"
84
+ )
85
+
86
+ thread .StepOut ()
87
+ self .assertIn ("a.testStringify" , thread .frames [0 ].name , "Step out from no_return" )
88
+
50
89
# Make sure we can set a symbolic breakpoint on a macro.
51
90
b = target .BreakpointCreateByName ("stringify" )
52
91
self .assertGreaterEqual (b .GetNumLocations (), 1 )
0 commit comments