aboutsummaryrefslogtreecommitdiff
path: root/gdb
diff options
context:
space:
mode:
authorJoel Brobecker <brobecker@gnat.com>2004-04-16 04:31:25 +0000
committerJoel Brobecker <brobecker@gnat.com>2004-04-16 04:31:25 +0000
commitfdc860a37ed026dce4455748cda5cf50ff680ec7 (patch)
treec4e4e70b50ec9d682cc95e5d99607a7936bd46c2 /gdb
parent57a1784ed8fb404cd444134a16921a40163692ec (diff)
downloadgdb-fdc860a37ed026dce4455748cda5cf50ff680ec7.zip
gdb-fdc860a37ed026dce4455748cda5cf50ff680ec7.tar.gz
gdb-fdc860a37ed026dce4455748cda5cf50ff680ec7.tar.bz2
* dwarf2read.c (dwarf2_attribute_true_p): New function.
(die_is_declaration): Use the function above.
Diffstat (limited to 'gdb')
-rw-r--r--gdb/ChangeLog5
-rw-r--r--gdb/dwarf2read.c24
2 files changed, 27 insertions, 2 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 1861281..0335fcc 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,10 @@
2004-04-15 Joel Brobecker <brobecker@gnat.com>
+ * dwarf2read.c (dwarf2_attribute_true_p): New function.
+ (die_is_declaration): Use the function above. Add comment.
+
+2004-04-15 Joel Brobecker <brobecker@gnat.com>
+
* dwarf2read.c (read_structure_scope): Identify stub types
using die_is_declaration() only.
diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
index 09b0cc5..8f98898 100644
--- a/gdb/dwarf2read.c
+++ b/gdb/dwarf2read.c
@@ -677,6 +677,9 @@ static void set_cu_language (unsigned int, struct dwarf2_cu *);
static struct attribute *dwarf2_attr (struct die_info *, unsigned int,
struct dwarf2_cu *);
+static int dwarf2_attribute_true_p (struct die_info *die, unsigned name,
+ struct dwarf2_cu *cu);
+
static int die_is_declaration (struct die_info *, struct dwarf2_cu *cu);
static struct die_info *die_specification (struct die_info *die,
@@ -5139,11 +5142,28 @@ dwarf2_attr (struct die_info *die, unsigned int name, struct dwarf2_cu *cu)
return NULL;
}
+/* Return non-zero iff the attribute NAME is defined for the given DIE,
+ and holds a non-zero value. */
+
+static int
+dwarf2_attribute_true_p (struct die_info *die, unsigned name,
+ struct dwarf2_cu *cu)
+{
+ struct attribute *attr = dwarf2_attr (die, name, cu);
+
+ return (attr && DW_UNSND (attr));
+}
+
static int
die_is_declaration (struct die_info *die, struct dwarf2_cu *cu)
{
- return (dwarf2_attr (die, DW_AT_declaration, cu)
- && ! dwarf2_attr (die, DW_AT_specification, cu));
+ /* A DIE is a declaration if it has a DW_AT_declaration attribute
+ which value is non-zero. However, we have to be careful of DIEs
+ with a DW_AT_specification attribute, because dwarf2_attribute_p()
+ follows this attribute, and therefore might cause us to find a
+ DW_AT_declaration attribute, but that belongs to a different DIE. */
+ return (dwarf2_attribute_true_p (die, DW_AT_declaration, cu)
+ && ! dwarf2_attribute_true_p (die, DW_AT_specification, cu));
}
/* Return the die giving the specification for DIE, if there is