@@ -10,7 +10,7 @@ use runtime_tracing::{CallKey, EventLogKind, Line, PathId, StepId, VariableId, N
1010
1111use crate :: calltrace:: Calltrace ;
1212use crate :: dap:: { self , DapClient , DapMessage } ;
13- use crate :: db:: { BreakpointRecord , Db , DbCall , DbRecordEvent , DbReplay , DbStep } ;
13+ use crate :: db:: { Db , DbCall , DbRecordEvent , DbReplay , DbStep } ;
1414use crate :: event_db:: { EventDb , SingleTableId } ;
1515use crate :: expr_loader:: ExprLoader ;
1616use crate :: flow_preloader:: FlowPreloader ;
@@ -57,8 +57,6 @@ pub struct Handler {
5757 pub replay : Box < dyn Replay > ,
5858 pub ct_rr_args : CtRRArgs ,
5959 pub load_flow_index : usize ,
60-
61- pub breakpoint_list : Vec < HashMap < usize , BreakpointRecord > > ,
6260}
6361
6462#[ derive( Debug , Clone , PartialEq ) ]
@@ -94,8 +92,6 @@ impl Handler {
9492 let calltrace = Calltrace :: new ( & db) ;
9593 let trace = CoreTrace :: default ( ) ;
9694 let mut expr_loader = ExprLoader :: new ( trace. clone ( ) ) ;
97- let mut breakpoint_list: Vec < HashMap < usize , BreakpointRecord > > = Default :: default ( ) ;
98- breakpoint_list. resize_with ( db. paths . len ( ) , HashMap :: new) ;
9995 let step_lines_loader = StepLinesLoader :: new ( & db, & mut expr_loader) ;
10096 let replay: Box < dyn Replay > = if trace_kind == TraceKind :: DB {
10197 Box :: new ( DbReplay :: new ( db. clone ( ) ) )
@@ -110,7 +106,6 @@ impl Handler {
110106 last_call_key : CallKey ( 0 ) ,
111107 indirect_send,
112108 // sender,
113- breakpoint_list,
114109 event_db : EventDb :: new ( ) ,
115110 flow_preloader : FlowPreloader :: new ( ) ,
116111 expr_loader,
@@ -809,14 +804,31 @@ impl Handler {
809804 _req : dap:: Request ,
810805 source_location : SourceLocation ,
811806 ) -> Result < ( ) , Box < dyn Error > > {
812- if let Some ( step_id) = self . get_closest_step_id ( & source_location) {
813- self . replay . jump_to ( step_id) ?;
814- self . step_id = self . replay . current_step_id ( ) ;
815- self . complete_move ( false ) ?;
816- Ok ( ( ) )
807+ if self . trace_kind == TraceKind :: DB {
808+ if let Some ( step_id) = self . get_closest_step_id ( & source_location) {
809+ self . replay . jump_to ( step_id) ?;
810+ self . step_id = self . replay . current_step_id ( ) ;
811+ self . complete_move ( false ) ?;
812+ Ok ( ( ) )
813+ } else {
814+ let err: String = format ! ( "unknown location: {}" , & source_location) ;
815+ Err ( err. into ( ) )
816+ }
817817 } else {
818- let err: String = format ! ( "unknown location: {}" , & source_location) ;
819- Err ( err. into ( ) )
818+ let b = self . replay . add_breakpoint ( & source_location. path , source_location. line as i64 ) ?;
819+ match self . replay . step ( Action :: Continue , true ) {
820+ Ok ( _) => {
821+ self . replay . delete_breakpoint ( & b) ?; // make sure we do it before potential `?` fail in next functions
822+ let _location = self . replay . load_location ( & mut self . expr_loader ) ?;
823+ self . step_id = self . replay . current_step_id ( ) ;
824+ self . complete_move ( false ) ?;
825+ Ok ( ( ) )
826+ }
827+ Err ( e) => {
828+ self . replay . delete_breakpoint ( & b) ?;
829+ Err ( e)
830+ }
831+ }
820832 }
821833 }
822834
@@ -882,13 +894,8 @@ impl Handler {
882894 }
883895
884896 pub fn add_breakpoint ( & mut self , loc : SourceLocation , _task : Task ) -> Result < ( ) , Box < dyn Error > > {
885- let path_id_res: Result < PathId , Box < dyn Error > > = self
886- . load_path_id ( & loc. path )
887- . ok_or ( format ! ( "can't add a breakpoint: can't find path `{}`` in trace" , loc. path) . into ( ) ) ;
888- let path_id = path_id_res?;
889- let inner_map = & mut self . breakpoint_list [ path_id. 0 ] ;
890- inner_map. insert ( loc. line , BreakpointRecord { is_active : true } ) ;
891- Ok ( ( ) )
897+ self . replay . add_breakpoint ( & loc. path , loc. line as i64 ) ?;
898+ Ok ( ( ) )
892899 }
893900
894901 pub fn delete_breakpoint ( & mut self , loc : SourceLocation , _task : Task ) -> Result < ( ) , Box < dyn Error > > {
0 commit comments