Skip to content

Commit 6ec3d43

Browse files
committed
fix: small fixes for raw diff index & db-backend test
small fixes after rebase; however also a `main.rs` fix, because we were handling structured diff CLI arg, as path, but it was the source not sure how this ever worked also a small fix for the dap server test (putting the new way to called the binary in the right place, sorry) copying commit message from original raw_diff_index commit by me and Nedy for context: (a624ea0): fix: try to pass raw diff index content to db-backend instead of hardcoding path Part of a pairing session with Nedy; TODO: (alexander: i decided for now to go with passing it directly with CLI for faster prototype/working version) still hacky as CLI args have limited size/memory, but for initial internal version hopefully ok
1 parent ed610cf commit 6ec3d43

File tree

5 files changed

+17
-10
lines changed

5 files changed

+17
-10
lines changed

src/db-backend/src/dap_server.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ pub fn run(socket_path: &PathBuf) -> Result<(), Box<dyn Error>> {
8686
handle_client(&mut reader, &mut writer)
8787
}
8888

89-
fn launch(trace_folder: &Path, trace_file: &Path, seq: i64) -> Result<Handler, Box<dyn Error>> {
89+
fn launch(trace_folder: &Path, trace_file: &Path, raw_diff_index: Option<String>, seq: i64) -> Result<Handler, Box<dyn Error>> {
9090
// TODO: log this when logging logic is properly abstracted
9191
info!("run launch() for {:?}", trace_folder);
9292
let trace_file_format = if trace_file.extension() == Some(std::ffi::OsStr::new("json")) {
@@ -108,6 +108,7 @@ fn launch(trace_folder: &Path, trace_file: &Path, seq: i64) -> Result<Handler, B
108108

109109
let mut handler = Handler::new(Box::new(db));
110110
handler.dap_client.seq = seq;
111+
handler.raw_diff_index = raw_diff_index;
111112
handler.run_to_entry(dap::Request::default())?;
112113
Ok(handler)
113114
} else {
@@ -233,6 +234,7 @@ pub struct Ctx {
233234
pub received_launch: bool,
234235
pub launch_trace_folder: PathBuf,
235236
pub launch_trace_file: PathBuf,
237+
pub launch_raw_diff_index: Option<String>,
236238
pub received_configuration_done: bool,
237239
}
238240

@@ -245,6 +247,7 @@ impl Default for Ctx {
245247
received_launch: false,
246248
launch_trace_folder: PathBuf::from(""),
247249
launch_trace_file: PathBuf::from(""),
250+
launch_raw_diff_index: None,
248251
received_configuration_done: false,
249252
}
250253
}
@@ -392,8 +395,10 @@ pub fn handle_message<T: DapTransport>(
392395
// TODO: log this when logging logic is properly abstracted
393396
//info!("stored launch trace folder: {0:?}", ctx.launch_trace_folder)
394397

398+
ctx.launch_raw_diff_index = args.raw_diff_index.clone();
399+
395400
if ctx.received_configuration_done {
396-
ctx.handler = Some(launch(&ctx.launch_trace_folder, &ctx.launch_trace_file, ctx.seq)?);
401+
ctx.handler = Some(launch(&ctx.launch_trace_folder, &ctx.launch_trace_file, ctx.launch_raw_diff_index.clone(), ctx.seq)?);
397402
if let Some(h) = ctx.handler.as_mut() {
398403
write_dap_messages(transport, h, &mut ctx.seq)?;
399404
}
@@ -442,7 +447,7 @@ pub fn handle_message<T: DapTransport>(
442447
// ctx.received_launch
443448
// );
444449
if ctx.received_launch {
445-
ctx.handler = Some(launch(&ctx.launch_trace_folder, &ctx.launch_trace_file, ctx.seq)?);
450+
ctx.handler = Some(launch(&ctx.launch_trace_folder, &ctx.launch_trace_file, ctx.launch_raw_diff_index.clone(), ctx.seq)?);
446451
if let Some(h) = ctx.handler.as_mut() {
447452
write_dap_messages(transport, h, &mut ctx.seq)?;
448453
}

src/db-backend/src/diff.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ pub struct DiffLine {
6767

6868
// loop shape 1:
6969
pub fn load_and_postprocess_trace(trace_folder: &Path) -> Result<Db, Box<dyn Error>> {
70+
info!("load_and_postprocess_trace {:?}", trace_folder.display());
7071
let mut trace_path = trace_folder.join("trace.json");
7172
let mut trace_file_format = runtime_tracing::TraceEventsFileFormat::Json;
7273
if !trace_path.exists() {
@@ -107,6 +108,7 @@ fn index_function_flow(_db: &Db, function_id: FunctionId) -> Result<(), Box<dyn
107108

108109

109110
pub fn index_diff(diff: Diff, trace_folder: &Path, multitrace_folder: &Path) -> Result<(), Box<dyn Error>> {
111+
info!("index_diff");
110112
let db = load_and_postprocess_trace(trace_folder)?;
111113

112114
// breakpoint on each diff line or at least track it for db-backend

src/db-backend/src/flow_preloader.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ impl FlowPreloader {
4141
}
4242

4343
pub fn load_diff_flow(&mut self, diff_lines: HashSet<(PathBuf, i64)>, db: &Db) -> FlowUpdate {
44+
info!("load_diff_flow");
4445
for diff_line in &diff_lines {
4546
match self.expr_loader.load_file(&diff_line.0) {
4647
Ok(_) => {

src/db-backend/src/main.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ enum Commands {
6565
stdio: bool,
6666
},
6767
IndexDiff {
68-
structured_diff_path: std::path::PathBuf,
68+
structured_diff_raw: String, // _path: std::path::PathBuf,
6969
trace_folder: std::path::PathBuf,
7070
multitrace_folder: std::path::PathBuf,
7171
},
@@ -139,13 +139,13 @@ fn main() -> Result<(), Box<dyn Error>> {
139139
};
140140
}
141141
Commands::IndexDiff {
142-
structured_diff_path,
142+
structured_diff_raw,
143143
trace_folder,
144144
multitrace_folder,
145145
} => {
146-
let raw = std::fs::read_to_string(structured_diff_path)?;
147-
info!("raw {raw:?}");
148-
let structured_diff = serde_json::from_str::<diff::Diff>(&raw)?;
146+
// TODO: eventually structured diff path? big diff-s might not fit into CLI args
147+
// let raw = std::fs::read_to_string(structured_diff_path)?;
148+
let structured_diff = serde_json::from_str::<diff::Diff>(&structured_diff_raw)?;
149149
diff::index_diff(structured_diff, &trace_folder, &multitrace_folder)?;
150150
}
151151
}

src/db-backend/tests/dap_backend_server.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ fn test_backend_dap_server() {
3939
let trace_dir = PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("trace");
4040

4141
let socket_path = dap_server::socket_path_for(std::process::id() as usize);
42-
let mut child = Command::new(bin).arg("dap-server").arg(&socket_path).spawn().unwrap();
4342

4443
if let Some(dir) = socket_path.parent() {
4544
fs::create_dir_all(dir).unwrap_or_else(|err| panic!("failed to create socket directory {dir:?}: {err}"));
@@ -63,7 +62,7 @@ fn test_backend_dap_server() {
6362
// use std::os::unix::fs::PermissionsExt;
6463
// fs::set_permissions(&socket_path, fs::Permissions::from_mode(0o600))?;
6564

66-
let mut child = Command::new(bin).arg(&socket_path).spawn().unwrap();
65+
let mut child = Command::new(bin).arg("dap-server").arg(&socket_path).spawn().unwrap();
6766
println!("Bin: {}", bin);
6867

6968
println!("Socket path: {}", socket_path.to_str().unwrap());

0 commit comments

Comments
 (0)