Rr: Difference between revisions

From miki
Jump to navigation Jump to search
 
(13 intermediate revisions by the same user not shown)
Line 5: Line 5:
* [https://github.com/mozilla/rr/wiki/Using-rr-in-an-IDE Using rr in an IDE]
* [https://github.com/mozilla/rr/wiki/Using-rr-in-an-IDE Using rr in an IDE]
* [https://github.com/mozilla/rr/wiki/Building-And-Installing Building and Installing] and [https://github.com/mozilla/rr/wiki/Usage rr Usage], from Mozilla wiki.
* [https://github.com/mozilla/rr/wiki/Building-And-Installing Building and Installing] and [https://github.com/mozilla/rr/wiki/Usage rr Usage], from Mozilla wiki.


* [https://pernos.co/ Pernosco] A nice front-end for rr (free for users on Github, see [https://news.ycombinator.com/item?id=25042827 HN thread]).


== Install and configuration ==
== Install and configuration ==
Line 18: Line 21:


# Enable perf for user land (temporary)
# Enable perf for user land (temporary)
sudo sysctl kernel.perf_event_paranoid=0
sudo sysctl kernel.perf_event_paranoid=1

# Enable perf permanently
echo 'kernel.perf_event_paranoid=1' | sudo tee '/etc/sysctl.d/51-rr-enable-perf-events.conf'

# To squeeze max perf on laptop (even plugged on AC!), disable CPU scaling:
sudo apt-get install cpufrequtils
sudo cpufreq-set -g performance # Must be redone at each reboot !!!
# CPU scaling can be disabled permanently in BIOS
</source>
</source>


See rr usage page for more performance tuning and setting perf flag permanently.
See rr usage page for more performance tuning and setting perf flag permanently.

See also troubleshooting below (for VM...).

=== Integration with cgdb ===

rr works nicely with '''[[gdb#CGDB|cgdb]]''':
<source lang="bash">
rr replay -d cgdb
</source>

CGDB output will be messed up if target produces any output [https://github.com/rr-debugger/rr/issues/1888].
Here a few options to circumvent that:
* Mute any output with <code>rr replay -q -d cgdb</code>
* Start rr in one window, and attach cgdb to it.
<source lang="bash">
rr replay -s 1234 # In one terminal
cgdb -ex "target remote :1234" # In second terminal
</source>


== Example of use ==
== Example of use ==
Line 43: Line 72:
</source>
</source>


During replay, rr behaves likes gdb, with the usual reverse debugging command.
During replay, rr behaves likes gdb, with the usual reverse debugging command (<code>rc</code>, <code>rn</code>, <code>rs</code>...).
See referenced links for more information.
See referenced links for more information.

'''NOTE''': rr seems to ignore breakpoints if we do <code>run</code> instead of <code>cont</code>...

== Troubleshoot ==
=== Potential issues in VM ===
* See rr page [https://github.com/rr-debugger/rr/wiki/Building-And-Installing].
* See this bug in VMWare [https://robert.ocallahan.org/2015/11/rr-in-vmware-solved.html]. Fix is to add <code>monitor_control.disable_hvsim_clusters = true</code>.
* See this bug in Xen [https://lists.xen.org/archives/html/xen-devel/2017-07/msg02242.html].
* Discuss on rr in [https://news.ycombinator.com/item?id=25042827 Hacker News].

Latest revision as of 09:28, 15 March 2024

rr is the Record and Replay Framework, developped by Mozilla, and is a replacement for and powerful enhancement of gdb.

References


Install and configuration

On Debian, rr is available as a package:

sudo apt install rr

rr also requires the linux performance analysis package for the current kernel.

# Install linux perf
sudo apt install linux-perf-4.19

# Enable perf for user land (temporary)
sudo sysctl kernel.perf_event_paranoid=1

# Enable perf permanently
echo 'kernel.perf_event_paranoid=1' | sudo tee '/etc/sysctl.d/51-rr-enable-perf-events.conf'

# To squeeze max perf on laptop (even plugged on AC!), disable CPU scaling:
sudo apt-get install cpufrequtils
sudo cpufreq-set -g performance          # Must be redone at each reboot !!!
# CPU scaling can be disabled permanently in BIOS

See rr usage page for more performance tuning and setting perf flag permanently.

See also troubleshooting below (for VM...).

Integration with cgdb

rr works nicely with cgdb:

rr replay -d cgdb

CGDB output will be messed up if target produces any output [1]. Here a few options to circumvent that:

  • Mute any output with rr replay -q -d cgdb
  • Start rr in one window, and attach cgdb to it.
rr replay -s 1234               # In one terminal
cgdb -ex "target remote :1234"  # In second terminal

Example of use

Start recording the application:

rr record my_app

Then replay it with:

rr replay

In case the application fires several processes, we can tell rr to fast-forward until child is forked. First we use rr ps to get the list of recorded processes, then we start rr with -f:

rr ps
rr replay -f 12345

During replay, rr behaves likes gdb, with the usual reverse debugging command (rc, rn, rs...). See referenced links for more information.

NOTE: rr seems to ignore breakpoints if we do run instead of cont...

Troubleshoot

Potential issues in VM

  • See rr page [2].
  • See this bug in VMWare [3]. Fix is to add monitor_control.disable_hvsim_clusters = true.
  • See this bug in Xen [4].
  • Discuss on rr in Hacker News.