@@ -6,7 +6,7 @@ use std::mem::swap;
6
6
use std:: rc:: Rc ;
7
7
8
8
use debug_types:: events:: { ContinuedEvent , Event , EventBody , StoppedEvent , StoppedReason } ;
9
- use debug_types:: requests:: { InitializeRequestArguments , LaunchRequestArguments , RequestCommand } ;
9
+ use debug_types:: requests:: { InitializeRequestArguments , RequestCommand } ;
10
10
use debug_types:: responses:: {
11
11
InitializeResponse , Response , ResponseBody , ScopesResponse , SetBreakpointsResponse ,
12
12
SetExceptionBreakpointsResponse , StackTraceResponse , ThreadsResponse , VariablesResponse ,
@@ -20,17 +20,17 @@ use clvmr::allocator::Allocator;
20
20
21
21
use clvm_tools_rs:: classic:: clvm_tools:: stages:: stage_0:: TRunProgram ;
22
22
23
- use clvm_tools_rs:: compiler:: cldb_hierarchy:: HierarchialRunner ;
24
23
use clvm_tools_rs:: compiler:: compiler:: DefaultCompilerOpts ;
25
- use clvm_tools_rs:: compiler:: sexp:: { decode_string, parse_sexp , SExp } ;
24
+ use clvm_tools_rs:: compiler:: sexp:: { decode_string, SExp } ;
26
25
use clvm_tools_rs:: compiler:: srcloc:: Srcloc ;
27
26
28
27
use crate :: dbg:: compopts:: DbgCompilerOpts ;
29
- use crate :: dbg:: obj:: { read_program_data , RunningDebugger , TargetDepth } ;
28
+ use crate :: dbg:: obj:: { ObjLaunchArgs , RunningDebugger , TargetDepth } ;
30
29
use crate :: dbg:: source:: { parse_srcloc, StoredScope } ;
31
30
use crate :: dbg:: types:: MessageHandler ;
32
31
use crate :: interfaces:: { IFileReader , ILogWriter } ;
33
32
use crate :: lsp:: types:: ConfigJson ;
33
+
34
34
// Lifecycle:
35
35
// (a (code... ) (c arg ...))
36
36
// We encounter this and we're creating the arguments for a future call to
@@ -49,6 +49,8 @@ pub struct ExtraLaunchData {
49
49
args : Option < Vec < String > > ,
50
50
#[ serde( rename = "program" ) ]
51
51
program : Option < String > ,
52
+ #[ serde( rename = "symbols" ) ]
53
+ symbols : Option < String > ,
52
54
}
53
55
54
56
/// Used to make some aspects of deserializing easier via serde_json easier.
@@ -59,6 +61,11 @@ pub struct RequestContainer<T> {
59
61
arguments : T ,
60
62
}
61
63
64
+ pub struct LaunchArgs < ' a > {
65
+ proto_msg : & ' a ProtocolMessage ,
66
+ obj_launch_args : ObjLaunchArgs < ' a > ,
67
+ }
68
+
62
69
/// State diagram for the debugger.
63
70
///
64
71
/// Starts in PreInitialization until we get an Initialization request.
@@ -180,16 +187,6 @@ fn get_initialize_response() -> InitializeResponse {
180
187
}
181
188
}
182
189
183
- struct LaunchArgs < ' a > {
184
- proto_msg : & ' a ProtocolMessage ,
185
- name : & ' a str ,
186
- init_args : & ' a InitializeRequestArguments ,
187
- launch_request : & ' a LaunchRequestArguments ,
188
- program : & ' a str ,
189
- args_for_program : & ' a [ String ] ,
190
- stop_on_entry : bool ,
191
- }
192
-
193
190
impl Debugger {
194
191
fn get_source_loc ( & self , running : & RunningDebugger , name : & str ) -> Option < Srcloc > {
195
192
let get_helper_loc = |name : & str | {
@@ -249,64 +246,22 @@ impl Debugger {
249
246
let mut allocator = Allocator :: new ( ) ;
250
247
let mut seq_nr = self . msg_seq ;
251
248
let config = self . read_chialisp_json ( ) ?;
252
- let read_in_file = self . fs . read_content ( launch_args. program ) ?;
253
- let def_opts = Rc :: new ( DefaultCompilerOpts :: new ( & launch_args. name ) ) ;
249
+ let def_opts = Rc :: new ( DefaultCompilerOpts :: new ( & launch_args. obj_launch_args . name ) ) ;
254
250
let opts = Rc :: new ( DbgCompilerOpts :: new (
255
251
def_opts,
256
252
self . log . clone ( ) ,
257
253
self . fs . clone ( ) ,
258
254
& config. include_paths ,
259
255
) ) ;
260
- let mut launch_data = read_program_data (
256
+ let debugger = RunningDebugger :: create (
257
+ & mut allocator,
261
258
self . fs . clone ( ) ,
262
259
self . log . clone ( ) ,
263
- & mut allocator ,
260
+ self . runner . clone ( ) ,
264
261
opts. clone ( ) ,
265
- launch_args. init_args ,
266
- launch_args. launch_request ,
267
- launch_args. program ,
268
- read_in_file. as_bytes ( ) ,
262
+ & launch_args. obj_launch_args ,
269
263
) ?;
270
-
271
- if !launch_args. args_for_program . is_empty ( ) {
272
- let parsed_argv0 = parse_sexp (
273
- Srcloc :: start ( "*args*" ) ,
274
- launch_args. args_for_program [ 0 ] . bytes ( ) ,
275
- )
276
- . map_err ( |( l, e) | format ! ( "{l}: {e}" ) ) ?;
277
- if !parsed_argv0. is_empty ( ) {
278
- launch_data. arguments = parsed_argv0[ 0 ] . clone ( ) ;
279
- }
280
- }
281
-
282
- let symbol_rc = Rc :: new ( launch_data. symbols ) ;
283
-
284
- let run = HierarchialRunner :: new (
285
- self . runner . clone ( ) ,
286
- self . prim_map . clone ( ) ,
287
- Some ( launch_args. name . to_string ( ) ) ,
288
- Rc :: new ( launch_data. program_lines ) ,
289
- symbol_rc. clone ( ) ,
290
- launch_data. program ,
291
- launch_data. arguments ,
292
- ) ;
293
- let state = State :: Launched ( RunningDebugger {
294
- initialized : launch_args. init_args . clone ( ) ,
295
- launch_info : launch_args. launch_request . clone ( ) ,
296
- running : !launch_args. stop_on_entry ,
297
- run,
298
- opts,
299
- output_stack : Vec :: new ( ) ,
300
- stopped_reason : None ,
301
- target_depth : None ,
302
- result : None ,
303
- source_file : launch_data. source_file ,
304
- compiled : launch_data. compiled ,
305
- breakpoints : HashMap :: new ( ) ,
306
- next_bp_id : 1 ,
307
- at_breakpoint : None ,
308
- symbols : symbol_rc,
309
- } ) ;
264
+ let state = State :: Launched ( debugger) ;
310
265
311
266
seq_nr += 1 ;
312
267
let mut out_messages = vec ! [ ProtocolMessage {
@@ -320,7 +275,7 @@ impl Debugger {
320
275
} ] ;
321
276
322
277
// Signal that we're paused if stop on entry.
323
- if launch_args. stop_on_entry {
278
+ if launch_args. obj_launch_args . stop_on_entry {
324
279
seq_nr += 1 ;
325
280
out_messages. push ( ProtocolMessage {
326
281
seq : self . msg_seq ,
@@ -402,19 +357,25 @@ impl MessageHandler<ProtocolMessage> for Debugger {
402
357
. as_ref ( )
403
358
. and_then ( |l| l. arguments . args . clone ( ) )
404
359
. unwrap_or ( vec ! [ ] ) ;
360
+ let symbols = launch_extra
361
+ . as_ref ( )
362
+ . and_then ( |l| l. arguments . symbols . clone ( ) )
363
+ . unwrap_or ( "" . to_string ( ) ) ;
405
364
if let Some ( name) = & l. name {
406
365
let program = launch_extra
407
366
. and_then ( |l| l. arguments . program )
408
367
. unwrap_or ( name. clone ( ) ) ;
409
368
410
369
let ( new_seq, new_state, out_msgs) = self . launch ( LaunchArgs {
411
370
proto_msg : pm,
412
- name,
413
- init_args : & i,
414
- launch_request : l,
415
- program : & program,
416
- args_for_program : & args,
417
- stop_on_entry,
371
+ obj_launch_args : ObjLaunchArgs {
372
+ init_args : & i,
373
+ name,
374
+ program : & program,
375
+ args_for_program : & args,
376
+ symbols : & symbols,
377
+ stop_on_entry,
378
+ } ,
418
379
} ) ?;
419
380
self . msg_seq = new_seq;
420
381
self . state = new_state;
0 commit comments