title: Can I have gdb jump past a throw statement at the end of a function?
body: <p>When I'm debugging, I sometimes find it useful to "replay" the last few statements of code.  For example:</p>
  
  <pre><code>void foo (int &amp; i) {
    i = 0;
    ++i;
    i++;
  }
  </code></pre>
  
  <p>While running this through the debugger, you can add a breakpoint at the top of the function body, and then from any statement inside of <code>foo</code> if you type:  "jump file.cc:2" the debugger will return back to <code>i = 0</code>.  I appreciate that this isn't always perfect, but sometimes it can be enough to find the bug you're searching for.</p>
  
  <p>I'm currently investigating a problem that results in an exception being thrown.  The exception is being thrown at the bottom of a called function, so something like:</p>
  
  <pre><code>void bar ()
  {
    throw int ();
  }
  
  void foo (int &amp; i)
  {
    i = 0;
    ++i;
  
    bar ();
  
    i++;
  }
  
  int main ()
  {
    try
    {
      int i;
      foo (i);
    }
    catch (...)
    {
    }
  }
  </code></pre>
  
  <p>What I want to be able to do, is to put a breakpoint before <code>throw int ()</code>, then to jump over just that statement, finish the function bar - so that I can then jump back up to the <code>i = 0</code> line in foo.</p>
  
  <p>Is there a way I can jump past <code>throw int ()</code>, or finish out of <code>bar</code> without executing the throw statement?</p>
  
  <p>The problem appears to be that there's no statement after the <code>throw</code> so I have nowhere to put the breakpoint I want to jump to.</p>
  
  <p><strong>UPDATE:</strong></p>
  
  <p>To highlight what happens in my simple example above:</p>
  
  <pre><code>This GDB was configured as "i486-slackware-linux"...
  (gdb) break bar
  Breakpoint 1 at 0x804856a: file t.cc, line 3.
  (gdb) run
  Starting program: ..../t 
  
  Breakpoint 1, bar () at t.cc:3
  (gdb) break t.cc:4
  Breakpoint 2 at 0x8048592: file t.cc, line 4.
  (gdb) jump t.cc:4
  Line 4 is not in `bar()'.  Jump anyway? (y or n) y
  Continuing at 0x8048592.
  
  Breakpoint 2, foo (i=@0xb80155eb) at t.cc:6
  </code></pre>
  
  <p>The close curly for 'bar' is on line 4 of 't.cc', however gdb considers this as a breakpoint for <code>foo</code>.</p>