• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

GNU Binutils with patches for OS216


Commit MetaInfo

Revisão3e1d3d8c2494c021718ba957e83395958ee08a0f (tree)
Hora2018-08-03 07:12:42
AutorTom Tromey <tom@trom...>
CommiterTom Tromey

Mensagem de Log

Allow "info address" of a template parameter

PR symtab/16842 shows that gdb will crash when the user tries to
invoke "info address" of a template parameter.

The bug here is that dwarf2read.c does not set the symtab on the
template parameter symbols. This is pedantically correct, given that
the template symbols do not appear in a symtab. However, gdb
primarily uses the symtab backlink to find the symbol's objfile. So,
this patch simply sets the symtab on these symbols.

Tested by the buildbot.

gdb/ChangeLog
2018-08-02 Tom Tromey <tom@tromey.com>

PR symtab/16842.
* dwarf2read.c (read_func_scope): Set symtab on template parameter
symbols.
(process_structure_scope): Likewise.

gdb/testsuite/ChangeLog
2018-08-02 Tom Tromey <tom@tromey.com>

PR symtab/16842.
* gdb.cp/temargs.exp: Test "info address" of a template
parameter.

Mudança Sumário

Diff

--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,10 @@
1+2018-08-02 Tom Tromey <tom@tromey.com>
2+
3+ PR symtab/16842.
4+ * dwarf2read.c (read_func_scope): Set symtab on template parameter
5+ symbols.
6+ (process_structure_scope): Likewise.
7+
18 2018-08-02 Xavier Roirand <roirand@adacore.com>
29
310 PR gdb/22629:
--- a/gdb/dwarf2read.c
+++ b/gdb/dwarf2read.c
@@ -13753,6 +13753,13 @@ read_func_scope (struct die_info *die, struct dwarf2_cu *cu)
1375313753 memcpy (templ_func->template_arguments,
1375413754 template_args.data (),
1375513755 (templ_func->n_template_arguments * sizeof (struct symbol *)));
13756+
13757+ /* Make sure that the symtab is set on the new symbols. Even
13758+ though they don't appear in this symtab directly, other parts
13759+ of gdb assume that symbols do, and this is reasonably
13760+ true. */
13761+ for (struct symbol *sym : template_args)
13762+ symbol_set_symtab (sym, symbol_symtab (templ_func));
1375613763 }
1375713764
1375813765 /* In C++, we can have functions nested inside functions (e.g., when
@@ -15873,6 +15880,7 @@ process_structure_scope (struct die_info *die, struct dwarf2_cu *cu)
1587315880 discriminant_info. */
1587415881 bool is_variant_part = TYPE_FLAG_DISCRIMINATED_UNION (type);
1587515882 sect_offset discr_offset;
15883+ bool has_template_parameters = false;
1587615884
1587715885 if (is_variant_part)
1587815886 {
@@ -15920,6 +15928,7 @@ process_structure_scope (struct die_info *die, struct dwarf2_cu *cu)
1592015928 /* Attach template arguments to type. */
1592115929 if (!template_args.empty ())
1592215930 {
15931+ has_template_parameters = true;
1592315932 ALLOCATE_CPLUS_STRUCT_TYPE (type);
1592415933 TYPE_N_TEMPLATE_ARGUMENTS (type) = template_args.size ();
1592515934 TYPE_TEMPLATE_ARGUMENTS (type)
@@ -16069,7 +16078,20 @@ process_structure_scope (struct die_info *die, struct dwarf2_cu *cu)
1606916078 attribute, and a declaration attribute. */
1607016079 if (dwarf2_attr (die, DW_AT_byte_size, cu) != NULL
1607116080 || !die_is_declaration (die, cu))
16072- new_symbol (die, type, cu);
16081+ {
16082+ struct symbol *sym = new_symbol (die, type, cu);
16083+
16084+ if (has_template_parameters)
16085+ {
16086+ /* Make sure that the symtab is set on the new symbols.
16087+ Even though they don't appear in this symtab directly,
16088+ other parts of gdb assume that symbols do, and this is
16089+ reasonably true. */
16090+ for (int i = 0; i < TYPE_N_TEMPLATE_ARGUMENTS (type); ++i)
16091+ symbol_set_symtab (TYPE_TEMPLATE_ARGUMENT (type, i),
16092+ symbol_symtab (sym));
16093+ }
16094+ }
1607316095 }
1607416096
1607516097 /* Assuming DIE is an enumeration type, and TYPE is its associated type,
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,3 +1,9 @@
1+2018-08-02 Tom Tromey <tom@tromey.com>
2+
3+ PR symtab/16842.
4+ * gdb.cp/temargs.exp: Test "info address" of a template
5+ parameter.
6+
17 2018-07-31 Jan Vrany <jan.vrany@fit.cvut.cz>
28
39 * gdb.python/py-mi-var-info-path-expression.c: New file.
--- a/gdb/testsuite/gdb.cp/temargs.exp
+++ b/gdb/testsuite/gdb.cp/temargs.exp
@@ -133,6 +133,10 @@ gdb_test "ptype T" "unsigned char" "test type of T in func"
133133 if $have_older_template_gcc { setup_xfail "*-*-*" }
134134 gdb_test "print I" " = 91" "test value of I in func"
135135
136+# PR symtab/16842 - gdb used to crash here.
137+if $have_older_template_gcc { setup_xfail "*-*-*" }
138+gdb_test "info addr I" "Symbol \"I\" is constant." "test address of I in templ_m"
139+
136140 if $have_older_template_gcc { setup_xfail "*-*-*" }
137141 gdb_test "print P == &a_global" " = true" "test value of P in func"
138142
@@ -151,6 +155,10 @@ gdb_test "ptype T" "double" "test type of T in templ_m"
151155 if $have_older_template_gcc { setup_xfail "*-*-*" }
152156 gdb_test "print I" " = 23" "test value of I in templ_m"
153157
158+# PR symtab/16842 - gdb used to crash here.
159+if $have_older_template_gcc { setup_xfail "*-*-*" }
160+gdb_test "info addr I" "Symbol \"I\" is constant." "test address of I in templ_m"
161+
154162 if $have_older_template_gcc { setup_xfail "*-*-*" }
155163 gdb_test "print P == &a_global" " = true" "test value of P in templ_m"
156164