thisisnic commented on a change in pull request #11658:
URL: https://github.com/apache/arrow/pull/11658#discussion_r747498927
##########
File path: r/vignettes/developers/debugger.Rmd
##########
@@ -0,0 +1,68 @@
+# Running R code with the C++ debugger
+
+As Arrow has C++ code at its core, debugging code can sometimes be tricky when
+errors originate in the C++ rather than the R layer. If you are adding new
code
+which triggers a C++ bug (or find one in existing code), this can result in a
+segfault. If you are working in RStudio, the session is aborted, and you may
+not be able to retrieve the error messaging needed to diagnose and/or report
+the bug. One way around this is to find the code that causes the error, and
+run R with a C++ debugger.
+
+Firstly, load R with your debugger. The most common debuggers are `gdb` and
`lldb`
+
+In my case it's `gdb`, but if you're using the `lldb` debugger, just swap in
+that command here.
+
+```shell
+R -d gdb
+```
+
+Next, run R.
+
+```shell
+run
+```
+
+You should now be in an R session with the C++ debugger attached. This will
+look similar to a normal R session, but with extra output. For example, here
+is the output I get from running an R session in the debugger
+and then loading arrow:
+
+```
+R version 4.1.1 (2021-08-10) -- "Kick Things"
+Copyright (C) 2021 The R Foundation for Statistical Computing
+Platform: x86_64-pc-linux-gnu (64-bit)
+
+R is free software and comes with ABSOLUTELY NO WARRANTY.
+You are welcome to redistribute it under certain conditions.
+Type 'license()' or 'licence()' for distribution details.
+
+ Natural language support but running in an English locale
+
+R is a collaborative project with many contributors.
+Type 'contributors()' for more information and
+'citation()' on how to cite R or R packages in publications.
+
+Type 'demo()' for some demos, 'help()' for on-line help, or
+'help.start()' for an HTML browser interface to help.
+Type 'q()' to quit R.
+
+[Detaching after vfork from child process 48943]
+[Detaching after vfork from child process 48945]
+> library(arrow)
+[New Thread 0x7ffff326d700 (LWP 48953)]
+[New Thread 0x7fffeb7ff700 (LWP 48958)]
+
+Attaching package: ‘arrow’
+
+The following object is masked from ‘package:utils’:
+
+ timestamp
+```
+
+Now, run your code - either directly in the session or by sourcing it from a
+file. If the code results in a segfault, you will have extra output that you
+can use to diagnose the problem or attach to an issue as extra information.
Review comment:
Have added a few bits including equivalent gdb and lldb commands now.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]