@@ -10,19 +10,8 @@ use tracing::trace;
1010
1111use crate :: CairoDebugger ;
1212
13- pub enum HandleResult {
14- Handled ,
15- Trigger ( NextAction ) ,
16- }
17-
18- pub enum NextAction {
19- Resume ,
20- Stop ,
21- FinishInit ,
22- }
23-
2413impl CairoDebugger {
25- pub fn handle_request ( & self , request : Request ) -> Result < HandleResult > {
14+ pub fn handle_request ( & mut self , request : Request ) -> Result < ( ) > {
2615 match & request. command {
2716 // We have not yet decided if we want to support these.
2817 Command :: BreakpointLocations ( _)
@@ -89,20 +78,21 @@ impl CairoDebugger {
8978 } ) ,
9079 ) ?;
9180 self . connection . send_event ( Event :: Initialized ) ?;
92- Ok ( HandleResult :: Handled )
81+ Ok ( ( ) )
9382 }
9483 Command :: Launch ( _) => {
9584 self . connection . send_success ( request, ResponseBody :: Launch ) ?;
96- Ok ( HandleResult :: Handled )
85+ Ok ( ( ) )
9786 }
9887 Command :: ConfigurationDone => {
9988 // Start running the Cairo program here.
100- trace ! ( "Configuration done" ) ;
89+ self . state . set_configuration_done ( ) ;
10190 self . connection . send_success ( request, ResponseBody :: ConfigurationDone ) ?;
102- Ok ( HandleResult :: Trigger ( NextAction :: FinishInit ) )
91+ Ok ( ( ) )
10392 }
10493
10594 Command :: Pause ( _) => {
95+ self . state . stop_execution ( ) ;
10696 self . connection . send_event ( Event :: Stopped ( StoppedEventBody {
10797 reason : StoppedEventReason :: Pause ,
10898 thread_id : Some ( 0 ) ,
@@ -113,14 +103,15 @@ impl CairoDebugger {
113103 hit_breakpoint_ids : None ,
114104 } ) ) ?;
115105 self . connection . send_success ( request, ResponseBody :: Pause ) ?;
116- Ok ( HandleResult :: Trigger ( NextAction :: Stop ) )
106+ Ok ( ( ) )
117107 }
118108 Command :: Continue ( _) => {
109+ self . state . resume_execution ( ) ;
119110 self . connection . send_success (
120111 request,
121112 ResponseBody :: Continue ( ContinueResponse { all_threads_continued : Some ( true ) } ) ,
122113 ) ?;
123- Ok ( HandleResult :: Trigger ( NextAction :: Resume ) )
114+ Ok ( ( ) )
124115 }
125116
126117 Command :: SetBreakpoints ( args) => {
@@ -142,7 +133,7 @@ impl CairoDebugger {
142133 breakpoints : response_bps,
143134 } ) ,
144135 ) ?;
145- Ok ( HandleResult :: Handled )
136+ Ok ( ( ) )
146137 }
147138
148139 Command :: Threads => {
@@ -153,7 +144,7 @@ impl CairoDebugger {
153144 threads : vec ! [ Thread { id: 0 , name: "" . to_string( ) } ] ,
154145 } ) ,
155146 ) ?;
156- Ok ( HandleResult :: Handled )
147+ Ok ( ( ) )
157148 }
158149 Command :: StackTrace ( _) => {
159150 self . connection . send_success (
@@ -172,15 +163,15 @@ impl CairoDebugger {
172163 total_frames : Some ( 1 ) ,
173164 } ) ,
174165 ) ?;
175- Ok ( HandleResult :: Handled )
166+ Ok ( ( ) )
176167 }
177168 Command :: Scopes ( _) => {
178169 // Return no scopes.
179170 self . connection . send_success (
180171 request,
181172 ResponseBody :: Scopes ( ScopesResponse { scopes : vec ! [ ] } ) ,
182173 ) ?;
183- Ok ( HandleResult :: Handled )
174+ Ok ( ( ) )
184175 }
185176 Command :: Variables ( _) => {
186177 self . connection . send_success (
@@ -190,7 +181,7 @@ impl CairoDebugger {
190181 variables : vec ! [ ] ,
191182 } ) ,
192183 ) ?;
193- Ok ( HandleResult :: Handled )
184+ Ok ( ( ) )
194185 }
195186
196187 Command :: Next ( _) => {
@@ -220,7 +211,7 @@ impl CairoDebugger {
220211 memory_reference : None ,
221212 } ) ,
222213 ) ?;
223- Ok ( HandleResult :: Handled )
214+ Ok ( ( ) )
224215 }
225216
226217 Command :: Disconnect ( _) => {
0 commit comments