This is the mail archive of the mailing list for the Archer project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [RFC] Set unwindonsignal to on by default

On Wed, 17 Sep 2008 23:28:31 +0200, Phil Muldoon wrote:
> Jan Kratochvil wrote:
>> On Wed, 17 Sep 2008 22:52:29 +0200, Phil Muldoon wrote:
>>> Do you think a breakpoint  on std::terminate and the new flag to unwind only
>>> on termination signals  a better solution?
>> IMO it is.  I hope it is clear a better way would be besides the dummy stack
>> frame to create also a dummy exception handler record.
> I disagree here. Creating a dummy exception handler is altering the  
> inferior behaviour. If the programmer decided to write her program to  
> handle exceptions "out-of-frame" and we - for the convenience of an  
> inferior function call - create dummy exception handler records  
> in-frame, it's close to interfering with that behaviour.

So you would like that if the GDB-called function throws an exception which
gets caught by a code we interrupted before it should get caught there?
In such case the following sample should IMO puts ("exception"); when I do
(gdb) p func1()
but that does not happen (IMO it should not happen, IMO we should never unwind
to frames upper than the current frame while calling an inferior function from
GDB - the question is if we:
(1) should catch the exception while throw is unwinding the frames to find the
    exception handler (as I was suggesting)
(2) or should be caught when the std::terminate gets called because no such
    handler was found (you were suggesting)
(3) or should be caught when the fatal signal gets raised by std::terminate
    (as currently happens)


(gdb) b 14
Breakpoint 1 at 0x4007e0: file cxxcleanup.C, line 14.
(gdb) r
Starting program: /tmp/cxxcleanup 

Breakpoint 1, main () at cxxcleanup.C:14
14	      puts ("break-me");
(gdb) set unwindonsignal on
(gdb) p func1()
terminate called after throwing an instance of 'int'

Program received signal SIGABRT, Aborted.
0x00000032aac330a5 in *__GI_raise (sig=<value optimized out>) at ../nptl/sysdeps/unix/sysv/linux/raise.c:64
64	  return INLINE_SYSCALL (tgkill, 3, pid, selftid, sig);
The program being debugged was signaled while in a function called from GDB.
GDB has restored the context to what it was before the call.
To change this behavior use "set unwindonsignal off"
Evaluation of the expression containing the function (func1()) will be abandoned.
(gdb) bt
#0  main () at cxxcleanup.C:14

No line "exception" was printed which happens when func1 is called natively:

$ ./cxxcleanup 
$ _
#include <stdio.h>

func1 ()
  throw 42;

main ()
      puts ("break-me");
      func1 ();
      puts ("passed");
  catch (...) 
      puts ("exception");
  puts ("exit");
  return 0;

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]