Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Andrew Burgess <andrew.burgess@embecosm.com>
To: gdb-patches@sourceware.org
Cc: Richard Bunt <Richard.Bunt@arm.com>,
	Andrew Burgess <andrew.burgess@embecosm.com>
Subject: [PATCH 2/7] gdb: Add an is_declaration field to each symbol
Date: Sat, 27 Jul 2019 16:22:00 -0000	[thread overview]
Message-ID: <02a60599e2dff9efead7adbb070733c0f4c65f04.1564243858.git.andrew.burgess@embecosm.com> (raw)
In-Reply-To: <cover.1564243858.git.andrew.burgess@embecosm.com>
In-Reply-To: <cover.1564243858.git.andrew.burgess@embecosm.com>

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)
-- 
2.14.5


  parent reply	other threads:[~2019-07-27 16:22 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-27 16:22 [PATCH 0/7] Fortran info types, info modules, info module Andrew Burgess
2019-07-27 16:22 ` [PATCH 3/7] gdb/fortran: Include module variables in 'info variables' output Andrew Burgess
2019-07-27 16:22 ` Andrew Burgess [this message]
2019-07-29 20:21   ` [PATCH 2/7] gdb: Add an is_declaration field to each symbol Tom Tromey
2019-07-30 21:00     ` Andrew Burgess
2019-07-27 16:23 ` [PATCH 1/7] gdb: Add new -n flag to some info commands Andrew Burgess
2019-07-27 16:41   ` Eli Zaretskii
2019-07-30 21:02     ` Andrew Burgess
2019-07-31 14:51       ` Eli Zaretskii
2019-08-26 15:52         ` Andrew Burgess
2019-08-26 16:19           ` Eli Zaretskii
2019-08-27 15:27             ` Andrew Burgess
2019-08-28 15:13               ` [committed][gdb/testsuite] Fix info-var.exp for debug info from other files Tom de Vries
2019-07-29 20:23   ` [PATCH 1/7] gdb: Add new -n flag to some info commands Tom Tromey
2019-07-27 16:23 ` [PATCH 6/7] gdb/fortran: Add new 'info modules' command Andrew Burgess
2019-07-27 16:45   ` Eli Zaretskii
2019-07-29 20:30   ` Tom Tromey
2019-07-27 16:23 ` [PATCH 7/7] gdb: Add new commands to list module variables and functions Andrew Burgess
2019-07-27 17:06   ` Eli Zaretskii
2019-07-27 16:23 ` [PATCH 4/7] gdb/fortran: Implement la_print_typedef for Fortran Andrew Burgess
2019-08-28 12:37   ` Andrew Burgess
2019-07-27 16:23 ` [PATCH 5/7] gdb/fortran: Don't include module symbols when searching for types Andrew Burgess
2019-08-28 12:37   ` Andrew Burgess
2019-08-29  9:09     ` Tom de Vries
2019-08-29 11:45       ` Tom de Vries
2019-08-29 12:47     ` [committed][gdb/testsuite] Fix gdb.fortran/info-types.exp regexp Tom de Vries

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=02a60599e2dff9efead7adbb070733c0f4c65f04.1564243858.git.andrew.burgess@embecosm.com \
    --to=andrew.burgess@embecosm.com \
    --cc=Richard.Bunt@arm.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