Debugging with RR

rr is a lightweight tool for recording, replaying and debugging execution of applications (trees of processes and threads). Debugging extends gdb with very efficient reverse-execution, which in combination with standard gdb/x86 features like hardware data watchpoints, makes debugging much more fun.

Using RR with the SDK

The Flatpak SDK already provides RR. You don't need to install it on your host machine. To record a trace, use this command:

$ WEBKIT_MINI_BROWSER_PREFIX=rr Tools/Scripts/run-minibrowser --gtk ...

You don't necessarily need a debug build, but it's better to have one.

To replay a trace or simply run rr:

$ Tools/Scripts/webkit-flatpak -c rr <rr arguments here>
$ Tools/Scripts/webkit-flatpak -c rr ps                                                                                                                                                            14:32:37
35      --      0       /app/webkit/WebKitBuild/Debug/bin/MiniBrowser
43      35      -5      /app/webkit/WebKitBuild/Debug/bin/WebKitWebProcess 7 24
44      35      0       /app/webkit/WebKitBuild/Debug/bin/WebKitNetworkProcess 8 24

Alternatively, you can run rr from the flatpak shell:

$ Tools/Scripts/webkit-flatpak --gtk --debug
[📦🌐🐱 org.webkit.Sdk WebKit]$ rr record /app/webkit/WebKitBuild/Debug/bin/MiniBrowser ...
[📦🌐🐱 org.webkit.Sdk WebKit]$ rr ps
[📦🌐🐱 org.webkit.Sdk WebKit]$ TEST_RUNNER_TEST_PLUGIN_PATH= rr record /app/webkit/WebKitBuild/Debug/bin/WebKitTestRunner ...
[📦🌐🐱 org.webkit.Sdk WebKit]$ rr replay

If you want to clear old unused traces, they're stored in ~/.local/share/rr/.

Last modified 2 years ago Last modified on May 6, 2022 5:55:47 AM