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

Dirk Eddelbuettel edd at debian.org
Tue Sep 23 21:38:43 CEST 2014


On 23 September 2014 at 12:14, Kumar Aiyer wrote:
| Hi John:
| Thanks for the info. I have not checked if it works in vanilla MingW. Doing
| that today. However here is the summary from the user guide which clearly
| states it has been tested.  The problem may be with the 64bit libraries.
  ^^^^^^^^^^^^^^^^^^^^^^^^^^

In the context of the SSC library, maybe.  

Note that the example below uses C language code (and there is a reason)

But what you are overlooking is that in general you CANNOT mix code from
Visual Studio and MinGW for purposes of Rcpp -- and in general you CANNOT mix
C++ code from different compilers.  So unless you get the source code for SSC
and learn how to build an Rcpp package __from sources__ ie without an
external library you will be out of luck.

This is all stated in the Rcpp-FAQ.

Dirk

| 
| 2.7 Compile and run the C program
| This description explains how to compile and run the C program in Windows using
| the
| MinGW development environment, assuming we saved the code to the file
| example1_pvwatts.c.
| This example was tested with MinGW gcc version 4.6.2.
| To compile and run the program, the following files must be in the same folder:
| • The .c file containing the program code
| • The sscapi.h header file
| • The dynamic library file, for example ssc32.dll
| • The daggett.tm2 weather file
| To compile the program, type the following command at the Windows command
| prompt:
| c:\> gcc example1_pvwatts.c ssc32.dll -o pvwatts.exe
| To run the program, specify a weather file on the command line. Here, we use the
| TMY2
| file for Daggett, California:
| c:\> pvwatts.exe daggett.tm2
| ac: 1668.23 kWh
|  
| best
| 
| Kumar Aiyer 
| 
| 
| On Monday, September 22, 2014 8:16 PM, Kumar Aiyer <kumar_neel at yahoo.com>
| wrote:
| 
| 
| 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
| =============================================
| test_script.r
| ==========
| require(Rcpp)
| require(RcppSSC)
| 
| 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>
| Constructors:
|     RcppSSC(std::string)
|         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.
| (gdb)
| 
| 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
| Continuing.
| 
| 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.
| dll
| (gdb)
| 
| So, no symbolic tables and no way to see which line of code SEGVs. Need help.
| 
| 
| 
| 
| _______________________________________________
| Rcpp-devel mailing list
| Rcpp-devel at lists.r-forge.r-project.org
| https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel

-- 
http://dirk.eddelbuettel.com | @eddelbuettel | edd at debian.org


More information about the Rcpp-devel mailing list