Skip to content

Instantly share code, notes, and snippets.

@larsbergstrom
Created June 26, 2015 05:29
Show Gist options
  • Save larsbergstrom/615fec7313452d0dd480 to your computer and use it in GitHub Desktop.
Save larsbergstrom/615fec7313452d0dd480 to your computer and use it in GitHub Desktop.
Debugging Servo exercise
The goal of this exercise is to see how to debug a `panic` in Servo (the equivalent of an uncaught exception in C++).
First, run Servo and see the crash in Google Maps by doing:
./mach run -d https://maps.google.com
To run the debugger, we need to call it directly (use lldb below on OSX but gdb in its place on Linux):
lldb target/debug/servo https://maps.google.com
Set a breakpoint on the `rust_panic` function, which is what is called when a panic occurs in Rust:
b rust_panic
Then, run the program:
run
You will stop at a breakpoint. See a backtrace (`bt`) and move up to the first frame that is in user code (`up 4`).
Of course, at this point, it's too late to see what happened! So, let's do some logging:
RUST_LOG=layout ./mach run -d https://maps.google.com
That generates more info, but it's WAY too much because the parallel layout threads are all interleaved. So, instead, run with a single thread:
RUST_LOG=layout ./mach run -d -y 1 https://maps.google.com
There will be additional panic output in this one (since you will see the script task fail as well), but above the first panic in layout, which should be the same as before, you will see additional output. This output points a finger at table layout code, which means we are at the end of this final exercise!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment