@@ -12112,7 +12112,8 @@ read_func_scope (struct die_info *die, struct dwarf2_cu *cu)
1211212112 for (child_die = die->child; child_die; child_die = child_die->sibling)
1211312113 {
1211412114 if (child_die->tag == DW_TAG_template_type_param
12115- || child_die->tag == DW_TAG_template_value_param)
12115+ || child_die->tag == DW_TAG_template_value_param
12116+ || child_die->tag == DW_TAG_GNU_template_parameter_pack)
1211612117 {
1211712118 templ_func = new (&objfile->objfile_obstack) template_symbol;
1211812119 templ_func->subclass = SYMBOL_TEMPLATE;
@@ -12161,6 +12162,23 @@ read_func_scope (struct die_info *die, struct dwarf2_cu *cu)
1216112162 if (arg != NULL)
1216212163 template_args.push_back (arg);
1216312164 }
12165+ else if (child_die->tag == DW_TAG_GNU_template_parameter_pack)
12166+ {
12167+ struct die_info *pack_die;
12168+ for (pack_die = child_die->child; pack_die; pack_die = pack_die->sibling)
12169+ {
12170+ struct symbol *arg = new_symbol (pack_die, NULL, cu);
12171+
12172+ if (arg != NULL)
12173+ template_args.push_back (arg);
12174+ }
12175+ }
12176+ else if (child_die->tag == DW_TAG_GNU_formal_parameter_pack)
12177+ {
12178+ struct die_info *pack_die;
12179+ for (pack_die = child_die->child; pack_die; pack_die = pack_die->sibling)
12180+ process_die (pack_die, cu);
12181+ }
1216412182 else
1216512183 process_die (child_die, cu);
1216612184 child_die = child_die->sibling;
@@ -16648,6 +16666,11 @@ read_subroutine_type (struct die_info *die, struct dwarf2_cu *cu)
1664816666 {
1664916667 if (child_die->tag == DW_TAG_formal_parameter)
1665016668 nparams++;
16669+ else if (child_die->tag == DW_TAG_GNU_formal_parameter_pack)
16670+ {
16671+ child_die = child_die->child;
16672+ continue;
16673+ }
1665116674 else if (child_die->tag == DW_TAG_unspecified_parameters)
1665216675 ftype->set_has_varargs (true);
1665316676
@@ -16723,6 +16746,11 @@ read_subroutine_type (struct die_info *die, struct dwarf2_cu *cu)
1672316746 ftype->field (iparams).set_type (arg_type);
1672416747 iparams++;
1672516748 }
16749+ else if (child_die->tag == DW_TAG_GNU_formal_parameter_pack)
16750+ {
16751+ child_die = child_die->child;
16752+ continue;
16753+ }
1672616754 child_die = child_die->sibling;
1672716755 }
1672816756 }
@@ -20844,13 +20872,16 @@ new_symbol (struct die_info *die, struct type *type, struct dwarf2_cu *cu,
2084420872 sym->set_type (type);
2084520873 else
2084620874 sym->set_type (die_type (die, cu));
20847- attr = dwarf2_attr (die,
20875+ struct die_info *line_file_die = die;
20876+ if (die->tag == DW_TAG_formal_parameter && die->parent && die->parent->tag == DW_TAG_GNU_formal_parameter_pack)
20877+ line_file_die = die->parent;
20878+ attr = dwarf2_attr (line_file_die,
2084820879 inlined_func ? DW_AT_call_line : DW_AT_decl_line,
2084920880 cu);
2085020881 if (attr != nullptr)
2085120882 sym->set_line (attr->constant_value (0));
2085220883
20853- attr = dwarf2_attr (die ,
20884+ attr = dwarf2_attr (line_file_die ,
2085420885 inlined_func ? DW_AT_call_file : DW_AT_decl_file,
2085520886 cu);
2085620887 if (attr != nullptr && attr->is_nonnegative ())
@@ -21070,6 +21101,8 @@ new_symbol (struct die_info *die, struct type *type, struct dwarf2_cu *cu,
2107021101 list_to_add = cu->list_in_scope;
2107121102 }
2107221103 break;
21104+ case DW_TAG_GNU_formal_parameter_pack:
21105+ break;
2107321106 case DW_TAG_unspecified_parameters:
2107421107 /* From varargs functions; gdb doesn't seem to have any
2107521108 interest in this information, so just ignore it for now.
@@ -22078,8 +22111,11 @@ dwarf2_name (struct die_info *die, struct dwarf2_cu *cu)
2207822111 if (attr_name == nullptr
2207922112 && die->tag != DW_TAG_namespace
2208022113 && die->tag != DW_TAG_class_type
22114+ && die->tag != DW_TAG_formal_parameter
2208122115 && die->tag != DW_TAG_interface_type
2208222116 && die->tag != DW_TAG_structure_type
22117+ && die->tag != DW_TAG_template_type_param
22118+ && die->tag != DW_TAG_template_value_param
2208322119 && die->tag != DW_TAG_namelist
2208422120 && die->tag != DW_TAG_union_type
2208522121 && die->tag != DW_TAG_template_type_param
@@ -22108,9 +22144,36 @@ dwarf2_name (struct die_info *die, struct dwarf2_cu *cu)
2210822144 return attr_name;
2210922145 return CP_ANONYMOUS_NAMESPACE_STR;
2211022146
22111- /* DWARF does not actually require template tags to have a name. */
22147+ case DW_TAG_formal_parameter:
2211222148 case DW_TAG_template_type_param:
2211322149 case DW_TAG_template_value_param:
22150+ if (!attr
22151+ && die->parent
22152+ && (die->parent->tag == DW_TAG_GNU_formal_parameter_pack
22153+ || die->parent->tag == DW_TAG_GNU_template_parameter_pack))
22154+ {
22155+ const char *parent_name;
22156+ int ordinal = 0;
22157+ struct die_info *child_die;
22158+ size_t size;
22159+ char *name;
22160+ parent_name = dwarf2_name(die->parent, cu);
22161+ if (!parent_name)
22162+ return NULL;
22163+ for (child_die = die->parent->child; child_die != die; child_die = child_die->sibling)
22164+ ++ordinal;
22165+ size = snprintf(NULL, 0, "%s#%d", parent_name, ordinal) + 1;
22166+ name = ((char *) obstack_alloc (&cu->per_objfile->per_bfd->obstack, size));
22167+ snprintf(name, size, "%s#%d", parent_name, ordinal);
22168+ return name;
22169+ }
22170+ if (die->tag == DW_TAG_formal_parameter)
22171+ {
22172+ if (!attr || attr_name == NULL)
22173+ return NULL;
22174+ break;
22175+ }
22176+ /* DWARF does not actually require template tags to have a name. */
2211422177 if (attr_name == nullptr)
2211522178 return unnamed_template_tag_name (die, cu);
2211622179 /* FALLTHROUGH. */
0 commit comments