From jeroenoom@ @end|ng |rom gm@||@com  Tue Jun  2 01:14:28 2020
From: jeroenoom@ @end|ng |rom gm@||@com (Jeroen Ooms)
Date: Tue, 2 Jun 2020 01:14:28 +0200
Subject: [Rd] Debugging packages with compiled C code on Windows
In-Reply-To: <CAOkNWZU8c5NG32h-A-7uA-rqPZRB5dGs61U3pYreFEPJk0eaOg@mail.gmail.com>
References: <CAOkNWZU8c5NG32h-A-7uA-rqPZRB5dGs61U3pYreFEPJk0eaOg@mail.gmail.com>
Message-ID: <CABFfbXuP78e52heZT1a=Y3n08RQsR9h_rV_9SB5F1Fn6BaQwDA@mail.gmail.com>

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



[Rd] Debugging packages with compiled C code on Windows
Jeroen Ooms