Skip to content

Commit

Permalink
Add debug instructions to README (#4158)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexpeters1208 committed Jul 10, 2023
1 parent 951a784 commit 3299027
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions R/rdeephaven/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,27 @@ The Deephaven R client utilizes R's `testthat` package to perform unit tests. In
library(testthat)
test_package("rdeephaven")
```

## Debugging

Because the Deephaven R client is written in C++ and wrapped with `Rcpp`, standard R-level debugging is not sufficient for many kinds of problems associated with C++ code. For this reason, debugging the R client must be done with a C++ debugger. We recommend using [Valgrind](https://valgrind.org) to check for memory bugs, and using [gdb](https://www.sourceware.org/gdb/) for thorough backtraces and general debugging.

### Running R with Valgrind

The following was taken from [this blog post](https://kevinushey.github.io/blog/2015/04/05/debugging-with-valgrind/), which has proven very useful for getting started with Valgrind.
1. Install Valgrind with `sudo apt-get install valgrind` or `sudo yum install valgrind`
2. Run R under Valgrind with `R -d valgrind`

OS-dependent problems may come up in either step, and the simplest solution is to use a Linux machine or VM if one is available. Attempting these steps in a Linux Docker image may also prove difficult, and will certainly fail if the host architecture is not AMD/X86.

### Running R with gdb

[This article](https://www.maths.ed.ac.uk/~swood34/RCdebug/RCdebug.html) is a good resource for running R with gdb, and also touches on Valgrind use. There are several ways to run R with gdb, and here we only outline the text-based approach given near the bottom of the page.
1. Install gdb with `sudo apt-get install gdb` or `sudo yum install gdb`
2. Start gdb with R attached with `R -d gdb`. This will start a gdb session denoted by `(gdb)` in the console.
3. In the gdb session, start an R console with `(gdb) run`

Both Valgrind and gdb debugging is done through a console, and is not interactive from an IDE. There may be a way to make RStudio play well with Valgrind or gdb, but that is beyond the scope of these instructions.

## High-level design overview

Expand Down

0 comments on commit 3299027

Please sign in to comment.