Calling vcDebug
will initiate a debug enabled Microsoft Visual Code instance
that can be use as a GUI debugger of your C/C++ code.
# S4 method for BSysProject
vcDebug(.Object, LaunchEditor=TRUE)
BSysProject
object instance defining the library to be debugged. See BuildSys-package
for more information.
LaunchEditor
is a reserved argument that should not be used by the user. A call to it with LaunchEditor=FALSE
is used
in the .Rprofile file for the debug R session to do the necessary tasks to initialise the R session state.
this method returns no value.
vcDebug
creates the necessary c_cpp_properties.json
and launch.json
files needed for Microsoft Visual Code
to effectively debug the project dynamic library and launches an instance of Visual Code. It is assumed that the dynamic
library has already been compiled with make
and Debug
support enabled. R needs to be configured to be able to build
C/C++ libraries (RTools installed on Windows) and it is assumed that Microsoft Visual Code is installed. These requirements
are discussed at length in BuildSys-package
.
Within Visual Code you can open the source file/s of your library, set breakpoints and run a debug session. To run a debug
session select the run/Start Debugging menu item. Doing so will result in a new instance of R being launched which contains
the same environment (including loaded packages and loaded dynamic libraries) as the parent R session where vcDebug
was first
called. This R session is your sandbox to safely debug your library in and leaves the parent R session safe from loss should
your code crash R completely.
Debugging a new library will typically require some R setup code to be executed before using and/or testing it. With BuildSys
you
should perform this initial setup of R in the parent R session before calling vcDebug
so that you never have to initialise
R in your debug session. The debug R session will inherit the state of the parent R session at the time that vcDebug
was called.