Skip to content

Commit 57be897

Browse files
committed
fix: fix many jumps: fix most places where we directly jump with step id
i forgot that now we mostly move with `self.replay`, so just changing the handler step_id might not be enough problem with iterate_asteroids flow remains
1 parent 47bb093 commit 57be897

File tree

1 file changed

+21
-26
lines changed

1 file changed

+21
-26
lines changed

src/db-backend/src/handler.rs

Lines changed: 21 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -446,19 +446,6 @@ impl Handler {
446446
}
447447

448448
pub fn load_flow(&mut self, _req: dap::Request, arg: CtLoadFlowArguments) -> Result<(), Box<dyn Error>> {
449-
// if self.trace_kind == TraceKind::RR {
450-
// warn!("flow not implemented for rr");
451-
// self.send_notification(NotificationKind::Warning, "flow not implemented for rr!", false)?;
452-
// return Ok(());
453-
// }
454-
// TODO: something like this for db/rr:
455-
// {
456-
// // TODO: pass step_id to load_location and let it jump for RR if needed?
457-
// // or have a separate jump_to when it's not self.step_id?
458-
// self.replay.jump_to(step_id)?;
459-
// let location = self.replay.load_location(&mut self.expr_loader)?;
460-
// }
461-
462449
let mut flow_replay: Box<dyn Replay> = if self.trace_kind == TraceKind::DB {
463450
Box::new(DbReplay::new(self.db.clone()))
464451
} else {
@@ -659,7 +646,8 @@ impl Handler {
659646
pub fn event_jump(&mut self, _req: dap::Request, event: ProgramEvent) -> Result<(), Box<dyn Error>> {
660647
let step_id = StepId(event.direct_location_rr_ticks); // currently using this field
661648
// for compat with rr/gdb core support
662-
self.step_id_jump(step_id);
649+
self.replay.jump_to(step_id)?;
650+
self.step_id = self.replay.current_step_id();
663651
self.complete_move(false)?;
664652

665653
Ok(())
@@ -668,7 +656,8 @@ impl Handler {
668656
pub fn calltrace_jump(&mut self, _req: dap::Request, location: Location) -> Result<(), Box<dyn Error>> {
669657
let step_id = StepId(location.rr_ticks.0); // using this field
670658
// for compat with rr/gdb core support
671-
self.step_id_jump(step_id);
659+
self.replay.jump_to(step_id)?;
660+
self.step_id = self.replay.current_step_id();
672661
self.complete_move(false)?;
673662

674663
Ok(())
@@ -765,7 +754,8 @@ impl Handler {
765754
}
766755

767756
pub fn history_jump(&mut self, _req: dap::Request, loc: Location) -> Result<(), Box<dyn Error>> {
768-
self.step_id_jump(StepId(loc.rr_ticks.0));
757+
self.replay.jump_to(StepId(loc.rr_ticks.0))?;
758+
self.step_id = self.replay.current_step_id();
769759
self.complete_move(false)?;
770760
Ok(())
771761
}
@@ -820,7 +810,8 @@ impl Handler {
820810
source_location: SourceLocation,
821811
) -> Result<(), Box<dyn Error>> {
822812
if let Some(step_id) = self.get_closest_step_id(&source_location) {
823-
self.step_id_jump(step_id);
813+
self.replay.jump_to(step_id)?;
814+
self.step_id = self.replay.current_step_id();
824815
self.complete_move(false)?;
825816
Ok(())
826817
} else {
@@ -829,11 +820,11 @@ impl Handler {
829820
}
830821
}
831822

832-
fn step_id_jump(&mut self, step_id: StepId) {
833-
if step_id.0 != NO_INDEX {
834-
self.step_id = step_id;
835-
}
836-
}
823+
// fn step_id_jump(&mut self, step_id: StepId) {
824+
// if step_id.0 != NO_INDEX {
825+
// self.step_id = step_id;
826+
// }
827+
// }
837828

838829
fn get_call_target(&self, loc: &SourceCallJumpTarget) -> Option<StepId> {
839830
let mut line: Line = Line(loc.line as i64);
@@ -869,11 +860,13 @@ impl Handler {
869860
line: call_target.line,
870861
path: call_target.path.clone(),
871862
}) {
872-
self.step_id_jump(line_step_id);
863+
self.replay.jump_to(line_step_id)?;
864+
self.step_id = self.replay.current_step_id();
873865
}
874866

875867
if let Some(call_step_id) = self.get_call_target(&call_target) {
876-
self.step_id_jump(call_step_id);
868+
self.replay.jump_to(call_step_id)?;
869+
self.step_id = self.replay.current_step_id();
877870
self.complete_move(false)?;
878871
Ok(())
879872
} else {
@@ -1097,7 +1090,8 @@ impl Handler {
10971090
}
10981091

10991092
pub fn trace_jump(&mut self, _req: dap::Request, event: ProgramEvent) -> Result<(), Box<dyn Error>> {
1100-
self.step_id_jump(StepId(event.direct_location_rr_ticks));
1093+
self.replay.jump_to(StepId(event.direct_location_rr_ticks))?;
1094+
self.step_id = self.replay.current_step_id();
11011095
self.complete_move(false)?;
11021096
Ok(())
11031097
}
@@ -1167,7 +1161,8 @@ impl Handler {
11671161
}
11681162

11691163
pub fn local_step_jump(&mut self, _req: dap::Request, arg: LocalStepJump) -> Result<(), Box<dyn Error>> {
1170-
self.step_id_jump(StepId(arg.rr_ticks));
1164+
self.replay.jump_to(StepId(arg.rr_ticks))?;
1165+
self.step_id = self.replay.current_step_id();
11711166
self.complete_move(false)?;
11721167
Ok(())
11731168
}

0 commit comments

Comments
 (0)