Stream: compiler development

Topic: lldb line tracer


view this post on Zulip Anton (Jun 21 2025 at 17:47):

Output of uftrace wasn't exactly what I needed for debugging #compiler development > slow build with lots of `?` so I made an lldb script to log every executed line of code in a specific file like inc_dec.rs. The output looks like this:

(lldb) process launch -- check hello.roc
=> function: check_file
*  1339     let compilation_start = Instant::now();
*  1343     let target = Target::LinuxX64;
*  1349         function_kind: FunctionKind::from_env(),
*  1351         render: RenderTarget::ColorTerminal,
*  1354         exec_mode: ExecutionMode::Check,
*  1347     let load_config = LoadConfig {
*  1358         roc_file_path,
*  1359         opt_main_path,
*  1356     let mut loaded = roc_load::load_and_typecheck(
*  1364     let buf = &mut String::with_capacity(1024);
*  1366     let mut it = loaded.timings.iter().peekable();
*  1367     while let Some((module_id, module_timing)) = it.next() {
*  1368         let module_name = loaded.interns.module_name(*module_id);
*  1370         buf.push_str("    ");
*  1372         if module_name.is_empty() {
*  1376             buf.push_str(module_name);
*  1379         buf.push('\n');
*  1381         report_timing(buf, "Read .roc file from disk", module_timing.read_roc_file);
=> function: report_timing
*   606         duration.as_secs_f64() * 1000.0,
*   603     writeln!(
*   610 }
[...]

(Code line numbers are on the left)
It's what you need when there is too much code to step through with the debugger :)

It works with zig too!


Last updated: Jul 06 2025 at 12:14 UTC