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

gdbsource {TMB} | R Documentation

## 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. Note that this will only work if the cpp file and the R file share the same base name.

### Usage

    gdbsource(file, interactive = FALSE)

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

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

### Value

Object of class `backtrace`

[Package TMB version 1.7.11 Index]