From vapniks at yahoo.com  Mon Feb  4 02:51:35 2008
From: vapniks at yahoo.com (Joe Bloggs)
Date: Mon, 04 Feb 2008 01:51:35 +0000
Subject: [Rd] gdb
References: <871w7ualss.fsf@DEBLAP1.BeNet>
	<18341.58878.423585.780727@ron.nulle.part>
Message-ID: <878x21cwuw.fsf@DEBLAP1.BeNet>

Dirk Eddelbuettel <edd at debian.org> writes:

> On 3 February 2008 at 01:08, Joe Bloggs wrote:
> | I am using gdb to debug a c++ library I made for R using Rcpp.
> | However, when I step through the code it seems to go all over the place, and some of the variables have been optimized out so I can't see their values.
> | How can I compile without optimization?
>
> Set MAKEFLAGS accordingly, possibly by editing R's Makeconf.  This is
> documented in the 'R Extensions' manual.
>

Thanks, for the benefit of others..

I changed the CXXFLAGS line in /etc/R/Makeconf from:

CXXFLAGS = -g -O2

to:

CXXFLAGS = -ggdb -O2

which seems to work. Changing -O2 to just -O would remove compiler optimizations, but it turns out this wasn't necessary.
Alternatively I could compile my package with

MAKEFLAGS="CXXFLAGS=-ggdb -O2" R CMD INSTALL ...

to temporarily change the flags.


> | Also, is there any neat way to run R with gdb through emacs?
>
> Yes, using 'M-x gdb' to launcg the gdb frontend. I also use ddd on Linux.
>
> Using the debugger is also described in the 'R Extensions' manual.
>

In the manual it says to run R through gdb by: R -d gdb
how can I do this in emacs?
Alternatively how do I run R through gdb after alreay starting gdb?

> Hope this helps, Dirk
>
> -- 
> Three out of two people have difficulties with fractions.
>
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel



[Rd] gdb
Joe Bloggs