public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "simon.marchi at polymtl dot ca" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug debug/96937] New: Duplicate DW_TAG_formal_parameter in out-of-line DW_TAG_subprogram instance
Date: Fri, 04 Sep 2020 14:06:23 +0000	[thread overview]
Message-ID: <bug-96937-4@http.gcc.gnu.org/bugzilla/> (raw)

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96937

            Bug ID: 96937
           Summary: Duplicate DW_TAG_formal_parameter in out-of-line
                    DW_TAG_subprogram instance
           Product: gcc
           Version: 11.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: debug
          Assignee: unassigned at gcc dot gnu.org
          Reporter: simon.marchi at polymtl dot ca
  Target Milestone: ---

While debugging GDB (compiled with GCC master and -O2) with GDB, I get:

972     do_examine (struct format_data fmt, struct gdbarch *gdbarch, CORE_ADDR
addr)
(top-gdb) frame
#0  do_examine (gdbarch=0x249a6b0, addr=0x400636, fmt=..., fmt=...) at
/home/smarchi/src/binutils-gdb/gdb/printcmd.c:972
972     do_examine (struct format_data fmt, struct gdbarch *gdbarch, CORE_ADDR
addr)

Note that the parameters shown by GDB aren't in the same order as in the
function declaration, and that "fmt" is duplicated.

0x0004e0bd:   DW_TAG_subprogram
                DW_AT_abstract_origin [DW_FORM_ref4]    (0x0004a912
"do_examine")
                ...

0x0004e0cd:     DW_TAG_formal_parameter
                  DW_AT_abstract_origin [DW_FORM_ref4]  (0x0004a92e "gdbarch")
                  ...

0x0004e0d6:     DW_TAG_formal_parameter
                  DW_AT_abstract_origin [DW_FORM_ref4]  (0x0004a93b "addr")
                  ...

0x0004e0df:     DW_TAG_variable
                  DW_AT_abstract_origin [DW_FORM_ref4]  (0x0004a948 "format")
                  ...

0x0004e0e8:     DW_TAG_variable
                  DW_AT_abstract_origin [DW_FORM_ref4]  (0x0004a955 "size")
                  ...

... some more variables ...


0x0004e130:     DW_TAG_formal_parameter
                  DW_AT_abstract_origin [DW_FORM_ref4]  (0x0004a921 "fmt")

0x0004e135:     DW_TAG_formal_parameter
                  DW_AT_abstract_origin [DW_FORM_ref4]  (0x0004a921 "fmt")


This matches what we see in GDB: the parameters are not in the same order as in
the function declaration and fmt is duplicated.  The abstract origin has them
correct:

0x0004a912:   DW_TAG_subprogram
                DW_AT_name [DW_FORM_strp]       ("do_examine")
                ...

0x0004a921:     DW_TAG_formal_parameter
                  DW_AT_name [DW_FORM_string]   ("fmt")
                  ...

0x0004a92e:     DW_TAG_formal_parameter
                  DW_AT_name [DW_FORM_strp]     ("gdbarch")
                  ...

0x0004a93b:     DW_TAG_formal_parameter
                  DW_AT_name [DW_FORM_strp]     ("addr")
                  ...

After reading bug #49828, I presume that the fact that the parameters are not
in the right order is not considered a bug.  GDB could cope with that by
sorting them to be in the same order as what's in the abstract origin.

However, having fmt there twice could maybe be considered a bug, hence I am
reporting it.

GDB commit (used as the debugged program):
c5cd900e4f197870812c2d3e2c194871c171ef42
GCC commit: 8ad3fc6ca46c603d9c3efe8e6d4a8f2ff1a893a4

             reply	other threads:[~2020-09-04 14:06 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-04 14:06 simon.marchi at polymtl dot ca [this message]
2020-09-04 14:07 ` [Bug debug/96937] " simon.marchi at polymtl dot ca
2020-09-04 14:09 ` simon.marchi at polymtl dot ca
2020-09-07  5:49 ` rguenth at gcc dot gnu.org
2020-09-08 13:20 ` simon.marchi at polymtl dot ca
2020-09-08 13:22 ` simon.marchi at polymtl dot ca
2021-12-09 16:35 ` wcohen at redhat dot com
2021-12-09 16:40 ` wcohen at redhat dot com

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=bug-96937-4@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@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).