summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMark Wielaard <mjw@redhat.com>2011-02-23 17:26:09 +0100
committerMark Wielaard <mjw@redhat.com>2011-02-23 17:26:09 +0100
commit5135cc6617c06a79793fa0ab4a9120a0138cd1fb (patch)
tree577b5df33bc4214d70d715a40ba265559e40a3fa
parent0a1e1b0b0ab9fa795f3ed069c61e4ec9691b6d83 (diff)
DW_AT_*_file is allowed to be zero, meaning "no file".
-rw-r--r--libdw/c++/dwarf3
-rw-r--r--libdw/c++/line_info.cc20
2 files changed, 20 insertions, 3 deletions
diff --git a/libdw/c++/dwarf b/libdw/c++/dwarf
index 085f0f92..9553bd69 100644
--- a/libdw/c++/dwarf
+++ b/libdw/c++/dwarf
@@ -1126,7 +1126,8 @@ namespace elfutils
}
/* Return a value unique to us while we're in memory.
- This is a stable pointer into the Dwarf_Files data. */
+ This is a stable pointer into the Dwarf_Files data
+ or to a static empty string. */
inline uintptr_t identity () const
{
return (uintptr_t) name ();
diff --git a/libdw/c++/line_info.cc b/libdw/c++/line_info.cc
index e613c16b..df7a2172 100644
--- a/libdw/c++/line_info.cc
+++ b/libdw/c++/line_info.cc
@@ -61,6 +61,15 @@ stringform (Dwarf_Attribute *attr)
return false;
}
+/* Returns true if the attribute represents a valid zero udata.
+ This represents "no-file". */
+static bool
+zero_formudata (Dwarf_Attribute *attr)
+{
+ Dwarf_Word zero;
+ return dwarf_formudata (attr, &zero) == 0 && zero == 0;
+}
+
/* Mock up a dummy attribute with a special kludge that get_files groks.
We use these for source_file objects consed directly from an index
rather than from a real attribute. */
@@ -91,7 +100,7 @@ get_files (const Dwarf_Attribute *attr, Dwarf_Files **files, Dwarf_Word *idx)
Dwarf_Word
dwarf::source_file::mtime () const
{
- if (stringform (thisattr ()))
+ if (stringform (thisattr ()) || zero_formudata (thisattr ()))
return 0;
Dwarf_Files *files;
@@ -106,7 +115,7 @@ dwarf::source_file::mtime () const
Dwarf_Word
dwarf::source_file::size () const
{
- if (stringform (thisattr ()))
+ if (stringform (thisattr ()) || zero_formudata (thisattr ()))
return 0;
Dwarf_Files *files;
@@ -118,12 +127,16 @@ dwarf::source_file::size () const
return result;
}
+static const char *no_file = "";
+
const char *
dwarf::source_file::name () const
{
const char *result;
if (stringform (thisattr ()))
result = dwarf_formstring (thisattr ());
+ else if (zero_formudata (thisattr ()))
+ result = no_file;
else
{
Dwarf_Files *files;
@@ -154,6 +167,9 @@ dwarf::source_file::to_string () const
return plain_string (result);
}
+ if (zero_formudata (thisattr ()))
+ return plain_string (no_file);
+
Dwarf_Files *files;
Dwarf_Word idx;
xif (thisattr (), get_files (thisattr (), &files, &idx));