debugging 编译Rcpp包,并在调试符号中包含行信息

iibxawm4  于 2022-11-14  发布在  其他
关注(0)|答案(2)|浏览(177)

我不知道如何给予我的R包的共享库的调试符号的源代码行信息。我错过了什么?
1.我创建以下src/Makevars文件:

PKG_CXXFLAGS=-O0 -ggdb
PKG_LIBS=-O0 -ggdb

1.我使用R CMD INSTALL --no-multiarch --with-keep.source编译包:

* installing to library ‘~/.local/lib/R/3.6’
* installing *source* package ‘reticulate’ ...
** using staged installation
g++ -std=gnu++11 -I"/usr/include/R/" -DNDEBUG  -I"$HOME/.local/lib/R/3.6/Rcpp/include" -D_FORTIFY_SOURCE=2 -O0 -ggdb -fpic  -march=x86-64 -mtune=generic -O2 -pipe -fno-plt  -c RcppExports.cpp -o RcppExports.o
** libs
g++ -std=gnu++11 -shared -L/usr/lib64/R/lib -Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now -o reticulate.so RcppExports.o event_loop.o libpython.o output.o python.o readline.o -O0 -ggdb -L/usr/lib64/R/lib -lR

正在安装到~/.local/lib/R/3.6/00 LOCK-reticulate/00新的/reticulate/libs
1.我这样调试:

R -d gdb --slave -e 'reticulate::py_eval("print")()'
GNU gdb (GDB) 8.3
[...]
(No debugging symbols found in /usr/lib64/R/bin/exec/R)
(gdb) break py_get_formals
Function "py_get_formals" not defined.
Make breakpoint pending on future shared library load? (y or [n]) y
Breakpoint 1 (py_get_formals) pending.
(gdb) run
Starting program: /usr/lib/R/bin/exec/R --slave -e reticulate::py_eval\(\"print\"\)\(\)
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/usr/lib/libthread_db.so.1".
[...]
Thread 1 "R" hit Breakpoint 1, 0x00007fffeb6b79a0 in py_get_formals(PyObjectRef, bool) () from /home/angerer/.local/lib/R/3.6/reticulate/libs/reticulate.so
(gdb) step
Single stepping until exit from function _Z14py_get_formals11PyObjectRefb,
which has no line number information.
[...]

为什么我的函数没有行号,尽管我在两个编译中都指定了-ggdb?我看到命令行中只提到了RcppExports.cpp,是不是这个问题?如果是这样,我该如何改变它?

uelo1irk

uelo1irk1#

变更Makevars不会提示重新编译。
在目标文件被重新编译之前,我需要rm -f src/*.o src/*.so

wa7juj8i

wa7juj8i2#

这是专为Windows设计的。最简单的方法是将R_MAKEVARS_USER环境设置为指向Makevars.win文件。这似乎可以工作。但是,调试断点已经停止工作!!!!

相关问题