This is the mail archive of the archer@sourceware.org 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


Jan Kratochvil wrote:
Hi Phil,

just my opinion of a C user:

On Wed, 17 Sep 2008 19:55:40 +0200, Phil Muldoon wrote:
I propose via this patch that we set the flag to "on" as default. It can always be turned off if the user desires it. Defaulting to "on" will improve the C++ user experience

and worsen the C user experience. I find it common the called function
segfaults and I would like to know why.

Fair point. But in your case if a segfault did happen as in your example below, you could just call the function again with unwindonsignal off.


So:

set unwindsignal on
p func()

<sigsegv> need to debug that.

Because the first call was unwound and state returned to before the inferior function call was made, you can call it again in the same debug session without restarting the inferior with the flag off:

set unwindsignal off
p func()

<sigsegv> can now debug that

In the C++ case once your inferior terminates there is no going back and switching flags. It's dead, and you have to start all over again. It's a little more trouble for a C user, but a much better usability gain for a C++ user. You can also just explicitly set unwindonsignal in .gdbinit if you absolutely have no interest in C++.

I do take your point well, however. It is not optimal to trade one user's pain for another if at all possible. Do you think a breakpoint on std::terminate and the new flag to unwind only on termination signals a better solution?

Regards

Phil


Regards, Jan

------------------------------------------------------------------------------

(gdb) set unwindonsignal on
(gdb) start
Temporary breakpoint 1 at 0x40048f: file /tmp/callfunc.c, line 12.
Starting program: /tmp/callfunc


Temporary breakpoint 1, main () at /tmp/callfunc.c:12
12	  return 0;
(gdb) p func()

Program received signal SIGSEGV, Segmentation fault.
0x0000000000000000 in ?? ()
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 (func) will be abandoned.
(gdb) bt
#0 main () at /tmp/callfunc.c:12
(gdb)


------------------------------------------------------------------------------

but before:

(gdb) start
Temporary breakpoint 1 at 0x40048f: file /tmp/callfunc.c, line 12.
Starting program: /tmp/callfunc


Temporary breakpoint 1, main () at /tmp/callfunc.c:12
12	  return 0;
(gdb) p func()

Program received signal SIGSEGV, Segmentation fault.
0x0000000000000000 in ?? ()
The program being debugged was signaled while in a function called from GDB.
GDB remains in the frame where the signal was received.
To change this behavior use "set unwindonsignal on"
Evaluation of the expression containing the function (func) will be abandoned.
(gdb) bt
#0 0x0000000000000000 in ?? ()
#1 0x0000000000400489 in func () at /tmp/callfunc.c:6
#2 <function called from gdb>
#3 main () at /tmp/callfunc.c:12
(gdb) up
#1 0x0000000000400489 in func () at /tmp/callfunc.c:6
6 return (*hook) ();
(gdb)


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