From jmc at r-project.org  Thu Dec  6 18:38:16 2007
From: jmc at r-project.org (John Chambers)
Date: Thu, 06 Dec 2007 09:38:16 -0800
Subject: [Rd] trace() problems (PR#10498)
In-Reply-To: <20071206133507.BA0ED283416A@mail.pubhealth.ku.dk>
References: <20071206133507.BA0ED283416A@mail.pubhealth.ku.dk>
Message-ID: <47583388.5010207@r-project.org>

The problem is at least as old as 2.5.1.  Looks like a line disappeared 
from trace(), something like:
    on.exit(tracingState(tState))

As a result, if an error occurs in the call to trace(), the tracing 
state is left FALSE.  The workaround is to turn it on explicitly:

    tracingState(TRUE)

after which normal behavior should resume.

murdoch at stats.uwo.ca wrote:
> trace() seems to be broken in 2.6.1 and R-devel:
>
> Try the example from the ?debug man page:
>
>  > library(methods)
>  > trace("plot", browser, exit=browser, signature = c("track",
> +       "missing"))
> Error in getFunction(what, where = whereF) : no function "plot" found
>
> Okay, it's just an example that doesn't work.  Let's try a simpler one, 
> the first example from the ?trace man page:
>
>  > trace(sum)
>  > hist(stats::rnorm(100)) # shows about 3-4 calls to sum()
>  > untrace(sum)
>
> No trace!  In a clean session without the first error, things are fine:
>
>  > trace(sum)
>  > hist(stats::rnorm(100)) # shows about 3-4 calls to sum()
> trace: sum(2^(opts - 2))
> trace: sum(2^(opts - 2))
> trace: sum(2^(opts - 2))
> trace: sum(counts)
> trace: sum(2^(opts - 2))
>  > untrace(sum)
>
> Duncan Murdoch
>
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>
>



[Rd] trace() problems (PR#10498)
John Chambers