[Rcpp-devel] Need Help: debugging Rcpp with gdb on Windows 8

Kumar Aiyer kumar_neel at yahoo.com
Tue Sep 23 05:16:28 CEST 2014

I am developing a module RcppSSC which is an R wrapper for a C library for Solar Energy from NREL.

I am using RStudio to build and install the package for debugging. 

Build session output shows that debug flags are enabled

 ==> Rcmd.exe INSTALL --preclean --no-multiarch --with-keep.source RcppSSC

* installing to library 'C:/Users/kumar_000/Documents/R/win-library/3.1'
* installing *source* package 'RcppSSC' ...
** libs
g++ -m64 -I"C:/PROGRA~1/R/R-31~1.1/include" -DNDEBUG -I. -I"C:/SAM/ssc-sdk-2014-1-21"   -I"C:/Users/kumar_000/Documents/R/win-library/3.1/Rcpp/include" -I"d:/RCompile/CRANpkg/extralibs64/local/include"     -g -O3 -Wall -pipe -pedantic -Wno-variadic-macros -c RcppSSC.cpp -o RcppSSC.o
g++ -m64 -shared -s -static-libgcc -o RcppSSC.dll tmp.def RcppSSC.o -LC:/SAM/ssc-sdk-2014-1-21/win64/ -lssc -Ld:/RCompile/CRANpkg/extralibs64/local/lib/x64 -Ld:/RCompile/CRANpkg/extralibs64/local/lib -LC:/PROGRA~1/R/R-31~1.1/bin/x64 -lR
installing to C:/Users/kumar_000/Documents/R/win-library/3.1/RcppSSC/libs/x64

Running the code in Rstudio

ssc_module <- Module( "RcppSSC","RcppSSC")
ssc <- ssc_module$RcppSSC
s <- new( ssc, "pvwattsv1" )
RStudio crashes "R Session Aborted. R encountered a fatal error. The session was terminated"


Running the code in gdb

I used the steps outlines in the following web page and face the same issues. Cannot get symbolic debug information in gdb or the correct source file

I used the following steps

1) set DEBUG=T 
2) C:\Rtools\gcc-4.6.3\bin64\gdb.exe rgui

3) type cont in gdb
4) load the script test_script.r in the R session
4) Execute the R code until the line s <- new( ssc, "pvwattsv1" )
in the R 
5) At this stage code runs fine. 
6) I checked the object ssc created in R.
7) Results are as follows 

> ssc
C++ class 'RcppSSC' <00000000076FD250>
        docstring : constructor with module name
8) Next I set a breakpoint in gdb in the function init which is called from the public constructor. I do this by choosing "Misc -> break to debuger" from the menu in RGui
9) I then execute "break init" in gdb
10) I get the following output which makes me to believe that no symbolic information was read in. NEED HELP ON THIS? Why is this happening despite compiling with the -g flag

Program received signal SIGTRAP, Trace/breakpoint trap.
0x000000006c714b01 in R_gl_tab_set ()
   from C:\Program Files\R\R-3.1.1\bin\x64\R.dll
(gdb) break init
Function "init" not defined.
Make breakpoint pending on future shared library load? (y or [n]) y

Breakpoint 1 (init) pending.

11)  Next type cont in gdb and get back to RGui
12) In RGui execute the line 
s <- new( ssc, "pvwattsv1" )

13) In gdb, I get
(gdb) cont

Program received signal SIGSEGV, Segmentation fault.
0x000000006b4c2508 in _rcpp_module_boot_RcppSSC ()
   from C:\Users\kumar_000\Documents\R\win-library\3.1\RcppSSC\libs\x64\RcppSSC.

So, no symbolic tables and no way to see which line of code SEGVs. Need help.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.r-forge.r-project.org/pipermail/rcpp-devel/attachments/20140922/8a5daad9/attachment-0001.html>

More information about the Rcpp-devel mailing list