Dotnet logo

.NET Tools

Essential productivity kit for .NET and game developers

.NET Tools How-To's

Hot-Reloading C++ with Live++ and JetBrains Rider

We’ve been working with Stefan Reinalter and the team at Molecular Matters to make the industry-leading Live++ binary patching tool work seamlessly with C++ projects in JetBrains Rider!

This is a great productivity boost for both Unreal Engine developers and those working on custom C++ engines. Live++ support works with all C and C++ projects in Rider and reduces iteration time by reloading changes to your code while the application is running, even when paused at a breakpoint.

While Live++ works with any editor, we’ve been working on Rider integration to improve your experience of working with Live++ and Rider. This doesn’t introduce any new UI features, but it does make the workflow a lot smoother. For example, Live++ will navigate to compile errors in Rider, automatically reattach the debugger when your application hot-restarts, and will hot-deoptimize the current file when using the Live++ hotkey.

Read on for more details!

What is Live++?

For those not familiar with Live++, it’s a great technology for reducing iteration time while building, running, and debugging your C and C++ applications. Conceptually, it’s very similar to Edit and Continue, or to the Hot Reload and Live Coding features of Unreal Engine, although it is more advanced and feature-rich. There are three main features we’ll look at today – Hot-Reload, Hot-Restart, and Hot-Deoptimize.

Getting started requires downloading the Live++ SDK, adding some APIs and libraries to your application, and checking some compiler flags. You can find out more in the Quickstart guide, as well as download the trial and some examples. There’s also a great overview of the product’s architecture.

Hot-Reload

The whole point of debugging is to find problems in your code so that you can fix them. But once you’ve made your changes and fixed the issue, you need to stop debugging, recompile, and start the process all over again, losing your current state and progress. Wouldn’t it be great if you could just keep going with the new changes applied?

That’s exactly the problem that Hot-Reload solves. Edit your code and use the global Ctrl+Alt+F11 shortcut, and Live++ will compile your changes and apply them to the running application. If you’re paused at a breakpoint, Rider will update, showing any new values you might have changed.

Changing a const value in code and invoking the global shortcut, and Rider updates debugger state
Changing a const value in code and invoking the global shortcut, and Rider updates debugger state

If you made a mistake in your updated code that causes a compilation error, the error will be reported in the Live++ Broker app’s main window. Double-clicking the error will navigate to the file in Rider.

Double-clicking an error in the Live++ Broker will open the file at the correct line in Rider
Double-clicking an error in the Live++ Broker will open the file at the correct line in Rider

Hot-Restart

The Hot-Restart feature is a great way to restart your application after making changes. Typically this would involve relinking the application, which can take extra time. The Live++ Broker application also has to load the application and process the PDB debug files to build internal caches. With Hot-Restart, these steps are skipped – the application doesn’t need to be linked because Live++ already has the changes ready to go. Similarly, it doesn’t need to reload the PDB files or rebuild caches because they’re already in memory. This can greatly decrease the iteration times when you want or need to restart your application.

If Rider was debugging your application when Live++ restarts it, Rider will automatically attach to the new process. It’s a small but very welcome quality of life improvement. Rider works alongside Live++ to keep you in the debugging flow without unnecessary roadblocks.

Hot-Deoptimize

Rider has a great debugger for stepping through code and examining values. Recent changes have also improved the situation for optimized code by showing as much data as possible from objects that have been partially optimized away. But sometimes that’s not enough, and you need to disable all optimizations and debug code like it was compiled in debug mode.

The Hot-Deoptimize feature can help here. In the Live++ Broker app, you can right-click on a .obj file to toggle optimizations. To save you from having to switch to the Compilands view, find the matching .obj and select a menu item, use the global Live++ Ctrl+Alt+O shortcut while the file is open in Rider, and Live++ will toggle optimizations for the matching .obj file. Rider will then immediately be able to debug the file as though it was initially compiled in debug mode.

Local variables are not available in a file compiled with optimisations. The global shortcut will toggle optimisations and Rider will automatically refresh the debugger
Local variables are not available in a file compiled with optimisations. The global shortcut will toggle optimisations and Rider will automatically refresh the debugger

When you’re done, press Ctrl+Alt+O again to restore optimizations to the current file.

Lots of people are using Live++ to improve their debugging experience with better iteration times. It’s been a pleasure working with Stefan to bring Rider support to Live++ and make our users’ workflows even smoother.

Stefan told us:

“Rider is a great IDE to work with.It easily supports huge AAA codebases, code navigation is smooth even on excessively large source files, Find in Files is instant, and it supports version control systems such as Perforce and Git out of the box, which is a huge boon. With its built-in support for Visual Studio solutions and projects, there’s no reason not to switch.JetBrains and their tools are well-known and respected in the industry.

It’s been a pleasure and honor working with their team to bring dedicated Rider support to Live++.

While Live++ itself is IDE-agnostic, having dedicated support for JetBrains Rider lets you be in the flow without any kind of interruption or manual intervention, making room for a much more seamless workflow. Not having to manually resume the debugger or switch to the Live++ UI to deoptimize a file or reattach the debugger after a hot-restart are all great quality-of-life improvements.”

These updates are available in the Early Access Preview builds of Rider 2024.3 and require the latest version of Live++. We hope you’ll try it for yourself on your own projects. Please let us know how it works for you!

A valid license for Live++ is still required – a free 30-day trial can be activated directly in the Live++ Broker app.

image description