Skip to content

Commit 615e442

Browse files
committed
feat: start adding breakpoint logic to load_diff_flow; not finished
building but not tested correctly: also more work! TODO
1 parent 7d0028d commit 615e442

File tree

2 files changed

+19
-5
lines changed

2 files changed

+19
-5
lines changed

src/db-backend/src/diff.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use runtime_tracing::FunctionId;
99
use log::info;
1010

1111
use crate::db::{Db,DbReplay};
12-
use crate::task::TraceKind;
12+
use crate::task::{TraceKind, FlowUpdate};
1313
use crate::trace_processor::{load_trace_data, load_trace_metadata, TraceProcessor};
1414
use crate::flow_preloader::FlowPreloader;
1515

@@ -148,7 +148,10 @@ pub fn index_diff(diff: Diff, trace_folder: &Path) -> Result<(), Box<dyn Error>>
148148
info!("diff_lines {diff_lines:?}");
149149
let mut flow_preloader = FlowPreloader::new();
150150
let mut replay = DbReplay::new(Box::new(db.clone()));
151-
let flow_update = flow_preloader.load_diff_flow(diff_lines, &db, TraceKind::DB, &mut replay);
151+
let flow_update = match flow_preloader.load_diff_flow(diff_lines, &db, TraceKind::DB, &mut replay) {
152+
Ok(flow_update_direct) => flow_update_direct,
153+
Err(_e) => FlowUpdate::error("load diff flow error: {e:?}"),
154+
};
152155

153156
let raw = serde_json::to_string(&flow_update)?;
154157
std::fs::write(trace_folder.join("diff_index.json"), raw)?;

src/db-backend/src/flow_preloader.rs

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ impl FlowPreloader {
4343
}
4444
}
4545

46-
pub fn load_diff_flow(&mut self, diff_lines: HashSet<(PathBuf, i64)>, db: &Db, trace_kind: TraceKind, replay: &mut dyn Replay) -> FlowUpdate {
46+
pub fn load_diff_flow(&mut self, diff_lines: HashSet<(PathBuf, i64)>, db: &Db, trace_kind: TraceKind, replay: &mut dyn Replay) -> Result<FlowUpdate, Box<dyn Error>> {
4747
info!("load_diff_flow");
4848
for diff_line in &diff_lines {
4949
match self.expr_loader.load_file(&diff_line.0) {
@@ -52,12 +52,23 @@ impl FlowPreloader {
5252
}
5353
Err(e) => {
5454
warn!("can't process file {}: error {}", diff_line.0.display(), e);
55-
return FlowUpdate::error(&format!("can't process file {}", diff_line.0.display()));
55+
return Err(format!("can't process file {}", diff_line.0.display()).into()); // FlowUpdate::error(&format!("can't process file {}", diff_line.0.display()));
5656
}
5757
}
5858
}
5959

6060
let mut diff_call_keys = HashSet::new();
61+
// put breakpoints on all of them
62+
for diff_line in &diff_lines {
63+
let _ = replay.add_breakpoint(&diff_line.0.display().to_string(), diff_line.1)?;
64+
}
65+
// TODO: breakpoints on function entries or function names as well
66+
// so => we can count how many stops?
67+
//
68+
// just continue for now in next diff flow step; and if we go through the function/function entry line or
69+
// breakpoint; count a next call for it;
70+
// maybe this will just work because they're registered as loop first line
71+
6172
for step in db.step_from(runtime_tracing::StepId(0), true) {
6273
if diff_lines.contains(&(PathBuf::from(db.paths[step.path_id].clone()), step.line.0)) {
6374
diff_call_keys.insert(step.call_key.0);
@@ -71,7 +82,7 @@ impl FlowPreloader {
7182

7283
let mut call_flow_preloader = CallFlowPreloader::new(self, Location::default(), diff_lines, diff_call_keys, FlowMode::Diff, trace_kind);
7384
let location = Location { line: 1, ..Location::default() };
74-
call_flow_preloader.load_flow(location, replay)
85+
Ok(call_flow_preloader.load_flow(location, replay))
7586
}
7687

7788
// fn load_file(&mut self, path: &str) {

0 commit comments

Comments
 (0)