Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* Don't overshoot when executing cfa instructions
@ 2009-06-27 22:23 Andreas Schwab
  2009-06-27 22:28 ` Daniel Jacobowitz
  2009-06-27 22:33 ` Daniel Jacobowitz
  0 siblings, 2 replies; 5+ messages in thread
From: Andreas Schwab @ 2009-06-27 22:23 UTC (permalink / raw)
  To: gdb-patches

The dwarf2 unwinder is careful to substract one from pc when finding the
associated fde, but when executing the cfa instructions it uses the
original pc as the limit, which may cause it to execute too much, for
example if this is a frame calling a noreturn function.  Tested on
powerpc-linux.

Andreas.

2009-06-28  Andreas Schwab  <schwab@linux-m68k.org>

	* dwarf2-frame.c (execute_cfa_program): Use
	get_frame_address_in_block instead of get_frame_pc.

--- gdb/dwarf2-frame.c.~1.89.~	2009-06-25 00:05:03.000000000 +0200
+++ gdb/dwarf2-frame.c	2009-06-27 21:52:17.000000000 +0200
@@ -376,7 +376,7 @@ execute_cfa_program (struct dwarf2_fde *
 		     struct dwarf2_frame_state *fs)
 {
   int eh_frame_p = fde->eh_frame_p;
-  CORE_ADDR pc = get_frame_pc (this_frame);
+  CORE_ADDR pc = get_frame_address_in_block (this_frame);
   int bytes_read;
   struct gdbarch *gdbarch = get_frame_arch (this_frame);
 

-- 
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Don't overshoot when executing cfa instructions
  2009-06-27 22:23 Don't overshoot when executing cfa instructions Andreas Schwab
@ 2009-06-27 22:28 ` Daniel Jacobowitz
  2009-06-27 22:33 ` Daniel Jacobowitz
  1 sibling, 0 replies; 5+ messages in thread
From: Daniel Jacobowitz @ 2009-06-27 22:28 UTC (permalink / raw)
  To: Andreas Schwab; +Cc: gdb-patches

On Sun, Jun 28, 2009 at 12:23:02AM +0200, Andreas Schwab wrote:
> The dwarf2 unwinder is careful to substract one from pc when finding the
> associated fde, but when executing the cfa instructions it uses the
> original pc as the limit, which may cause it to execute too much, for
> example if this is a frame calling a noreturn function.  Tested on
> powerpc-linux.

OK, thanks!

-- 
Daniel Jacobowitz
CodeSourcery


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Don't overshoot when executing cfa instructions
  2009-06-27 22:23 Don't overshoot when executing cfa instructions Andreas Schwab
  2009-06-27 22:28 ` Daniel Jacobowitz
@ 2009-06-27 22:33 ` Daniel Jacobowitz
  2009-06-29 13:19   ` Andreas Schwab
  1 sibling, 1 reply; 5+ messages in thread
From: Daniel Jacobowitz @ 2009-06-27 22:33 UTC (permalink / raw)
  To: Andreas Schwab; +Cc: gdb-patches

On Sun, Jun 28, 2009 at 12:23:02AM +0200, Andreas Schwab wrote:
> The dwarf2 unwinder is careful to substract one from pc when finding the
> associated fde, but when executing the cfa instructions it uses the
> original pc as the limit, which may cause it to execute too much, for
> example if this is a frame calling a noreturn function.  Tested on
> powerpc-linux.

Actually, before approving this I have a question.  What about state
changes caused by the branch?

I remember a similar problem with location lists.  Before the branch,
a variable lives at some location.  Inside the called function, it is
gone.  Did we ever find a representation for that?  Does it rely
on the instruction after the branch marking the register as clobbered?

Sorry, I can't find a link.

-- 
Daniel Jacobowitz
CodeSourcery


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Don't overshoot when executing cfa instructions
  2009-06-27 22:33 ` Daniel Jacobowitz
@ 2009-06-29 13:19   ` Andreas Schwab
  2009-06-29 14:33     ` Daniel Jacobowitz
  0 siblings, 1 reply; 5+ messages in thread
From: Andreas Schwab @ 2009-06-29 13:19 UTC (permalink / raw)
  To: gdb-patches

Daniel Jacobowitz <drow@false.org> writes:

> Actually, before approving this I have a question.  What about state
> changes caused by the branch?
>
> I remember a similar problem with location lists.  Before the branch,
> a variable lives at some location.  Inside the called function, it is
> gone.  Did we ever find a representation for that?  Does it rely
> on the instruction after the branch marking the register as clobbered?

Do you have a testcase, or a hint how to create one?

Andreas.

-- 
Andreas Schwab, aschwab@redhat.com
GPG Key fingerprint = D4E8 DBE3 3813 BB5D FA84  5EC7 45C6 250E 6F00 984E
"And now for something completely different."


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Don't overshoot when executing cfa instructions
  2009-06-29 13:19   ` Andreas Schwab
@ 2009-06-29 14:33     ` Daniel Jacobowitz
  0 siblings, 0 replies; 5+ messages in thread
From: Daniel Jacobowitz @ 2009-06-29 14:33 UTC (permalink / raw)
  To: Andreas Schwab; +Cc: gdb-patches

On Mon, Jun 29, 2009 at 03:19:09PM +0200, Andreas Schwab wrote:
> Daniel Jacobowitz <drow@false.org> writes:
> 
> > Actually, before approving this I have a question.  What about state
> > changes caused by the branch?
> >
> > I remember a similar problem with location lists.  Before the branch,
> > a variable lives at some location.  Inside the called function, it is
> > gone.  Did we ever find a representation for that?  Does it rely
> > on the instruction after the branch marking the register as clobbered?
> 
> Do you have a testcase, or a hint how to create one?

We currently deal with this by implicit knowledge of the ABI
(dwarf2_init_reg methods).  I couldn't coax either GCC or RealView
into producing an example, but here's what I was thinking of:

foo:
	.cfi_startproc
	mov sp, fp
	.cfi_def_cfa_register fp
	push r0
	push r1
	bl bar				@ clobber r0, r1, r2
	.cfi_offset r0, -4
	.cfi_offset r1, -8
	.cfi_undefined r2
	pop r0, r1
	.cfi_same_value r0
	.cfi_same_value r1
	ret

I think this CFI is unlikely, but correct.  At "bl bar" r1 can be
found in r1.  After that instruction it must be found on the stack.
GCC already combines pushes in this way although it will place the CFI
after the last push.  But if it emitted full undefined markers,
isn't that where the r2 marker would have to go?

-- 
Daniel Jacobowitz
CodeSourcery


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2009-06-29 14:33 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-06-27 22:23 Don't overshoot when executing cfa instructions Andreas Schwab
2009-06-27 22:28 ` Daniel Jacobowitz
2009-06-27 22:33 ` Daniel Jacobowitz
2009-06-29 13:19   ` Andreas Schwab
2009-06-29 14:33     ` Daniel Jacobowitz

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox