title: R: How make dump.frames() include all variables for later post-mortem debugging with debugger()
body: <p>I have the following code which provokes an error and writes a dump of all frames using <code>dump.frames()</code> as <a href="http://adv-r.had.co.nz/Exceptions-Debugging.html" rel="nofollow noreferrer">proposed e. g. by Hadley Wickham</a>:</p>
  
  <pre><code>a &lt;- -1
  b &lt;- "Hello world!"
  bad.function &lt;- function(value)
  {
    log(value)                  # the log function may cause an error or warning depending on the value
  }
  
  tryCatch( {
               a.local.value &lt;- 42
               bad.function(a)
               bad.function(b)
            },
            error = function(e)
            {
              dump.frames(to.file = TRUE)
            })
  </code></pre>
  
  <p>When I restart the R session and load the dump to debug the problem via</p>
  
  <pre><code>load(file = "last.dump.rda")
  debugger(last.dump)
  </code></pre>
  
  <p>I cannot find my variables (a, b, a.local.value) nor my function "bad.function" anywhere in the frames.</p>
  
  <p>This makes the dump nearly worthless to me.</p>
  
  <p>What do I have to do to see all my variables and functions for a decent <strong>post-mortem analysis</strong>?</p>
  
  <p>The output of <code>debugger</code> is:</p>
  
  <pre><code>&gt; load(file = "last.dump.rda")
  &gt; debugger(last.dump)
  Message:  non-numeric argument to mathematical functionAvailable environments had calls:
  1: tryCatch({
      a.local.value &lt;- 42
      bad.function(a)
      bad.function(b)
  2: tryCatchList(expr, classes, parentenv, handlers)
  3: tryCatchOne(expr, names, parentenv, handlers[[1]])
  4: value[[3]](cond)
  
  Enter an environment number, or 0 to exit  
  Selection: 
  </code></pre>
  
  <p>PS: I am using R3.3.2 with RStudio for debugging.</p>