public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
From: werner@almesberger.net
To: gcc-gnats@gcc.gnu.org
Subject: debug/10000: gcc -g generates location expressions which are not valid in prologue
Date: Sat, 08 Mar 2003 14:16:00 -0000	[thread overview]
Message-ID: <200303081413.h28EDnO26554@almesberger.net> (raw)


>Number:         10000
>Category:       debug
>Synopsis:       gcc -g generates location expressions which are not valid in prologue
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sat Mar 08 14:16:01 UTC 2003
>Closed-Date:
>Last-Modified:
>Originator:     Werner Almesberger
>Release:        3.3 20030303 (prerelease)
>Organization:
>Environment:
System: Linux ar 2.4.18 #5 Mon Mar 18 09:25:24 ART 2002 i686 unknown
Architecture: i686

	
host: i686-pc-linux-gnu
build: i686-pc-linux-gnu
target: i686-pc-linux-gnu
configured with: ./configure --prefix=/usr/local/gcc20030303/ --enable-languages=c
>Description:

gcc -g generates location expressions which are not valid
in prologue

This may actually be more a misfeature of DWARF2 than a gcc bug.
Theoretically, DWARF2 would allow us to express exactly what is
valid and at which location, even during the prologue, but this
seems to be quite cumbersome.

>How-To-Repeat:

Example (with Red Hat's gcc 3.1 20011127 on ia32):

$ cat <<EOF >foo.c
int main(int argc)
{
    return 0;
}
EOF
$ gcc -g foo.c
$ readelf -w a.out
...
     DW_AT_name        : (indirect string, offset: 0x3f): main
...
     DW_AT_low_pc      : 0x8048398 134513560
...
     DW_AT_frame_base  : 1 byte block: 55       (DW_OP_reg5; )
 <2><40>: Abbrev Number: 3 (DW_TAG_formal_parameter)
     DW_AT_name        : (indirect string, offset: 0x3a): argc
...
     DW_AT_location    : 2 byte block: 91 8     (DW_OP_fbreg: 8; )
...
$ objdump -d a.out
...
08048398 <main>:
 8048398:       55                      push   %ebp
 8048399:       89 e5                   mov    %esp,%ebp
 804839b:       83 ec 08                sub    $0x8,%esp
 804839e:       83 e4 f0                and    $0xfffffff0,%esp
...

Quite obviously, 8(%ebp) only points to argc when we've reached
address 804839b, but the debugging information does not provide
any indication more precise than DW_AT_low_pc.

>Fix:

The work-around gdb uses seems to work reasonably well, but I'm
a bit worried about whether unusual linkage styles might throw
it off. (After all, this has to work with the Linux kernel.)
>Release-Note:
>Audit-Trail:
>Unformatted:


             reply	other threads:[~2003-03-08 14:16 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-03-08 14:16 werner [this message]
2003-03-08 18:36 Zack Weinberg

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=200303081413.h28EDnO26554@almesberger.net \
    --to=werner@almesberger.net \
    --cc=gcc-gnats@gcc.gnu.org \
    /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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).