@@ -46,74 +46,75 @@ def check_list_output(self, command, active_plans = [], completed_plans = [], di
46
46
self .assertTrue (result .Succeeded (), "command: '%s' failed: '%s'" % (command , result .GetError ()))
47
47
result_arr = result .GetOutput ().splitlines ()
48
48
num_results = len (result_arr )
49
-
50
- # Match the expected number of elements.
51
- # Adjust the count for the number of header lines we aren't matching:
52
- fudge = 0
53
49
54
- if num_completed == 0 and num_discarded == 0 :
55
- # The fudge is 3: Thread header, Active Plan header and base plan
56
- fudge = 3
57
- elif num_completed == 0 or num_discarded == 0 :
58
- # The fudge is 4: The above plus either the Completed or Discarded Plan header:
59
- fudge = 4
60
- else :
61
- # The fudge is 5 since we have both headers:
62
- fudge = 5
63
-
64
- self .assertEqual (num_results , num_active + num_completed + num_discarded + fudge ,
65
- "Too many elements in match arrays for: \n %s\n " % result .GetOutput ())
66
-
67
50
# Now iterate through the results array and pick out the results.
68
51
result_idx = 0
69
52
self .assertIn ("thread #" , result_arr [result_idx ], "Found thread header" ) ; result_idx += 1
70
53
self .assertIn ("Active plan stack" , result_arr [result_idx ], "Found active header" ) ; result_idx += 1
71
54
self .assertIn ("Element 0: Base thread plan" , result_arr [result_idx ], "Found base plan" ) ; result_idx += 1
72
55
73
56
for text in active_plans :
74
- self .assertFalse ("Completed plan stack" in result_arr [result_idx ], "Found Completed header too early." )
75
57
self .assertIn (text , result_arr [result_idx ], "Didn't find active plan: %s" % (text )) ; result_idx += 1
58
+
76
59
77
60
if len (completed_plans ) > 0 :
78
- self .assertIn ("Completed plan stack:" , result_arr [result_idx ], "Found completed plan stack header" ) ; result_idx += 1
61
+ # First consume any remaining active plans:
62
+ while not "Completed plan stack:" in result_arr [result_idx ]:
63
+ result_idx += 1
64
+ if result_idx == num_results :
65
+ self .fail ("There should have been completed plans, but I never saw the completed stack header" )
66
+ # We are at the Completed header, skip it:
67
+ result_idx += 1
79
68
for text in completed_plans :
80
69
self .assertIn (text , result_arr [result_idx ], "Didn't find completed plan: %s" % (text )) ; result_idx += 1
81
70
82
71
if len (discarded_plans ) > 0 :
83
- self .assertIn ("Discarded plan stack:" , result_arr [result_idx ], "Found discarded plan stack header" ) ; result_idx += 1
72
+ # First consume any remaining completed plans:
73
+ while not "Discarded plan stack:" in result_arr [result_idx ]:
74
+ result_idx += 1
75
+ if result_idx == num_results :
76
+ self .fail ("There should have been discarded plans, but I never saw the discarded stack header" )
77
+
78
+ # We are at the Discarded header, skip it:
79
+ result_idx += 1
84
80
for text in discarded_plans :
85
- self .assertIn (text , result_arr [result_idx ], "Didn't find completed plan: %s" % (text )) ; result_idx += 1
81
+ self .assertIn (text , result_arr [result_idx ], "Didn't find discarded plan: %s" % (text )) ; result_idx += 1
86
82
87
83
88
84
def thread_plan_test (self ):
89
85
(target , process , thread , bkpt ) = lldbutil .run_to_source_breakpoint (self ,
90
86
"Set a breakpoint here" , self .main_source_file )
91
87
92
- # Now set a breakpoint in call_me and step over. We should have
93
- # two public thread plans
88
+ # We need to have an internal plan so we can test listing one.
89
+ # The most consistent way to do that is to use a scripted thread plan
90
+ # that uses a sub-plan. Source that in now.
91
+ source_path = os .path .join (self .getSourceDir (), "wrap_step_over.py" )
92
+ self .runCmd ("command script import '%s'" % (source_path ))
93
+
94
+ # Now set a breakpoint that we will hit by running our scripted step.
94
95
call_me_bkpt = target .BreakpointCreateBySourceRegex ("Set another here" , self .main_source_file )
95
96
self .assertTrue (call_me_bkpt .GetNumLocations () > 0 , "Set the breakpoint successfully" )
96
- thread .StepOver ( )
97
+ thread .StepUsingScriptedThreadPlan ( "wrap_step_over.WrapStepOver" )
97
98
threads = lldbutil .get_threads_stopped_at_breakpoint (process , call_me_bkpt )
98
99
self .assertEqual (len (threads ), 1 , "Hit my breakpoint while stepping over" )
99
100
100
101
current_id = threads [0 ].GetIndexID ()
101
102
current_tid = threads [0 ].GetThreadID ()
102
103
# Run thread plan list without the -i flag:
103
104
command = "thread plan list %d" % (current_id )
104
- self .check_list_output (command , ["Stepping over line main.c " ], [])
105
+ self .check_list_output (command , ["wrap_step_over.WrapStepOver " ], [])
105
106
106
107
# Run thread plan list with the -i flag:
107
108
command = "thread plan list -i %d" % (current_id )
108
- self .check_list_output (command , ["Stepping over line main.c" , "Stepping out from " ])
109
+ self .check_list_output (command , ["WrapStepOver" , " Stepping over line main.c" ])
109
110
110
111
# Run thread plan list providing TID, output should be the same:
111
112
command = "thread plan list -t %d" % (current_tid )
112
- self .check_list_output (command , ["Stepping over line main.c " ])
113
+ self .check_list_output (command , ["wrap_step_over.WrapStepOver " ])
113
114
114
115
# Provide both index & tid, and make sure we only print once:
115
116
command = "thread plan list -t %d %d" % (current_tid , current_id )
116
- self .check_list_output (command , ["Stepping over line main.c " ])
117
+ self .check_list_output (command , ["wrap_step_over.WrapStepOver " ])
117
118
118
119
# Try a fake TID, and make sure that fails:
119
120
fake_tid = 0
@@ -133,7 +134,7 @@ def thread_plan_test(self):
133
134
134
135
# Run thread plan list - there aren't any private plans at this point:
135
136
command = "thread plan list %d" % (current_id )
136
- self .check_list_output (command , [], ["Stepping over line main.c " ])
137
+ self .check_list_output (command , [], ["wrap_step_over.WrapStepOver " ])
137
138
138
139
# Set another breakpoint that we can run to, to try deleting thread plans.
139
140
second_step_bkpt = target .BreakpointCreateBySourceRegex ("Run here to step over again" ,
0 commit comments