In Visual Studio we can use "attach to process" in order to debug the DLLs.
Is there any way to debug C/C++ code of an R package in Eclipse/StatET (i.e. something like this example of debugging external code linked to Scilab)?
The following steps work for Eclipse-CDT C/C++ (LUNA).
$./configure --enable-R-shlib --with-valgrind-instrumentation=2 --with-system-valgrind-headers --CFLAGS='-g -O0 -fPIC' FFLAGS='-g -O0 -fPIC' CXXFLAGS='-g -O0 -fPIC' FCFLAGS='-g -O0 -fPIC' $make $sudo make install
This will install R under
Note: -g and -O are needed to add debug symbols and to make sure that comiple optimization do not prevent debugging.
Setup proper directory structure for an R-package with C source code. Use a makefile rather than relying on Eclipse-StatET for building the project. Makes the setup more easily portable to Windows.
R CMD install at the command line or using the Makefile will install the package to the user's local R library.
Under Eclipse (Luna) create a "New Debug Configuration" under C/C++ Application.
Under 'Main' tab:
a. select a C/C++ Application:
b. Project may point to the R-package project.
c. Check "Connect process input & output to a terminal".
--slave --vanilla --no-save
a. LD_LIBRARY_PATH: /use/local/lib/R/lib
b. R_HOME /usr/local/lib/R Select "Append environment to native environment"
a. Pick GDB debugger
b. If 'GDB command set' is not displayed as an option, click 'Select other...' at the very bottom. Choose 'Legacy Create Process Launcher'. Doing so will now display options for picking GDB command set: Pick Standard with protocol
a. Add absolute path to the R directory with R source (optional) ~/Downloads/R
b. Add absolute path to the package src directory and any other dependent libraries.