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