* RFA: try to ensure abort has valid return address
@ 2002-01-11 22:45 Jim Blandy
2002-01-20 16:24 ` Andrew Cagney
2002-01-21 8:29 ` Fernando Nasser
0 siblings, 2 replies; 4+ messages in thread
From: Jim Blandy @ 2002-01-11 22:45 UTC (permalink / raw)
To: gdb-patches
2002-01-12 Jim Blandy <jimb@redhat.com>
* gdb.base/coremaker.c (func2): Try to arrange for the return
address passed to `abort' to fall within `func2', so we can get
backtraces.
Index: gdb/testsuite/gdb.base/coremaker.c
===================================================================
RCS file: /cvs/cvsfiles/devo/gdb/testsuite/gdb.base/coremaker.c,v
retrieving revision 1.4
diff -c -r1.4 coremaker.c
*** gdb/testsuite/gdb.base/coremaker.c 1999/06/25 23:44:28 1.4
--- gdb/testsuite/gdb.base/coremaker.c 2002/01/12 06:42:09
***************
*** 81,87 ****
}
void
! func2 ()
{
int coremaker_local[5];
int i;
--- 81,87 ----
}
void
! func2 (int please_abort)
{
int coremaker_local[5];
int i;
***************
*** 104,116 ****
for (i = 0; i < 5; i++)
coremaker_bss += coremaker_local[i];
coremaker_data = coremaker_ro + 1;
! abort ();
}
void
func1 ()
{
! func2 ();
}
int main ()
--- 104,138 ----
for (i = 0; i < 5; i++)
coremaker_bss += coremaker_local[i];
coremaker_data = coremaker_ro + 1;
!
! /* This function used to simply call `abort' unconditionally.
! However, because GCC sometimes knows that `abort' will never
! return, the `call' instruction that invokes `abort' would
! sometimes be the very last instruction in this function. The
! epilogue instructions you'd normally expect --- deallocating the
! frame, jumping to the return address --- were omitted, since
! they'd never be reached anyway. This means that the return
! address passed to abort (which it'll never use) actually points
! beyond the end of the caller! Sometimes the return address
! seemed to be in the next function; sometimes it seemed to be in
! padding instructions between functions, for which there was no
! line number info. In any case, GDB had difficulties producing a
! backtrace in this case.
!
! There's no way to force the compiler not to put the call to
! `abort' at the very end of the function --- after all, it is
! functionally correct to do so. But we hope that putting it in a
! conditional will make it more likely that GDB can get a
! backtrace, and find coremaker_local, which is what we really care
! about. */
! if (please_abort)
! abort ();
}
void
func1 ()
{
! func2 (1);
}
int main ()
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: RFA: try to ensure abort has valid return address
2002-01-11 22:45 RFA: try to ensure abort has valid return address Jim Blandy
@ 2002-01-20 16:24 ` Andrew Cagney
2002-01-21 8:29 ` Fernando Nasser
1 sibling, 0 replies; 4+ messages in thread
From: Andrew Cagney @ 2002-01-20 16:24 UTC (permalink / raw)
To: Jim Blandy, Fernando Nasser; +Cc: gdb-patches
> 2002-01-12 Jim Blandy <jimb@redhat.com>
>
> * gdb.base/coremaker.c (func2): Try to arrange for the return
> address passed to `abort' to fall within `func2', so we can get
> backtraces.
>
> Index: gdb/testsuite/gdb.base/coremaker.c
> ===================================================================
> RCS file: /cvs/cvsfiles/devo/gdb/testsuite/gdb.base/coremaker.c,v
> retrieving revision 1.4
> diff -c -r1.4 coremaker.c
> *** gdb/testsuite/gdb.base/coremaker.c 1999/06/25 23:44:28 1.4
> --- gdb/testsuite/gdb.base/coremaker.c 2002/01/12 06:42:09
> ***************
> *** 81,87 ****
> }
>
> void
> ! func2 ()
> {
> int coremaker_local[5];
> int i;
> --- 81,87 ----
> }
>
> void
> ! func2 (int please_abort)
> {
> int coremaker_local[5];
> int i;
> ***************
> *** 104,116 ****
> for (i = 0; i < 5; i++)
> coremaker_bss += coremaker_local[i];
> coremaker_data = coremaker_ro + 1;
> ! abort ();
> }
>
> void
> func1 ()
> {
> ! func2 ();
> }
>
> int main ()
> --- 104,138 ----
> for (i = 0; i < 5; i++)
> coremaker_bss += coremaker_local[i];
> coremaker_data = coremaker_ro + 1;
> !
> ! /* This function used to simply call `abort' unconditionally.
> ! However, because GCC sometimes knows that `abort' will never
> ! return, the `call' instruction that invokes `abort' would
> ! sometimes be the very last instruction in this function. The
> ! epilogue instructions you'd normally expect --- deallocating the
> ! frame, jumping to the return address --- were omitted, since
> ! they'd never be reached anyway. This means that the return
> ! address passed to abort (which it'll never use) actually points
> ! beyond the end of the caller! Sometimes the return address
> ! seemed to be in the next function; sometimes it seemed to be in
> ! padding instructions between functions, for which there was no
> ! line number info. In any case, GDB had difficulties producing a
> ! backtrace in this case.
> !
> ! There's no way to force the compiler not to put the call to
> ! `abort' at the very end of the function --- after all, it is
> ! functionally correct to do so. But we hope that putting it in a
> ! conditional will make it more likely that GDB can get a
> ! backtrace, and find coremaker_local, which is what we really care
> ! about. */
> ! if (please_abort)
> ! abort ();
> }
>
> void
> func1 ()
> {
> ! func2 (1);
> }
>
> int main ()
>
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: RFA: try to ensure abort has valid return address
2002-01-11 22:45 RFA: try to ensure abort has valid return address Jim Blandy
2002-01-20 16:24 ` Andrew Cagney
@ 2002-01-21 8:29 ` Fernando Nasser
2002-01-21 14:13 ` Jim Blandy
1 sibling, 1 reply; 4+ messages in thread
From: Fernando Nasser @ 2002-01-21 8:29 UTC (permalink / raw)
To: Jim Blandy; +Cc: gdb-patches
I wonder if we will always be able to trick the compiler with
this, but it is worthy of a try.
Approved.
Thanks Jim.
Fernando
Jim Blandy wrote:
>
> 2002-01-12 Jim Blandy <jimb@redhat.com>
>
> * gdb.base/coremaker.c (func2): Try to arrange for the return
> address passed to `abort' to fall within `func2', so we can get
> backtraces.
>
> Index: gdb/testsuite/gdb.base/coremaker.c
> ===================================================================
> RCS file: /cvs/cvsfiles/devo/gdb/testsuite/gdb.base/coremaker.c,v
> retrieving revision 1.4
> diff -c -r1.4 coremaker.c
> *** gdb/testsuite/gdb.base/coremaker.c 1999/06/25 23:44:28 1.4
> --- gdb/testsuite/gdb.base/coremaker.c 2002/01/12 06:42:09
> ***************
> *** 81,87 ****
> }
>
> void
> ! func2 ()
> {
> int coremaker_local[5];
> int i;
> --- 81,87 ----
> }
>
> void
> ! func2 (int please_abort)
> {
> int coremaker_local[5];
> int i;
> ***************
> *** 104,116 ****
> for (i = 0; i < 5; i++)
> coremaker_bss += coremaker_local[i];
> coremaker_data = coremaker_ro + 1;
> ! abort ();
> }
>
> void
> func1 ()
> {
> ! func2 ();
> }
>
> int main ()
> --- 104,138 ----
> for (i = 0; i < 5; i++)
> coremaker_bss += coremaker_local[i];
> coremaker_data = coremaker_ro + 1;
> !
> ! /* This function used to simply call `abort' unconditionally.
> ! However, because GCC sometimes knows that `abort' will never
> ! return, the `call' instruction that invokes `abort' would
> ! sometimes be the very last instruction in this function. The
> ! epilogue instructions you'd normally expect --- deallocating the
> ! frame, jumping to the return address --- were omitted, since
> ! they'd never be reached anyway. This means that the return
> ! address passed to abort (which it'll never use) actually points
> ! beyond the end of the caller! Sometimes the return address
> ! seemed to be in the next function; sometimes it seemed to be in
> ! padding instructions between functions, for which there was no
> ! line number info. In any case, GDB had difficulties producing a
> ! backtrace in this case.
> !
> ! There's no way to force the compiler not to put the call to
> ! `abort' at the very end of the function --- after all, it is
> ! functionally correct to do so. But we hope that putting it in a
> ! conditional will make it more likely that GDB can get a
> ! backtrace, and find coremaker_local, which is what we really care
> ! about. */
> ! if (please_abort)
> ! abort ();
> }
>
> void
> func1 ()
> {
> ! func2 (1);
> }
>
> int main ()
--
Fernando Nasser
Red Hat Canada Ltd. E-Mail: fnasser@redhat.com
2323 Yonge Street, Suite #300
Toronto, Ontario M4P 2C9
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: RFA: try to ensure abort has valid return address
2002-01-21 8:29 ` Fernando Nasser
@ 2002-01-21 14:13 ` Jim Blandy
0 siblings, 0 replies; 4+ messages in thread
From: Jim Blandy @ 2002-01-21 14:13 UTC (permalink / raw)
To: Fernando Nasser; +Cc: gdb-patches
Fernando Nasser <fnasser@redhat.com> writes:
> I wonder if we will always be able to trick the compiler with
> this, but it is worthy of a try.
As the comment says, it won't always work.
> Approved.
Committed, thanks.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2002-01-21 22:13 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-01-11 22:45 RFA: try to ensure abort has valid return address Jim Blandy
2002-01-20 16:24 ` Andrew Cagney
2002-01-21 8:29 ` Fernando Nasser
2002-01-21 14:13 ` Jim Blandy
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox