Implement source mapping#107
Implement source mapping#107bjorn3 merged 15 commits intoheadcrab-rs:masterfrom blitzerr:i-100upstream/master
Conversation
nbaksalyar
left a comment
There was a problem hiding this comment.
Nice one, thank you!
I left a few minor suggestions and noticed a few typos.
|
@nbaksalyar @bjorn3 the build is failing on This patch should not impact that, right ? |
|
Strange. |
|
It didn't fail earlier but after rebasing .. |
|
@bjorn3 and @nbaksalyar You comments are addressed and rebased with the latest. |
Hmm, probably an intermittent error related to #95 - I'll try to run separate fuzz-like tests with that. |
nbaksalyar
left a comment
There was a problem hiding this comment.
LGTM, thank you! I've just one minor comment about commented-out code
nbaksalyar
left a comment
There was a problem hiding this comment.
Thank you, great work! 👍
I've got one question about a new dependency which we can consider moving behind a feature-flag.
change summary -------------- (+) Print source lines when pausing on a breakpoint. (+) New command `list` or `l` (+) Some code refactoring. currently if you debug your program with lldb, and say your program stops at the set breakpoint, lldb will print the source line and not just filename and line number. It might be more clear with an example, so here goes one: ``` rust-lldb tests/testees/hello breakpoint set --file hello.rs --line 22 r (lldb) r Process 58912 launched: '/workspaces/headcrab/tests/testees/hello' (x86_64) Process 58912 stopped * thread #1, name = 'hello', stop reason = breakpoint 2.1 frame #0: 0x0000555555559301 hello`hello::main::hd078db076938ab99 at hello.rs:22 19 let mut temp = 100usize; 20 black_box(&mut temp); 21 } -> 22 black_box(reg_var); 23 breakpoint(); 24 black_box(reg_var); 25 println!("{} {}", STATICVAR, var); ``` Before this PR, the behavior of headcrab for a similar steps of execution would have been: ``` (headcrab) cargo run --example repl (headcrab) exec tests/testees/hello (headcrab) _patch_breakpoint_function (headcrab) cont (headcrab) ``` So, you can see, after cont(inuing) to the next breakpoint, headcrab is silent. You have to give the command `bt` to print the backtrace. ``` (headcrab) bt 0000555555559295 core::core_arch::x86::sse2::_mm_pause /usr/local/rustup/toolchains/1.45.2-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/libcore/../stdarch/crates/core_arch/src/x86/sse2.rs:25 breakpoint /workspaces/headcrab/tests/testees/hello.rs:7 000055555555930b hello::main /workspaces/headcrab/tests/testees/hello.rs:24 0000555555559246 std::rt::lang_start::{{closure}} /usr/local/rustup/toolchains/1.45.2-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/libstd/rt.rs:67 0000555555562c68 std::panicking::try /rustc/d3fb005a39e62501b8b0b356166e515ae24e2e54/src/libstd/panicking.rs:275 std::panic::catch_unwind /rustc/d3fb005a39e62501b8b0b356166e515ae24e2e54/src/libstd/panic.rs:394 std::rt::lang_start_internal /rustc/d3fb005a39e62501b8b0b356166e515ae24e2e54/src/libstd/rt.rs:51 ``` After the change, the output will be something like this: ``` (headcrab) exec tests/testees/hello Starting program: tests/testees/hello Stopped(Pid(75698), SIGTRAP) (headcrab) _patch_breakpoint_function (headcrab) cont Stopped(Pid(75698), SIGTRAP) 0000555555559295 core::core_arch::x86::sse2::_mm_pause /usr/local/rustup/toolchains/1.45.2-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/libcore/../stdarch/crates/core_arch/src/x86/sse2.rs:25 /workspaces/headcrab/tests/testees/hello.rs:7:14 4 #[inline(never)] 5 fn breakpoint() { 6 // This will be patched by the debugger to be a breakpoint > 7 unsafe { core::arch::x86_64::_mm_pause(); } 8 } 9 10 #[inline(never)] (headcrab) ``` So, as you can see, now when we pause at the break-point, we also print the source code around it.
…nction during syntax highlighting of code snippet
Co-authored-by: bjorn3 <bjorn3@users.noreply.github.com>
Now the repl can be run as cargo run --example repl --features syntax-highlighting
|
@nbaksalyar r? |
|
Please run |
|
Hmm, the build seems to be failing: https://travis-ci.com/github/headcrab-rs/headcrab/jobs/383054168#L426-L444 |
|
Thanks @blitzerr! |
|
My first PR merged :D. Thank you @nbaksalyar and @bjorn3 |
Fixes: #100
change summary
(+) Print source lines when pausing on a breakpoint.
(+) New command
listorl(+) Some code refactoring.
(+) Syntax highlighting of code snippet.
currently if you debug your program with lldb, and say your program stops
at the set breakpoint, lldb will print the source line and not just filename
and line number. It might be more clear with an example, so here goes one:
Before this PR, the behavior of headcrab for a similar steps of execution would
have been:
So, you can see, after cont(inuing) to the next breakpoint, headcrab is silent. You have to give
the command
btto print the backtrace.After the change, the output will be something like this:
So, as you can see, now when we pause at the break-point, we also print the source code around it.