Sue McDonald
2020-Jun-01 21:36 UTC
[Rd] Debugging packages with compiled C code on Windows
I have several related questions. 1. Is it possible to use a GUI: Rstudio/Eclipse/Visual-studio to debug compiled code on Windows? Things that work on Eclipse for Windows do not work on Eclipse for Windows. 2. R CMD INSTALL seems to override default attempts to provide CFLAGS="-DDEBUG -g3 -O0" 3. Is it necessary to compile R with debug turned on? One of the FAQs mentioned to compile R with make DEBUG=T. 4. Using Rtools 4.0 and Jeroen's scripts for building R works great (many thanks). But does not seem to have an impact on optimization, other than including -gwarf-2. It adds -DNDEBUG flag. Is that sufficient for debugging compiled code in a package? Obviously, I just need to debug package code, so does it matter? I am happy to write-up a FAQ. Thanks, SM [[alternative HTML version deleted]]
Avraham Adler
2020-Jun-01 22:37 UTC
[Rd] Debugging packages with compiled C code on Windows
Hello, Sue. 1. I work exclusively on Windows have packages with compiled C, C++, and Fortran (2003+) and I use RStudio to debug and work with them using Rtools40, so I guess it's possible. Have I misunderstood and are you asking about debugging assembler? 2. If you're using Jeroen's scripts, have you tried uncommenting and adding that to EOPTS in MkRules.local.in? Note that ./src/gnuwin32/fixed/Makefile has a nasty habit of overriding various optimizations that affect packages. 3. I don't think so 4. The default is that EOPTS is commented out. I talk about it a nit more at length here [1]. Perhaps that would be of use? [1] <https://www.avrahamadler.com/2020/05/12/building-r-4-for-windows-with-openblas/> Good Luck, Avi On Mon, Jun 1, 2020 at 9:36 PM Sue McDonald <sudomeme at gmail.com> wrote:> > I have several related questions. > > 1. Is it possible to use a GUI: Rstudio/Eclipse/Visual-studio to debug > compiled code on Windows? Things that work on Eclipse for Windows do not > work on Eclipse for Windows. > 2. R CMD INSTALL seems to override default attempts to provide > CFLAGS="-DDEBUG -g3 -O0" > 3. Is it necessary to compile R with debug turned on? One of the FAQs > mentioned to compile R with make DEBUG=T. > 4. Using Rtools 4.0 and Jeroen's scripts for building R works great (many > thanks). But does not seem to have an impact on optimization, other than > including -gwarf-2. It adds -DNDEBUG flag. Is that sufficient for > debugging compiled code in a package? Obviously, I just need to debug > package code, so does it matter? > > I am happy to write-up a FAQ. > > Thanks, SM > > [[alternative HTML version deleted]] > > ______________________________________________ > R-devel at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-devel
On Mon, Jun 1, 2020 at 11:36 PM Sue McDonald <sudomeme at gmail.com> wrote:> > I have several related questions. > > 1. Is it possible to use a GUI: Rstudio/Eclipse/Visual-studio to debug > compiled code on Windows? Things that work on Eclipse for Windows do not > work on Eclipse for Windows. > 2. R CMD INSTALL seems to override default attempts to provide > CFLAGS="-DDEBUG -g3 -O0" > 3. Is it necessary to compile R with debug turned on? One of the FAQs > mentioned to compile R with make DEBUG=T. > 4. Using Rtools 4.0 and Jeroen's scripts for building R works great (many > thanks). But does not seem to have an impact on optimization, other than > including -gwarf-2. It adds -DNDEBUG flag. Is that sufficient for > debugging compiled code in a package? Obviously, I just need to debug > package code, so does it matter?If you use the official R-for-Windows installation, you should install your R package with R CMD INSTALL --debug in order to keep debug symbols. That is usually sufficient to get a backtrace with e.g drmingw. See FAQ 8.4 of https://cran.r-project.org/bin/windows/base/rw-FAQ.html Coincidentally I am also working on a special debugging build of R, which uses -g -O0 for all compiled code. It is not final yet, but it should work. You can test it here: https://github.com/r-windows/rtools-packages/pull/119