From: Keith Seitz <keiths@redhat.com>
To: gdb-patches@sourceware.org
Subject: [RFC PATCH] Really fix gdb/23010: SYMBOL_LANGUAGE != DICT_LANGUAGE assertion
Date: Tue, 05 Jun 2018 18:09:00 -0000 [thread overview]
Message-ID: <20180605180912.3256-1-keiths@redhat.com> (raw)
This patch is another attempt at really fixing the multitude of assertions
being seen where symbols of one language are being added to symbol lists of
another language.
In short, this is happening because read_file_scope was reading DIEs without
having its language set. As a result, the default language, language_minimal,
was being passed to imported DIE trees and, in certain specific situations,
causing the SYMBOL_LANGUAGE != DICT_LANGUAGE assertion being widely reported.
For a more thorough explanation, see the following mailing list
post:
https://sourceware.org/ml/gdb-patches/2018-05/msg00703.html
Since a test reproducer for this has been so elusive, this patch also adds a
wrapper function around add_symbol_to_list which asserts when adding a symbol
of one language to a list containing symbols of a different language.
For this RFC, I have left both the assertion (which I prefer) and the
complaint variation in the patch. I will remove the unused bits upon
approval.
gdb/ChangeLog:
PR gdb/23010
* dwarf2read.c (dw2_add_symbol_to_list): New function.
(fixup_go_packaging, new_symbol): Use dw2_add_symbol_to_list
instead of add_symbol_to_list.
(read_file_scope): Call prepare_one_comp_unit before reading
any other DIEs.
---
gdb/dwarf2read.c | 38 ++++++++++++++++++++++++++++++++------
1 file changed, 32 insertions(+), 6 deletions(-)
diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
index 1cabfbb0d4..04f22114f8 100644
--- a/gdb/dwarf2read.c
+++ b/gdb/dwarf2read.c
@@ -9701,6 +9701,33 @@ compute_delayed_physnames (struct dwarf2_cu *cu)
cu->method_list.clear ();
}
+/* A wrapper for add_symbol_to_list to issue a complaint if a symbol
+ with a different language is added to LISTHEAD. */
+
+static inline void
+dw2_add_symbol_to_list (struct symbol *symbol, struct pending **listhead)
+{
+ /* Only complain if LISTHEAD already contains symbols of a different
+ language. */
+#if USE_ASSERT
+ gdb_assert ((*listhead) == NULL
+ || (*listhead)->nsyms == 0
+ || (SYMBOL_LANGUAGE ((*listhead)->symbol[0])
+ == SYMBOL_LANGUAGE (symbol)));
+#else
+ if ((*listhead) != NULL && (*listhead)->nsyms > 0
+ && SYMBOL_LANGUAGE ((*listhead)->symbol[0]) != SYMBOL_LANGUAGE (symbol))
+ {
+ complaint (_("recording symbol \"%s\" with language %s "
+ "into list of langauge %s"), SYMBOL_LINKAGE_NAME (symbol),
+ language_str (SYMBOL_LANGUAGE (symbol)),
+ language_str (SYMBOL_LANGUAGE ((*listhead)->symbol[0])));
+ }
+#endif
+
+ add_symbol_to_list (symbol, listhead);
+}
+
/* Go objects should be embedded in a DW_TAG_module DIE,
and it's not clear if/how imported objects will appear.
To keep Go support simple until that's worked out,
@@ -9772,7 +9799,7 @@ fixup_go_packaging (struct dwarf2_cu *cu)
SYMBOL_ACLASS_INDEX (sym) = LOC_TYPEDEF;
SYMBOL_TYPE (sym) = type;
- add_symbol_to_list (sym, &global_symbols);
+ dw2_add_symbol_to_list (sym, &global_symbols);
xfree (package_name);
}
@@ -11438,6 +11465,7 @@ read_file_scope (struct die_info *die, struct dwarf2_cu *cu)
struct die_info *child_die;
CORE_ADDR baseaddr;
+ prepare_one_comp_unit (cu, die, cu->language);
baseaddr = ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile));
get_scope_pc_bounds (die, &lowpc, &highpc, cu);
@@ -11450,8 +11478,6 @@ read_file_scope (struct die_info *die, struct dwarf2_cu *cu)
file_and_directory fnd = find_file_and_directory (die, cu);
- prepare_one_comp_unit (cu, die, cu->language);
-
/* The XLCL doesn't generate DW_LANG_OpenCL because this attribute is not
standardised yet. As a workaround for the language detection we fall
back to the DW_AT_producer string. */
@@ -21208,7 +21234,7 @@ new_symbol (struct die_info *die, struct type *type, struct dwarf2_cu *cu,
SYMBOL_TYPE (sym) = objfile_type (objfile)->builtin_core_addr;
SYMBOL_DOMAIN (sym) = LABEL_DOMAIN;
SYMBOL_ACLASS_INDEX (sym) = LOC_LABEL;
- add_symbol_to_list (sym, cu->list_in_scope);
+ dw2_add_symbol_to_list (sym, cu->list_in_scope);
break;
case DW_TAG_subprogram:
/* SYMBOL_BLOCK_VALUE (sym) will be filled in later by
@@ -21466,7 +21492,7 @@ new_symbol (struct die_info *die, struct type *type, struct dwarf2_cu *cu,
case DW_TAG_common_block:
SYMBOL_ACLASS_INDEX (sym) = LOC_COMMON_BLOCK;
SYMBOL_DOMAIN (sym) = COMMON_BLOCK_DOMAIN;
- add_symbol_to_list (sym, cu->list_in_scope);
+ dw2_add_symbol_to_list (sym, cu->list_in_scope);
break;
default:
/* Not a tag we recognize. Hopefully we aren't processing
@@ -21486,7 +21512,7 @@ new_symbol (struct die_info *die, struct type *type, struct dwarf2_cu *cu,
}
if (list_to_add != NULL)
- add_symbol_to_list (sym, list_to_add);
+ dw2_add_symbol_to_list (sym, list_to_add);
/* For the benefit of old versions of GCC, check for anonymous
namespaces based on the demangled name. */
--
2.13.6
next reply other threads:[~2018-06-05 18:09 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-06-05 18:09 Keith Seitz [this message]
2018-06-06 17:49 ` Keith Seitz
2018-06-11 22:26 ` Joel Brobecker
2018-06-26 21:40 ` Keith Seitz
2018-06-27 16:25 ` Joel Brobecker
2018-07-09 19:50 ` Keith Seitz
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=20180605180912.3256-1-keiths@redhat.com \
--to=keiths@redhat.com \
--cc=gdb-patches@sourceware.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).