From patchwork Sat Jul 27 16:22:30 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Burgess X-Patchwork-Id: 33829 Received: (qmail 28940 invoked by alias); 27 Jul 2019 16:22:53 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 28925 invoked by uid 89); 27 Jul 2019 16:22:53 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-22.4 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_STOCKGEN, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.1 spammy=visible X-HELO: mail-wm1-f68.google.com Received: from mail-wm1-f68.google.com (HELO mail-wm1-f68.google.com) (209.85.128.68) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sat, 27 Jul 2019 16:22:51 +0000 Received: by mail-wm1-f68.google.com with SMTP id s15so28659921wmj.3 for ; Sat, 27 Jul 2019 09:22:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=embecosm.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=vnv2AXuSRM8UvTLVX0wbZShYIqMlSyRjznteFj+bI6c=; b=HJRsRUUcRHEzxdqhQjvmXjKWwRoXQ60JSR4kyJz4/2+N7xjvLUODdksJs7WqLXGjdN WqxYRtfpHCVHKkz9bmg7/UQb2x3526sucwPOnXEyDeAX+hgAp4mfXjLpLfIQtDbIGLqF T+OfW77cemexliWU1zLoTRuN4SsUQxUMpAWr2dxX3zUtZFKozCxILTOyqE1ag6z7bbrB XaEvjux7mCkTqBuZ8UR/G/g5dMJBtu9wPyKQcQmZftyPBlXrUrgxc5u3pSTaCy6h2L7Z B0TchtSimamXvNSr2Mjc8p2elwUlfeMMyxiE7HgRJw1jYwlvEQqZ/w6eN8iMUZLDcXAm dIXA== Return-Path: Received: from localhost (188.29.165.26.threembb.co.uk. [188.29.165.26]) by smtp.gmail.com with ESMTPSA id z1sm60202656wrv.90.2019.07.27.09.22.48 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 27 Jul 2019 09:22:48 -0700 (PDT) From: Andrew Burgess To: gdb-patches@sourceware.org Cc: Richard Bunt , Andrew Burgess Subject: [PATCH 2/7] gdb: Add an is_declaration field to each symbol Date: Sat, 27 Jul 2019 17:22:30 +0100 Message-Id: <02a60599e2dff9efead7adbb070733c0f4c65f04.1564243858.git.andrew.burgess@embecosm.com> In-Reply-To: References: In-Reply-To: References: X-IsSubscribed: yes This commit is in preparation for a later commit, there should be no user visible change after this commit. Track if a symbol is a declaration or not. At one point we could possibly figure this out based on the LOC_UNRESOLVED address class of the symbol, but, for Fortran we mark some symbols as LOC_UNRESOLVED even when the DWARF supplies an address, this is because the address supplied by the DWARF is actually wrong. For details look in dwarf2read.c and look for references to gFortran bug #40040. I have confirmed that current versions of gFortran still have the issue mentioned in that bug report. I considered two possible solutions to this problem, one was to add a new address class, something like: LOC_UNRESOLVED_BUT_IS_STILL_A_DEFINITION that I could use specifically for marking these "broken" Fortran symbols. My concern here is that every place LOC_UNRESOLVED is mentioned would need to be possibly edited to also handle the new address class, and any future change that mentions LOC_UNRESOLVED would be a possible source of Fortran bugs due to not handling the new address class correctly. So, the solution I took was to add a new single bit flag to the symbol to track if the symbol is a declaration or not. There are already some 1 bit flags in the symbol object, and on x86-64 GNU/Linux (at least for me) adding one additional flag didn't increase the size of the symbol object at all. gdb/ChangeLog: * dwarf2read.c (new_symbol): Mark symbol as declaration when appropriate. * symtab.h (struct symbol): Add 'is_declaration' flag. (SYMBOL_IS_DECLARATION): Define. --- gdb/ChangeLog | 7 +++++++ gdb/dwarf2read.c | 3 +++ gdb/symtab.h | 4 ++++ 3 files changed, 14 insertions(+) diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c index 3d90d632891..01cab752888 100644 --- a/gdb/dwarf2read.c +++ b/gdb/dwarf2read.c @@ -21503,6 +21503,9 @@ new_symbol (struct die_info *die, struct type *type, struct dwarf2_cu *cu, dwarf2_full_name (name, die, cu), NULL); + if (die_is_declaration (die, cu)) + SYMBOL_IS_DECLARATION (sym) = 1; + /* Default assumptions. Use the passed type or decode it from the die. */ SYMBOL_DOMAIN (sym) = VAR_DOMAIN; diff --git a/gdb/symtab.h b/gdb/symtab.h index 4f653bcdc1b..c4fd520e735 100644 --- a/gdb/symtab.h +++ b/gdb/symtab.h @@ -1110,6 +1110,9 @@ struct symbol /* Whether this is an inlined function (class LOC_BLOCK only). */ unsigned is_inlined : 1; + /* Is this symbol a declaration? */ + unsigned is_declaration : 1; + /* The concrete type of this symbol. */ ENUM_BITFIELD (symbol_subclass_kind) subclass : 2; @@ -1171,6 +1174,7 @@ extern const struct symbol_impl *symbol_impls; #define SYMBOL_INLINED(symbol) (symbol)->is_inlined #define SYMBOL_IS_CPLUS_TEMPLATE_FUNCTION(symbol) \ (((symbol)->subclass) == SYMBOL_TEMPLATE) +#define SYMBOL_IS_DECLARATION(symbol) (symbol)->is_declaration #define SYMBOL_TYPE(symbol) (symbol)->type #define SYMBOL_LINE(symbol) (symbol)->line #define SYMBOL_COMPUTED_OPS(symbol) (SYMBOL_IMPL (symbol).ops_computed)