Re: [R-SIG-Mac] Debug Rcpp with lldb: variables not available

2020-06-12 Thread Constantin Ahlmann-Eltze via R-SIG-Mac
Hi inf0phile,

you can just run the command generated by devtools (including the step that
generates the package.so file) manually on the command line in the src
folder. Just remember to replace -g O2 with -g O0, then you get the
unoptimized shared object that shouldn't make any problems in debugger.

Best Regards,
Constantin

Am Fr., 12. Juni 2020 um 14:57 Uhr schrieb inf0phile via R-SIG-Mac <
r-sig-mac@r-project.org>:

> * I made a minimal example in order to be reproduced:
>
> library(Rcpp)
> library(RcppArmadillo)
> RcppArmadillo.package.skeleton()
>
> which create the package anRpackage.
> Setting the working directory in this package, I load it by:
>
> library(devtools)
> devtools::load_all()
>
> * Then the basic function rcpparma_hello_world() can be executed:
>
> rcpparma_hello_world()
>
>  [,1] [,2] [,3]
> [1,]700
> [2,]070
> [3,]007
>
> * I want now to debug the code with lldb via the Terminal command R -d
> lldb in order to check the variable values during the execution via the
> command frame variable.
>
> R -d lldb
> (lldb) breakpoint set --name rcpparma_hello_world()
> (lldb) run
> > library(devtools)
> > devtools::load_all()
> > rcpparma_hello_world()
>
> anRpackage.so was compiled with optimization - stepping may behave oddly;
> variables may not be available.
>
> Indeed, the problem is that most of variables are not available:
>
> > next
> > frame variable
>
> (arma::mat) m1 = 
> (arma::mat) m2 = 
>
> * I read in the previous link the following recommandations:
>
> you may consider producing so-called ‘debug’ builds, with optimization
> toned down, when attempting to debug these kinds of issues as well. For
> building R packages, this effectively amounts to something like CXXFLAGS=-g
> -O0 in your ~/.R/Makevars file)
>
> * I have tried it but it seems to have no effect under the compilation
> flags used since I have a local file Makevars in my package to specify the
> way of compiling with RcppArdimillo, whose flags are:
>
> CXX_STD = CXX11
> PKG_CXXFLAGS = $(SHLIB_OPENMP_CXXFLAGS)
> PKG_LIBS = $(SHLIB_OPENMP_CXXFLAGS) $(LAPACK_LIBS) $(BLAS_LIBS) $(FLIBS)
>
> * Then, the command devtools::load_all() produces the line-command
> compilation given below, in which there is indeed -g -O2 making some code
> optimization:
>
> clang++ -mmacosx-version-min=10.13 -std=gnu++11
> -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG
> -I'/Library/Frameworks/R.framework/Versions/4.0/Resources/library/Rcpp/include'
> -I'/Library/Frameworks/R.framework/Versions/4.0/Resources/library/RcppArmadillo/include'
> -I/usr/local/include-fPIC  -Wall -g -O2  -c rcpparma_hello_world.cpp -o
> rcpparma_hello_world.o
>
> Question: how can I have access to the variables in debugging mode?
>
> Thanks
>
> ‐‐‐ Original Message ‐‐‐
> Le jeudi 11 juin 2020 18:48, inf0phile via R-SIG-Mac <
> r-sig-mac@r-project.org> a écrit :
>
> > Hello,
> >
> > I'm making a package with Rcpp (and RcppArmadillo) under the latest
> version of Rstudio (1.3.959) and R (4.0.0).
> >
> > -   The compilation of the cpp files (with clang) is working well
> >
> > clang++ -mmacosx-version-min=10.13 -std=gnu++11
> -I"/Library/Frameworks/
> > R.framework/Resources/include
> > " -DNDEBUG -I'/Library/Frameworks/
> > R.framework/Versions/4.0/Resources/library/Rcpp/include
> > ' -I'/Library/Frameworks/
> > R.framework/Versions/4.0/Resources/library/RcppArmadillo/include
> > ' -I/usr/local/include -fPIC -Wall -g -O2 -c compensator_Rcpp.cpp -o
> compensator_Rcpp.o
> >
> > This command is automatically generated by pushing the Rstudio
> package dev button "Install and restart"
> >
> > -   I want now to debug the code with lldb (
> https://kevinushey.github.io/blog/2015/04/13/debugging-with-lldb/) via
> the Terminal command R -d lldb in order to check the variable values during
> the execution via the command frame variable. The problem is most of them
> are not available:
> >
> > (SEXP) lambda = 
> >
> >
> > (Rcpp::NumericVector) beta =  out>
> > (int) index = 
> >
> > -   I read in the previous link the following recommandations:
> >
> > > you may consider producing so-called ‘debug’ builds, with optimization
> toned down, when attempting to debug these kinds of issues as well. For
> building R packages, this effectively amounts to something like CXXFLAGS=-g
> -O0 in your ~/.R/Makevars file)
> >
> > -   I have tried it but it seems to have no effect under the compilation
> flags used since I have a local file Makevars in my package to specify the
> way of compiling with RcppArdimillo (
> http://dirk.eddelbuettel.com/blog/2017/06/04/), whose flags are:
> >
> > CXX_STD = CXX11
> > PKG_CXXFLAGS = $(SHLIB_OPENMP_CXXFLAGS)
> > PKG_LIBS = $(SHLIB_OPENMP_CXXFLAGS) $(LAPACK_LIBS) $(BLAS_LIBS)
> $(FLIBS)
> >
> > producing the line-command compilation given above, in which there
> is indeed -g -O2 making some code optimization.
> >
> > Question: how 

Re: [R-SIG-Mac] Debug Rcpp with lldb: variables not available

2020-06-12 Thread inf0phile via R-SIG-Mac
* I made a minimal example in order to be reproduced:

library(Rcpp)
library(RcppArmadillo)
RcppArmadillo.package.skeleton()

which create the package anRpackage.
Setting the working directory in this package, I load it by:

library(devtools)
devtools::load_all()

* Then the basic function rcpparma_hello_world() can be executed:

rcpparma_hello_world()

 [,1] [,2] [,3]
[1,]700
[2,]070
[3,]007

* I want now to debug the code with lldb via the Terminal command R -d lldb in 
order to check the variable values during the execution via the command frame 
variable.

R -d lldb
(lldb) breakpoint set --name rcpparma_hello_world()
(lldb) run
> library(devtools)
> devtools::load_all()
> rcpparma_hello_world()

anRpackage.so was compiled with optimization - stepping may behave oddly; 
variables may not be available.

Indeed, the problem is that most of variables are not available:

> next
> frame variable

(arma::mat) m1 = 
(arma::mat) m2 = 

* I read in the previous link the following recommandations:

you may consider producing so-called ‘debug’ builds, with optimization 
toned down, when attempting to debug these kinds of issues as well. For 
building R packages, this effectively amounts to something like CXXFLAGS=-g -O0 
in your ~/.R/Makevars file)

* I have tried it but it seems to have no effect under the compilation flags 
used since I have a local file Makevars in my package to specify the way of 
compiling with RcppArdimillo, whose flags are:

CXX_STD = CXX11
PKG_CXXFLAGS = $(SHLIB_OPENMP_CXXFLAGS)
PKG_LIBS = $(SHLIB_OPENMP_CXXFLAGS) $(LAPACK_LIBS) $(BLAS_LIBS) $(FLIBS)

* Then, the command devtools::load_all() produces the line-command compilation 
given below, in which there is indeed -g -O2 making some code optimization:

clang++ -mmacosx-version-min=10.13 -std=gnu++11 
-I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG  
-I'/Library/Frameworks/R.framework/Versions/4.0/Resources/library/Rcpp/include' 
-I'/Library/Frameworks/R.framework/Versions/4.0/Resources/library/RcppArmadillo/include'
 -I/usr/local/include-fPIC  -Wall -g -O2  -c rcpparma_hello_world.cpp -o 
rcpparma_hello_world.o

Question: how can I have access to the variables in debugging mode?

Thanks

‐‐‐ Original Message ‐‐‐
Le jeudi 11 juin 2020 18:48, inf0phile via R-SIG-Mac  
a écrit :

> Hello,
>
> I'm making a package with Rcpp (and RcppArmadillo) under the latest version 
> of Rstudio (1.3.959) and R (4.0.0).
>
> -   The compilation of the cpp files (with clang) is working well
>
> clang++ -mmacosx-version-min=10.13 -std=gnu++11 -I"/Library/Frameworks/
> R.framework/Resources/include
> " -DNDEBUG -I'/Library/Frameworks/
> R.framework/Versions/4.0/Resources/library/Rcpp/include
> ' -I'/Library/Frameworks/
> R.framework/Versions/4.0/Resources/library/RcppArmadillo/include
> ' -I/usr/local/include -fPIC -Wall -g -O2 -c compensator_Rcpp.cpp -o 
> compensator_Rcpp.o
>
> This command is automatically generated by pushing the Rstudio package 
> dev button "Install and restart"
>
> -   I want now to debug the code with lldb 
> (https://kevinushey.github.io/blog/2015/04/13/debugging-with-lldb/) via the 
> Terminal command R -d lldb in order to check the variable values during the 
> execution via the command frame variable. The problem is most of them are not 
> available:
>
> (SEXP) lambda = 
>
>
> (Rcpp::NumericVector) beta = 
> (int) index = 
>
> -   I read in the previous link the following recommandations:
>
> > you may consider producing so-called ‘debug’ builds, with optimization 
> > toned down, when attempting to debug these kinds of issues as well. For 
> > building R packages, this effectively amounts to something like CXXFLAGS=-g 
> > -O0 in your ~/.R/Makevars file)
>
> -   I have tried it but it seems to have no effect under the compilation 
> flags used since I have a local file Makevars in my package to specify the 
> way of compiling with RcppArdimillo 
> (http://dirk.eddelbuettel.com/blog/2017/06/04/), whose flags are:
>
> CXX_STD = CXX11
> PKG_CXXFLAGS = $(SHLIB_OPENMP_CXXFLAGS)
> PKG_LIBS = $(SHLIB_OPENMP_CXXFLAGS) $(LAPACK_LIBS) $(BLAS_LIBS) $(FLIBS)
>
> producing the line-command compilation given above, in which there is 
> indeed -g -O2 making some code optimization.
>
> Question: how can I have access to the variables in debugging mode?
>
> Thanks
> [[alternative HTML version deleted]]
>
>
> R-SIG-Mac mailing list
> R-SIG-Mac@r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-mac

___
R-SIG-Mac mailing list
R-SIG-Mac@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-mac


[R-SIG-Mac] Debug Rcpp with lldb: variables not available

2020-06-11 Thread inf0phile via R-SIG-Mac
Hello,

I'm making a package with Rcpp (and RcppArmadillo) under the latest version of 
Rstudio (1.3.959) and R (4.0.0).

- The compilation of the cpp files (with clang) is working well

clang++ -mmacosx-version-min=10.13 -std=gnu++11 -I"/Library/Frameworks/
R.framework/Resources/include
" -DNDEBUG  -I'/Library/Frameworks/
R.framework/Versions/4.0/Resources/library/Rcpp/include
' -I'/Library/Frameworks/
R.framework/Versions/4.0/Resources/library/RcppArmadillo/include
' -I/usr/local/include -fPIC  -Wall -g -O2  -c compensator_Rcpp.cpp -o 
compensator_Rcpp.o

This command is automatically generated by pushing the Rstudio package dev 
button "Install and restart"

- I want now to [debug the code with 
lldb](https://kevinushey.github.io/blog/2015/04/13/debugging-with-lldb/) 
(https://kevinushey.github.io/blog/2015/04/13/debugging-with-lldb/) via the 
Terminal command R -d lldb in order to check the variable values during the 
execution via the command frame variable. The problem is most of them are not 
available:

(SEXP) lambda = 
(Rcpp::NumericVector) beta = 
(int) index = 

- I read in the previous link the following recommandations:

> you may consider producing so-called ‘debug’ builds, with optimization toned 
> down, when attempting to debug these kinds of issues as well. For building R 
> packages, this effectively amounts to something like CXXFLAGS=-g -O0 in your 
> ~/.R/Makevars file)

- I have tried it but it seems to have no effect under the compilation flags 
used since I have a local file Makevars in my package to specify the way of 
[compiling with RcppArdimillo](http://dirk.eddelbuettel.com/blog/2017/06/04/) 
(http://dirk.eddelbuettel.com/blog/2017/06/04/), whose flags are:

CXX_STD = CXX11
PKG_CXXFLAGS = $(SHLIB_OPENMP_CXXFLAGS)
PKG_LIBS = $(SHLIB_OPENMP_CXXFLAGS) $(LAPACK_LIBS) $(BLAS_LIBS) $(FLIBS)

producing the line-command compilation given above, in which there is indeed -g 
-O2 making some code optimization.

Question: how can I have access to the variables in debugging mode?

Thanks
[[alternative HTML version deleted]]

___
R-SIG-Mac mailing list
R-SIG-Mac@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-mac