public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "wcohen at redhat dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug debug/96937] Duplicate DW_TAG_formal_parameter in out-of-line DW_TAG_subprogram instance
Date: Thu, 09 Dec 2021 16:35:24 +0000	[thread overview]
Message-ID: <bug-96937-4-5HA7c0k8kF@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-96937-4@http.gcc.gnu.org/bugzilla/>

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

Will Cohen <wcohen at redhat dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |wcohen at redhat dot com

--- Comment #6 from Will Cohen <wcohen at redhat dot com> ---
I have similar duplications of formal parameters in some of the code compiled
linux kernel code.  I had a dwgrep (https://pmachata.github.io/dwgrep/) that
would print out each function and location with more formal parameters than
listed in the abstract origin:

 dwgrep vmlinux  -e '
let A := entry (?TAG_subprogram) !AT_declaration;
let FSTART := ((A ?AT_entry_pc @AT_entry_pc) || (A ?AT_ranges @AT_ranges low)
|| ( A low));
let B := [A child ?TAG_formal_parameter name] ;
let ABS_ORIGIN := A @AT_abstract_origin;
let C := [ABS_ORIGIN child ?TAG_formal_parameter name];
(C length != B length) B C A name FSTART'

Looking through the functions flagged I found match_id in
/arch/x86/kernel/probe_roms.c looked small and could be a starting point for a
reproducer (two pdev formal parameters):

0xffffffff8102eec0
match_id
["pdev", "vendor", "device"]
["vendor", "device", "pdev", "pdev"]
<Dwarf "vmlinux">

The  "llvm-dwarfdump -c --name=match_id vmlinux" show the duplicate pdev formal
parameters in its output:

0x005741ea: DW_TAG_subprogram
              DW_AT_abstract_origin     (0x00574134 "match_id")
              DW_AT_low_pc      (0xffffffff8102eec0)
              DW_AT_high_pc     (0xffffffff8102ef1a)
              DW_AT_frame_base  (DW_OP_call_frame_cfa)
              DW_AT_call_all_calls      (true)
              DW_AT_sibling     (0x00574291)

0x00574206:   DW_TAG_formal_parameter
                DW_AT_abstract_origin   (0x00574151 "vendor")
                DW_AT_location  (0x0006ebe0: 
                   [0xffffffff8102eec0, 0xffffffff8102eee0): DW_OP_reg2 RCX
                   [0xffffffff8102eee0, 0xffffffff8102ef1a): DW_OP_reg4 RSI)
                DW_AT_GNU_entry_view    (0x0006ebdc)

0x00574213:   DW_TAG_formal_parameter
                DW_AT_abstract_origin   (0x0057415d "device")
                DW_AT_location  (DW_OP_reg8 R8)

0x0057421b:   DW_TAG_variable
                DW_AT_abstract_origin   (0x00574169 "drv")
                DW_AT_location  (0x0006ebf6: 
                   [0xffffffff8102eeeb, 0xffffffff8102eeff): DW_OP_reg2 RCX)
                DW_AT_GNU_entry_view    (0x0006ebf4)

0x00574228:   DW_TAG_variable
                DW_AT_abstract_origin   (0x00574174 "id")
                DW_AT_location  (0x0006ec09: 
                   [0xffffffff8102eef8, 0xffffffff8102eeff): DW_OP_reg1 RDX
                   [0xffffffff8102eeff, 0xffffffff8102ef03): DW_OP_breg1
RDX+40, DW_OP_stack_value
                   [0xffffffff8102ef03, 0xffffffff8102ef19): DW_OP_reg1 RDX)
                DW_AT_GNU_entry_view    (0x0006ec03)

0x00574235:   DW_TAG_formal_parameter
                DW_AT_abstract_origin   (0x00574145 "pdev")
                DW_AT_location  (0x0006ec26: 
                   [0xffffffff8102eec0, 0xffffffff8102ef1a): <decoding error>
fa c7 cc 00 00 9f)
                DW_AT_GNU_entry_view    (0x0006ec24)

0x00574242:   DW_TAG_formal_parameter
                DW_AT_abstract_origin   (0x00574145 "pdev")

The probe_rom.i file was used a a starting point to create a smaller reproducer
with creduce which can be compiled with:

gcc  -Wp,-MMD,arch/x86/kernel/.probe_roms.o.d -nostdinc -D__KERNEL__
-fmacro-pre
fix-map=./= -Wall -Wundef -Werror=strict-prototypes -Wno-trigraphs
-fno-strict-a
liasing -fno-common -fshort-wchar -fno-PIE
-Werror=implicit-function-declaration
 -Werror=implicit-int -Werror=return-type -Wno-format-security -std=gnu89
-mno-s
se -mno-mmx -mno-sse2 -mno-3dnow -mno-avx -fcf-protection=none -m64
-falign-jump
s=1 -falign-loops=1 -mno-80387 -mno-fp-ret-in-387 -mpreferred-stack-boundary=3
-
mskip-rax-setup -mtune=generic -mno-red-zone -mcmodel=kernel -Wno-sign-compare
-
fno-asynchronous-unwind-tables -mindirect-branch=thunk-extern
-mindirect-branch-
register -fno-jump-tables -fno-delete-null-pointer-checks -Wno-frame-address
-Wn
o-format-truncation -Wno-format-overflow -Wno-address-of-packed-member -O2
-fno-
allow-store-data-races -Wframe-larger-than=2048 -fstack-protector-strong
"-Wimpl
icit-fallthrough=5" -Wno-main -Wno-unused-but-set-variable
-Wno-unused-const-var
iable -fno-stack-clash-protection -pg -mrecord-mcount -mfentry
-DCC_USING_FENTRY
 -Wdeclaration-after-statement -Wvla -Wno-pointer-sign -Wno-stringop-truncation 
-Wno-zero-length-bounds -Wno-array-bounds -Wno-stringop-overflow -Wno-restrict
-
Wno-maybe-uninitialized -Wno-alloc-size-larger-than -fno-strict-overflow
-fno-st
ack-check -fconserve-stack -Werror=date-time -Werror=incompatible-pointer-types 
-Werror=designated-init -Wno-packed-not-aligned -g   
-DKBUILD_MODFILE='"arch/x8
6/kernel/probe_roms"' -DKBUILD_BASENAME='"probe_roms"'
-DKBUILD_MODNAME='"probe_
roms"' -D__KBUILD_MODNAME=kmod_probe_roms -c -o probe_roms.o probe_roms.i

  parent reply	other threads:[~2021-12-09 16:35 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-04 14:06 [Bug debug/96937] New: " simon.marchi at polymtl dot ca
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 [this message]
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-5HA7c0k8kF@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).