public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: "Ulrich Weigand" <uweigand@de.ibm.com>
To: dje.gcc@gmail.com (David Edelsohn)
Cc: geoffk@geoffk.org, jakub@redhat.com, gcc-patches@gcc.gnu.org,
	       binutils@sourceware.org, gdb-patches@sourceware.org
Subject: Re: [RFC] Wrong register numbers in .dwarf_frame on Linux/PowerPC
Date: Tue, 27 Nov 2012 19:12:00 -0000	[thread overview]
Message-ID: <201211271912.qARJC2La003115@d06av02.portsmouth.uk.ibm.com> (raw)
In-Reply-To: <CAGWvnykKKQ8YBGEXp1_Kvo5j=7Yt9gBmfNuMuXNQ=-gcPS1b0g@mail.gmail.com> from "David Edelsohn" at Nov 26, 2012 03:04:45 PM

David Edelsohn wrote:
> On Mon, Nov 26, 2012 at 2:10 PM, Ulrich Weigand <uweigand@de.ibm.com> wrote:
> 
> > So I'm wondering where to go from here.  I guess we could:
> >
> > 1. Bring GCC (and gas) behaviour in compliance with the documented ABI
> >    by removing the #undef DBX_REGISTER_NUMBER and changing gas's
> >    md_reg_eh_frame_to_debug_frame to the original implementation from
> >    Jakub's patch.  That would make GDB work well on new files, but
> >    there are a large number of binaries out there where we continue
> >    to have the same behaviour as today ...
> >
> > 2. Leave GCC and gas as-is and modify GDB to expect GCC numbering in
> >    .dwarf_frame, except for the condition code register.  This would
> >    break debugging of files built with GCC 4.0 and 4.1 unless we
> >    want to add a special hack for that.
> >
> > 3. Like 2., but remove the condition code hack: simply use identical
> >    numbers in .eh_frame and .dwarf_frame.  This would make PowerPC
> >    like other Linux platforms in that respect.
> >
> > Thoughts?
> 
> I vote for (3).

I'd agree, in particular given that XLC and LLVM seem to match this
behaviour as well.

Looking into this further, it turns out that on Linux not only .debug_frame
is affected, but also .debug_info and all the other .debug_... sections.
DBX_REGISTER_NUMBER is used for register numbers in those sections too ...

This again doesn't match what GDB is expecting:  For regular debug info
(not frame info), GDB only distinguished between stabs and DWARF, and
assumes GCC numbering for stabs, and DWARF numbering for DWARF.  This
holds for any PowerPC operating system.

However, looking at GCC behaviour, we have instead GCC numbering used
in either stabs or DWARF on Linux, but DWARF numbering apparently used
in either stabs or DWARF on AIX/BSD/Darwin.

Here, comparison with other compilers is less clear.  I wasn't able to
get XLC on Linux to generate any .debug_info containing a register
number for non-GPR/FPR registers (it would always put such variables
on the stack).  The XLC on AIX I have access to is quite old and only
generates stabs; again I wasn't able to see any non-GPR register
assignments.  LLVM consistently uses the GCC numbering on all operating
systems it supports (I think that's Linux, Darwin, and FreeBSD).

As far as Linux is concerned, leaving the compilers as-is and changing
GDB to expect GCC numbering might be the best option.  Not sure about
other operating systems ...

Bye,
Ulrich

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

  reply	other threads:[~2012-11-27 19:12 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-11-26 19:10 Ulrich Weigand
2012-11-26 20:04 ` David Edelsohn
2012-11-27 19:12   ` Ulrich Weigand [this message]
2012-11-26 20:14 ` Mark Kettenis
2012-11-27 18:43   ` Ulrich Weigand
2012-11-27 19:13     ` Mark Kettenis
2012-11-27  9:26 ` Mark Wielaard
2012-11-27 18:49   ` Ulrich Weigand
2012-11-28 11:26     ` Mark Wielaard

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=201211271912.qARJC2La003115@d06av02.portsmouth.uk.ibm.com \
    --to=uweigand@de.ibm.com \
    --cc=binutils@sourceware.org \
    --cc=dje.gcc@gmail.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=gdb-patches@sourceware.org \
    --cc=geoffk@geoffk.org \
    --cc=jakub@redhat.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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).