diff options
author | Mark Wielaard <mjw@redhat.com> | 2011-02-23 17:26:09 +0100 |
---|---|---|
committer | Mark Wielaard <mjw@redhat.com> | 2011-03-16 12:38:27 +0100 |
commit | 35727d56106182c7513c1d4c5f784cb087d2f4ec (patch) | |
tree | 0206671c9eb2a2773da4c159b191ca33d880e391 | |
parent | c8f5a7d9725e882eed142722a4b9e097c16fd88f (diff) | |
download | elfutils-35727d56106182c7513c1d4c5f784cb087d2f4ec.tar.gz |
DW_AT_*_file is allowed to be zero, meaning "no file".
-rw-r--r-- | libdw/c++/dwarf | 3 | ||||
-rw-r--r-- | libdw/c++/line_info.cc | 20 |
2 files changed, 20 insertions, 3 deletions
diff --git a/libdw/c++/dwarf b/libdw/c++/dwarf index 8342dc78..c386f0ed 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)); |