Learn R Programming

TMB (version 1.9.15)

gdbsource: Source R-script through gdb to get backtrace.

Description

Source R-script through gdb to get backtrace.

If gdbsource is run non-interactively (the default) only the relevant information will be printed.

Usage

gdbsource(file, interactive = FALSE)

# S3 method for backtrace print(x, ...)

Value

Object of class backtrace

Arguments

file

Your R script

interactive

Run interactive gdb session?

x

Backtrace from gdbsource

...

Not used

Details

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).