Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

debugging gcc compiled code with lldb does not work for every dbg_* function #5

Open
aryoda opened this issue Nov 28, 2019 · 2 comments
Labels
incompatibility two or more tools do not work together as expected

Comments

@aryoda
Copy link
Owner

aryoda commented Nov 28, 2019

Running lldb with

R -d lldb

and setting a breakpoint (same commands as in gdb so far) prints strange results:

(lldb) p dbg_print(x)
error: warning: '__cplusplus' macro redefined
previous definition is here
warning: '__GNUC__' macro redefined
previous definition is here
...
warning: '__LDBL_EPSILON__' macro redefined
previous definition is here
warning: '__LDBL_DENORM_MIN__' macro redefined
previous definition is here
error: Couldn't lookup symbols:
  Rcpp::PreserveStorage<Rcpp::Vector<4> >::~PreserveStorage()
  Rcpp::Vector<4>::Vector(Rcpp::Vector<4> const&)

but SEXP printing does work:

(lldb) p dbg_print(x.data)
[1] "foo"   "bar"   NA      "hello"

Investigate this (low prio)...

See also:
Is it possible to debug a gcc-compiled program using lldb, or debug a clang-compiled program using gdb?

@aryoda aryoda added the incompatibility two or more tools do not work together as expected label Nov 28, 2019
@aryoda
Copy link
Owner Author

aryoda commented Nov 28, 2019

Perhaps switching to clang++ solves the problem, see:

http://r-pkgs.had.co.nz/src.html

Use clang instead of gcc to compile your C++ code: it gives much better error messages. You can make clang the default by creating a .R/Makevars (linux and mac) or .R/Makevars.win (windows) file in your home directory that contains:
CXX=clang++

But a first try with a clean & rebuild of CppDebugHelper only (not Rcpp) didn't help (debugging/stepping works, but printing not):

(lldb) p dbg_print(x)
error: CppDebugHelper.so DWARF DIE at 0x00099d2f (class String) has a member variable 0x00099d44 (buffer) whose type is a forward declaration, not a complete definition.
Try compiling the source file with -fstandalone-debug
error: Couldn't lookup symbols:
  Rcpp::Vector<16>::Vector(Rcpp::Vector<16> const&)
  Rcpp::traits::proxy_cache<16>::~proxy_cache()
  Rcpp::PreserveStorage<Rcpp::Vector<16> >::~PreserveStorage()

Some interesting links:

It seems that R and Rcpp must be recompiled completely with clang++ (but clang++ seems to be supported by R only on OSX/Mac) to avoid mixing compilers...

in general you CANNOT mix C++ code from different compilers

@aryoda
Copy link
Owner Author

aryoda commented Nov 29, 2019

This Debugging compiled code in R with lldb video by Jim Hester show the lldb does work within RStudio (on OSX/Mac)

It also gives good "how to debug" instructions via a live debugging session in RStudio

Direct link to the video: https://www.youtube.com/watch?v=R3-IMGyNJY4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
incompatibility two or more tools do not work together as expected
Projects
None yet
Development

No branches or pull requests

1 participant