Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Daniel Jacobowitz <drow@false.org>
To: Orjan Friberg <orjan.friberg@axis.com>
Cc: gdb-patches@sources.redhat.com
Subject: Re: [CRIS] dwarf2 frame sniffer problem?
Date: Thu, 11 Mar 2004 17:11:00 -0000	[thread overview]
Message-ID: <20040311171139.GA17530@nevyn.them.org> (raw)
In-Reply-To: <40508BD8.10802@axis.com>

On Thu, Mar 11, 2004 at 04:55:04PM +0100, Orjan Friberg wrote:
> I don't know if this is related to the previous suggested problem (i.e. 
> the dwarf2 information being wrong), but I changed the test program 
> slightly to:
> 
> void bar(void) {}
> void foo(void)
> {
>   bar();
> }
> int main ()
> {
>   foo();
>   return 0;
> }
> 
> Now foo is no longer a leaf function, and thus saves the return address 
> on the stack in its prologue.  Stepping over foo ("next" in main) causes 
> a breakpoint to be set at the first instruction in foo.  After the 
> target is stopped at that instruction (which is where the return address 
> is pushed on the stack) dwarf2_frame_prev_register is called, which 
> thinks that the PC is saved on the stack (case 
> DWARF2_FRAME_REG_SAVED_OFFSET) and reads it from there.  Obviously the 
> value it reads is wrong, since the return address hasn't been pushed yet.
> 
> What's wrong here?  Is the dwarf2 debug information wrong, or should 
> dwarf2_frame_prev_register not have been called while still in the prologue?

The beauty of using the CFI data is that it _is_ supposed to work in
the prologue.  It sounds like the CFI is wrong.  Could you post both
assembly and CFI data for the same testcase?  I don't know CRIS
assembly but I imagine I can interpret it well enough to see what's
going on.

It also sounds like your DWARF2_REG_TO_REGNUM may need work, if the
unwinder thinks r16 is the return address column and GDB thinks it's an
8-bit register.

-- 
Daniel Jacobowitz
MontaVista Software                         Debian GNU/Linux Developer


WARNING: multiple messages have this Message-ID
From: Daniel Jacobowitz <drow@false.org>
To: Orjan Friberg <orjan.friberg@axis.com>
Cc: gdb-patches@sources.redhat.com
Subject: Re: [CRIS] dwarf2 frame sniffer problem?
Date: Fri, 19 Mar 2004 00:09:00 -0000	[thread overview]
Message-ID: <20040311171139.GA17530@nevyn.them.org> (raw)
Message-ID: <20040319000900.tweCP1hjlvsk9O2xJpY1MgE2WGVQm6YG2ajjXh0U2jE@z> (raw)
In-Reply-To: <40508BD8.10802@axis.com>

On Thu, Mar 11, 2004 at 04:55:04PM +0100, Orjan Friberg wrote:
> I don't know if this is related to the previous suggested problem (i.e. 
> the dwarf2 information being wrong), but I changed the test program 
> slightly to:
> 
> void bar(void) {}
> void foo(void)
> {
>   bar();
> }
> int main ()
> {
>   foo();
>   return 0;
> }
> 
> Now foo is no longer a leaf function, and thus saves the return address 
> on the stack in its prologue.  Stepping over foo ("next" in main) causes 
> a breakpoint to be set at the first instruction in foo.  After the 
> target is stopped at that instruction (which is where the return address 
> is pushed on the stack) dwarf2_frame_prev_register is called, which 
> thinks that the PC is saved on the stack (case 
> DWARF2_FRAME_REG_SAVED_OFFSET) and reads it from there.  Obviously the 
> value it reads is wrong, since the return address hasn't been pushed yet.
> 
> What's wrong here?  Is the dwarf2 debug information wrong, or should 
> dwarf2_frame_prev_register not have been called while still in the prologue?

The beauty of using the CFI data is that it _is_ supposed to work in
the prologue.  It sounds like the CFI is wrong.  Could you post both
assembly and CFI data for the same testcase?  I don't know CRIS
assembly but I imagine I can interpret it well enough to see what's
going on.

It also sounds like your DWARF2_REG_TO_REGNUM may need work, if the
unwinder thinks r16 is the return address column and GDB thinks it's an
8-bit register.

-- 
Daniel Jacobowitz
MontaVista Software                         Debian GNU/Linux Developer


  parent reply	other threads:[~2004-03-11 17:11 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-03-10 16:53 Orjan Friberg
2004-03-10 16:59 ` Daniel Jacobowitz
2004-03-19  0:09   ` Orjan Friberg
2004-03-11 14:09     ` Orjan Friberg
2004-03-11 15:55     ` Orjan Friberg
2004-03-11 17:05       ` Andrew Cagney
2004-03-19  0:09         ` Andrew Cagney
2004-03-19  0:09         ` Orjan Friberg
2004-03-12 12:00           ` Orjan Friberg
2004-03-11 17:11       ` Daniel Jacobowitz [this message]
2004-03-12 10:23         ` Orjan Friberg
2004-03-19  0:09           ` Orjan Friberg
2004-03-19  0:09           ` Daniel Jacobowitz
2004-03-12 15:38             ` Daniel Jacobowitz
2004-03-15 10:19             ` Orjan Friberg
2004-03-19  0:09               ` Orjan Friberg
2004-03-16 16:26             ` Orjan Friberg
2004-03-16 19:13               ` Daniel Jacobowitz
2004-03-16 20:51                 ` Hans-Peter Nilsson
2004-03-16 22:27                   ` Daniel Jacobowitz
2004-03-16 23:38                     ` Hans-Peter Nilsson
2004-03-16 23:58                       ` Daniel Jacobowitz
2004-03-19  0:09                         ` Daniel Jacobowitz
2004-03-19  0:09                       ` Hans-Peter Nilsson
2004-03-19  0:09                     ` Daniel Jacobowitz
2004-03-19  0:09                   ` Hans-Peter Nilsson
2004-03-19  0:09                 ` Daniel Jacobowitz
2004-03-19  0:09               ` Orjan Friberg
2004-03-19  0:09           ` Orjan Friberg
2004-03-12 15:38             ` Orjan Friberg
2004-03-19  0:09           ` Orjan Friberg
2004-03-12 13:50             ` Orjan Friberg
2004-03-19  0:09         ` Daniel Jacobowitz
2004-03-19  0:09       ` Orjan Friberg
2004-03-19  0:09   ` Daniel Jacobowitz
2004-03-19  0:09 ` Orjan Friberg

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=20040311171139.GA17530@nevyn.them.org \
    --to=drow@false.org \
    --cc=gdb-patches@sources.redhat.com \
    --cc=orjan.friberg@axis.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