Rev 36975 | Rev 38608 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed
\name{traceback}\alias{traceback}\alias{.Traceback}\title{Print Call Stacks}\description{By default, \code{traceback()} prints the call stack of the lastuncaught error, i.e., the sequence of calls that lead to the error.This is useful when an error occurs with an unidentifiable errormessage. It can also be used to print arbitrary lists of deparsedcalls.}\usage{traceback(x = NULL)}\arguments{\item{x}{\code{NULL} (default), or a list or pairlist of deparsedcalls.}}\details{The stack of the last uncaught error is stored as a list of deparsedcalls in \code{.Traceback}, which \code{traceback} prints in auser-friendly format. The stack of deparsed calls always contains allfunction calls and (as from \R 2.3.0) all foreign function calls (suchas \code{\link{.Call}}): if profiling is in progress it will includeall other calls to primitive functions.Errors which are caught \emph{via} \code{\link{try}} or\code{\link{tryCatch}} do not generate a traceback, so what is printedis the call sequence for the last uncaught error, and not necessarilythe last error.}\value{\code{traceback()} returns nothing, but prints the deparsed call stackdeepest call first. The calls may print on more than one line, andthe first line for each call is labelled by the frame number. Thenumber of lines printed per call can be limited by setting\code{\link{options}(deparse.max.lines)}.}\references{Becker, R. A., Chambers, J. M. and Wilks, A. R. (1988)\emph{The New S Language}.Wadsworth \& Brooks/Cole.}\examples{foo <- function(x) { print(1); bar(2) }bar <- function(x) { x + a.variable.which.does.not.exist }\dontrun{foo(2) # gives a strange errortraceback()}## 2: bar(2)## 1: foo(2)bar## Ah, this is the culprit ...}\keyword{programming}