Hacker News Re-Imagined

What rr does

  • 880 points
  • 1 month ago

  • @mmarq
  • Created a post

What rr does


@stewbrew 1 month

Replying to @mmarq 🎙

We already have https://r-project.org. Now we have https://rr-project.org. So, https://rrr-project.org is next?

Reply


@InfiniteRand 1 month

Replying to @mmarq 🎙

Does rr require debug builds? Like if I took a random executable on Linux and used rr record, would rr replay work?

Reply


@blacksqr 1 month

Replying to @mmarq 🎙

Makes every day seem like Talk Like a Pirate Day.

Reply


@sfink 1 month

Replying to @mmarq 🎙

If you use https://pernos.co/ then you don't need any of this, but I have a set of only slightly buggy gdbinit scripts that extend the rr debugging experience at <https://github.com/hotsphink/sfink-tools>. The main things it adds are:

1. a `log` command that just records whatever you give it into a plaintext file, together with its "point in time" according to rr. This is useful because when using rr, you tend to move forward and backward in time a lot, and it's hard to keep track of the actual sequence of events and where you are within them. It also creates a checkpoint so you can return to any one of your log points. It also has some niceties like replacing any expression enclosed in curly brackets with the results of executing the gdb expression given, so you can do things like

    log starting execution of Init() with v={v}. About to crash.
2. a `label` command that lets you assign names to random hex values. Then in the output of `p expr` or the above `log` with no arguments, which displays the full set of log messages you've recorded, it will replace known hex values with their labels. This is so much nicer than memorizing numeric values and matching them up.

    (rr) p obj
    $1 = (JSObject*) 0x7f606892a200
    (rr) label OUTER_OBJ=obj
    (rr) p $OUTER_OBJ
    (JSObject*) $OUTER_OBJ
    (rr) log
    701/31299795 [c4] starting processing with obj=(JSObject*) $OUTER_OBJ
    983/31299 [c2] starting processing with obj=(JSObject*) 0x7f6068a2a200
    2081/7382911 [c3] traversing to (JSObject*) 0x7f6069c2a7e8
    3316/199 [c1] crashing while accessing field of object (JSObject*) $OUTER_OBJ
The [c2] markers are the automatically-created checkpoints, numbered in order that you made those log entries in the debugger. It reorders the log messages to show them in execution order rather than debugging order. Pernosco has a very similar feature called the Notebook (where you only have to click on a log entry to view the state at that point in time.)

The scripts are also intended for sharing log files and labels between multiple concurrent replays of the same execution, which I find useful to have separate windows each maintaining a different context (point in time, and portion of the execution that I'm examining.) That tends to be the buggier part of the scripts, though. ;-)

If you're working with C or C++ (or Rust? haven't tried it), rr really is a superpower. I rarely bother using straight gdb anymore. It feels crippled.

Reply


@raydiatian 1 month

Replying to @mmarq 🎙

Man. I wish I had this for Typescript.

Well done!

Reply


@stefantalpalaru 1 month

Replying to @mmarq 🎙

https://github.com/rr-debugger/rr#system-requirements :

"rr currently requires either:

    - An Intel CPU with Nehalem (2010) or later microarchitecture.
    - Certain AMD Zen or later processors (see https://github.com/rr-debugger/rr/wiki/Zen)"

Reply


@ris58h 1 month

Replying to @mmarq 🎙

Could you next time provide some small but meaningful description in the title? "Rr" is a little bit short in my opinion.

Reply


@qumpis 1 month

Replying to @mmarq 🎙

Is there a counterpart of this in Python?

Reply


@bornfreddy 1 month

Replying to @mmarq 🎙

Now this is how the project documentation should look like! Explains what the project does, gives some short examples of the most common features, then goes into the details - while being easy to understand for the target audience. Kudos to whoever wrote this! (and rr sounds like a nice tool too ;) )

Reply


@jchw 1 month

Replying to @mmarq 🎙

Historically, rr has not worked on AMD processors, which is a bummer. However, I have been able to make good use of it on my 5950X now with the workaround script and newer versions of rr. This is good news.

I've not read their extended technical report, but I am kind of curious exactly what performance counters AMD is implementing poorly and how that impacts rr.

Reply


@adgjlsfhk1 1 month

Replying to @mmarq 🎙

Breakpoint plus reverse watch is incredibly powerful. It makes it trivial to find the code that last modified a variable before a breakpoint.

Reply


@sph 1 month

Replying to @mmarq 🎙

This is incredible!

For those that have used it, how useful it is for debugging multithreading heisenbugs? Can I let a process run under rr for days, wait until it crashes to due a heisenbug, and replay the trace without rr having to go through days of recording? i.e. is it possible to fast forward the trace, somehow?

(I nerd sniped myself a bit here, wondering how fast forwarding could be implemented. I think it might be achievable with periodic process memory snapshots and incremental traces.)

Reply


@omginternets 1 month

Replying to @mmarq 🎙

How does this work, exactly? Is it recording every state change in the program?

Reply


@sirwhinesalot 1 month

Replying to @mmarq 🎙

This sounds like a debugger I might actually enjoy using (unlike all the others).

Reply


@pizza 1 month

Replying to @mmarq 🎙

what I would give to have something like this that additionally worked on Mac and Windows too

Reply


@borodi 1 month

Replying to @mmarq 🎙

rr is a life changing experience for debugging things. One underrated thing is being able to save and share rr traces. rr + CI makes finding and potentially fixing heisenbugs a lot easier.

Reply


@DoctorOW 1 month

Replying to @mmarq 🎙



@logbiscuitswave 1 month

Replying to @mmarq 🎙

This kind of replayable debugging can be wonderful - especially for hard to debug issues like heap corruption and such.

Windows has something similar called Time Travel Debugging[1] but in my experience the dump files it creates can be enormous and be a pain to analyze as a result. (It also relies on WinDbg which while being extremely powerful and capable, has a huge learning and usability cliff. I’ve been using it for over a decade and I still need a cheat sheet from time to time. The revamped WinDbg Preview[2] improves the UI a lot, but ultimately it’s still WinDbg.)

[1] https://docs.microsoft.com/en-us/windows-hardware/drivers/de...

[2] https://docs.microsoft.com/en-us/windows-hardware/drivers/de...

Reply


@jng 1 month

Replying to @mmarq 🎙

Eager for the day someone integrates this into VS Code.

Reply


@jonnycomputer 1 month

Replying to @mmarq 🎙

Looks like a cool debugging tool, but I clicked the link because I thought maybe it was related to R. Maybe modify the title to make it clearer?

Reply


About Us

site design / logo © 2022 Box Piper