public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug debug/96937] New: Duplicate DW_TAG_formal_parameter in out-of-line DW_TAG_subprogram instance
@ 2020-09-04 14:06 simon.marchi at polymtl dot ca
2020-09-04 14:07 ` [Bug debug/96937] " simon.marchi at polymtl dot ca
` (6 more replies)
0 siblings, 7 replies; 8+ messages in thread
From: simon.marchi at polymtl dot ca @ 2020-09-04 14:06 UTC (permalink / raw)
To: gcc-bugs
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
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug debug/96937] Duplicate DW_TAG_formal_parameter in out-of-line DW_TAG_subprogram instance
2020-09-04 14:06 [Bug debug/96937] New: Duplicate DW_TAG_formal_parameter in out-of-line DW_TAG_subprogram instance simon.marchi at polymtl dot ca
@ 2020-09-04 14:07 ` simon.marchi at polymtl dot ca
2020-09-04 14:09 ` simon.marchi at polymtl dot ca
` (5 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: simon.marchi at polymtl dot ca @ 2020-09-04 14:07 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96937
--- Comment #1 from Simon Marchi <simon.marchi at polymtl dot ca> ---
I passed the program in creduce, the result is not pretty but it's not too big
and still reproduces the problem, so I'll attach it anyway.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug debug/96937] Duplicate DW_TAG_formal_parameter in out-of-line DW_TAG_subprogram instance
2020-09-04 14:06 [Bug debug/96937] New: Duplicate DW_TAG_formal_parameter in out-of-line DW_TAG_subprogram instance 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
` (4 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: simon.marchi at polymtl dot ca @ 2020-09-04 14:09 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96937
--- Comment #2 from Simon Marchi <simon.marchi at polymtl dot ca> ---
Created attachment 49181
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=49181&action=edit
Output from creduce
I compile the reproducer program with:
/opt/gcc/git/bin/g++ -x c++ -g3 -O2 -c bug.c
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug debug/96937] Duplicate DW_TAG_formal_parameter in out-of-line DW_TAG_subprogram instance
2020-09-04 14:06 [Bug debug/96937] New: Duplicate DW_TAG_formal_parameter in out-of-line DW_TAG_subprogram instance 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
` (3 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: rguenth at gcc dot gnu.org @ 2020-09-07 5:49 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96937
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |rguenth at gcc dot gnu.org
Last reconfirmed| |2020-09-07
Status|UNCONFIRMED |WAITING
Ever confirmed|0 |1
--- Comment #3 from Richard Biener <rguenth at gcc dot gnu.org> ---
Hmm, can you point out the issue in the reduced testcase? I can't see it. The
only cloning done I see is partial inlining so does -fno-partial-inlining fix
the issue for you?
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug debug/96937] Duplicate DW_TAG_formal_parameter in out-of-line DW_TAG_subprogram instance
2020-09-04 14:06 [Bug debug/96937] New: Duplicate DW_TAG_formal_parameter in out-of-line DW_TAG_subprogram instance simon.marchi at polymtl dot ca
` (2 preceding siblings ...)
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
` (2 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: simon.marchi at polymtl dot ca @ 2020-09-08 13:20 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96937
--- Comment #4 from Simon Marchi <simon.marchi at polymtl dot ca> ---
Created attachment 49198
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=49198&action=edit
Output from creduce
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug debug/96937] Duplicate DW_TAG_formal_parameter in out-of-line DW_TAG_subprogram instance
2020-09-04 14:06 [Bug debug/96937] New: Duplicate DW_TAG_formal_parameter in out-of-line DW_TAG_subprogram instance simon.marchi at polymtl dot ca
` (3 preceding siblings ...)
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
6 siblings, 0 replies; 8+ messages in thread
From: simon.marchi at polymtl dot ca @ 2020-09-08 13:22 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96937
--- Comment #5 from Simon Marchi <simon.marchi at polymtl dot ca> ---
(In reply to Richard Biener from comment #3)
> Hmm, can you point out the issue in the reduced testcase? I can't see it.
> The only cloning done I see is partial inlining so does
> -fno-partial-inlining fix the issue for you?
Doh, I indeed uploaded the wrong thing. My creduce test was trying to
reproduce the "wrong parameter order" problem, which I later found was probably
not considered a bug, instead of the "duplicate parameter problem". I re-ran
it with the right test, I attached the result.
The relevant portion of the DWARF is:
0x000003bb: DW_TAG_subprogram
DW_AT_abstract_origin (0x00000383 "do_examine")
DW_AT_low_pc (0x0000000000000000)
DW_AT_high_pc (0x0000000000000039)
DW_AT_frame_base (DW_OP_call_frame_cfa)
DW_AT_GNU_all_call_sites (true)
DW_AT_sibling (0x00000464)
0x000003d6: DW_TAG_variable
DW_AT_abstract_origin (0x000003a4 "ai")
0x000003db: DW_TAG_variable
DW_AT_abstract_origin (0x000003af "aq")
DW_AT_location (DW_OP_fbreg -17)
0x000003e3: DW_TAG_formal_parameter
DW_AT_abstract_origin (0x0000039f)
DW_AT_location (<decoding error> 9f 03 00 00 9f)
0x000003ef: DW_TAG_formal_parameter
DW_AT_abstract_origin (0x0000039a)
DW_AT_location (<decoding error> 9a 03 00 00 9f)
0x000003fb: DW_TAG_formal_parameter
DW_AT_abstract_origin (0x00000390 "y")
0x00000400: DW_TAG_formal_parameter
DW_AT_abstract_origin (0x00000390 "y")
The last two DW_TAG_formal_parameter refer to the same parameter.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug debug/96937] Duplicate DW_TAG_formal_parameter in out-of-line DW_TAG_subprogram instance
2020-09-04 14:06 [Bug debug/96937] New: Duplicate DW_TAG_formal_parameter in out-of-line DW_TAG_subprogram instance simon.marchi at polymtl dot ca
` (4 preceding siblings ...)
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
6 siblings, 0 replies; 8+ messages in thread
From: wcohen at redhat dot com @ 2021-12-09 16:35 UTC (permalink / raw)
To: gcc-bugs
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
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug debug/96937] Duplicate DW_TAG_formal_parameter in out-of-line DW_TAG_subprogram instance
2020-09-04 14:06 [Bug debug/96937] New: Duplicate DW_TAG_formal_parameter in out-of-line DW_TAG_subprogram instance simon.marchi at polymtl dot ca
` (5 preceding siblings ...)
2021-12-09 16:35 ` wcohen at redhat dot com
@ 2021-12-09 16:40 ` wcohen at redhat dot com
6 siblings, 0 replies; 8+ messages in thread
From: wcohen at redhat dot com @ 2021-12-09 16:40 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96937
--- Comment #7 from Will Cohen <wcohen at redhat dot com> ---
Created attachment 51963
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=51963&action=edit
Reproducer showing duplicate formal parameters from kernel probe_rom.i
Compiled with following to generate probe_rom.o with duplicate k formal
parameters in the debuginfo:
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
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2021-12-09 16:40 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-04 14:06 [Bug debug/96937] New: Duplicate DW_TAG_formal_parameter in out-of-line DW_TAG_subprogram instance 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
2021-12-09 16:40 ` wcohen at redhat dot com
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).