Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: "Ulrich Weigand" <uweigand@de.ibm.com>
To: pedro@codesourcery.com (Pedro Alves)
Cc: gdb-patches@sourceware.org
Subject: [rfc] Fix broken i386 signal unwinding (Re: graceful unwind termination when we'd need unavailable/uncollect memory or registers to unwind further)
Date: Thu, 31 Mar 2011 14:43:00 -0000	[thread overview]
Message-ID: <201103311357.p2VDvp7s026986@d06av02.portsmouth.uk.ibm.com> (raw)
In-Reply-To: <201102221834.42413.pedro@codesourcery.com> from "Pedro Alves" at Feb 22, 2011 06:34:42 PM

Pedro Alves wrote:

> 	(i386_frame_prev_register): Handle unavailable SP.

> -  if (regnum == I386_ESP_REGNUM && cache->saved_sp)
> -    return frame_unwind_got_constant (this_frame, regnum, cache->saved_sp);
> +  if (regnum == I386_ESP_REGNUM)
> +    {
> +      /* If the SP has been saved, but we don't know where, then this
> +	 means that SAVED_SP_REG register was found unavailable back
> +	 when we built the cache.  */
> +      if (cache->saved_sp == 0 && cache->saved_sp_reg != -1)
> +	return frame_unwind_got_register (this_frame, regnum,
> +					  cache->saved_sp_reg);
> +      else
> +	return frame_unwind_got_constant (this_frame, regnum,
> +					  cache->saved_sp);
> +    }
>  
>    if (regnum < I386_NUM_SAVED_REGS && cache->saved_regs[regnum] != -1)
>      return frame_unwind_got_memory (this_frame, regnum,

It seems this change broke unwinding out of signal trampoline
frames on i386 for me.  In this case, neither SAVED_SP nor
SAVED_SP_REG is set; instead, SP is supposed to be unwound
from memory (the trampoline stack frame) via SAVED_REGS.

However, after your change, we now fall into the _got_constant
case and SP is always unwound as 0.

The following patch fixes this for me, and gets about 50 test
cases back to PASS.

Does this look right to you?

Tested on i386-linux (Ubuntu Lucid).

Bye,
Ulrich

ChangeLog:

	* i386-tdep.c (i386_frame_prev_register): Unwind SP from memory
	if neither saved value nor register available (e.g. signal frame).


Index: gdb/i386-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/i386-tdep.c,v
retrieving revision 1.330
diff -u -p -r1.330 i386-tdep.c
--- gdb/i386-tdep.c	18 Mar 2011 18:52:30 -0000	1.330
+++ gdb/i386-tdep.c	31 Mar 2011 13:50:07 -0000
@@ -1798,12 +1798,13 @@ i386_frame_prev_register (struct frame_i
   if (regnum == I386_EIP_REGNUM && cache->pc_in_eax)
     return frame_unwind_got_register (this_frame, regnum, I386_EAX_REGNUM);
 
-  if (regnum == I386_ESP_REGNUM)
+  if (regnum == I386_ESP_REGNUM
+      && (cache->saved_sp != 0 || cache->saved_sp_reg != -1))
     {
       /* If the SP has been saved, but we don't know where, then this
 	 means that SAVED_SP_REG register was found unavailable back
 	 when we built the cache.  */
-      if (cache->saved_sp == 0 && cache->saved_sp_reg != -1)
+      if (cache->saved_sp == 0)
 	return frame_unwind_got_register (this_frame, regnum,
 					  cache->saved_sp_reg);
       else

-- 
  Dr. Ulrich Weigand
  GNU Toolchain for Linux on System z and Cell BE
  Ulrich.Weigand@de.ibm.com


  parent reply	other threads:[~2011-03-31 13:58 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-02-22 18:35 graceful unwind termination when we'd need unavailable/uncollect memory or registers to unwind further Pedro Alves
2011-02-28 15:42 ` Jan Kratochvil
2011-02-28 15:56   ` Pedro Alves
2011-02-28 18:50     ` Jan Kratochvil
2011-03-18 20:21 ` Pedro Alves
2011-03-21 10:09 ` Regression: " Jan Kratochvil
2011-03-21 20:46   ` Pedro Alves
2011-03-22 14:40   ` Pedro Alves
2011-03-22 15:36     ` Jan Kratochvil
2011-03-22 16:19       ` Pedro Alves
2011-03-21 17:46 ` [commit] Fix tramp-frame.c crash (Re: graceful unwind termination when we'd need unavailable/uncollect memory or registers to unwind further) Ulrich Weigand
2011-03-21 20:52   ` Pedro Alves
2011-03-31 14:43 ` Ulrich Weigand [this message]
2011-03-31 16:20   ` [rfc] Fix broken i386 signal unwinding " Pedro Alves
2011-03-31 16:23     ` [rfc] Fix broken i386 signal unwinding (Re: graceful unwind termination when we'd need unavailable/uncollect memory or regis Ulrich Weigand

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=201103311357.p2VDvp7s026986@d06av02.portsmouth.uk.ibm.com \
    --to=uweigand@de.ibm.com \
    --cc=gdb-patches@sourceware.org \
    --cc=pedro@codesourcery.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox