How to run R script with gdb attached?
I have an R script that's usually started from the command line with arguments:
./script.R --width=10
It uses Rscript as interpreter:
#!/usr/bin/env Rscript
Unfortunately it gives me a segmentation fault when it executes my compiled C code in R using .C("compiled_function")
.
So how can I run my R
script with the gdb
debugger attached?
Rscript
apparently does not know the -d
option.
I tried this
R -d gdb --vanilla --args --width=10 < sc开发者_运维百科ript.R
But it didn't work since it passed the --width=10
to the debugger. What is the right call?
Maybe I should start R
interactively:
$ R -d gdb --vanilla
But then I don't know how to source
my script and pass the arguments (--width=10
).
I think a general GNU getopt convention is to use --
to denote remaining arguments. So try
R -d gdb --vanilla -- --width=10 < script.R
Else hardwire the argument value in your script or compiled function.
精彩评论