Source R-script through gdb to get backtrace.
If gdbsource
is run non-interactively (the default) only
the relevant information will be printed. Note that this will only
work if the cpp file and the R file share the same base name.
gdbsource(file, interactive = FALSE)# S3 method for backtrace
print(x, ...)
Your R script
Run interactive gdb session?
Backtrace from gdbsource
Not used
Object of class backtrace
This function is useful for debugging templates.
If a script aborts e.g. due to an out-of-bound index operation
it should be fast to locate the line that caused the problem by
running gdbsource(file)
.
Alternatively, If more detailed debugging is required, then
gdbsource(file,TRUE)
will provide the full backtrace followed
by an interactive gdb session where the individual frames can be inspected.
Note that templates should be compiled without optimization and with debug
information in order to provide correct line numbers:
On Linux/OS X use compile(cppfile,"-O0 -g")
.
On Windows use compile(cppfile,"-O1 -g",DLLFLAGS="")
(lower
optimization level will cause errors).