Bug 21630 - A this pointer DIE can be const
authorDodji Seketeli <dodji@redhat.com>
Mon, 26 Jun 2017 12:06:48 +0000 (14:06 +0200)
committerDodji Seketeli <dodji@redhat.com>
Tue, 4 Jul 2017 14:45:31 +0000 (16:45 +0200)
From what I have usually seen emitted by GCC, a "this pointer" is
represented by a DW_TAG_pointer_type.  If the "this pointer" is for a
const method, then it points to a const class type DIE.

But in, in this problem report, I am seeing a "this pointer"
represented by a DW_TAG_const_type that points to a
DW_TAG_pointer_type, which is itself points to a class type DIE.

The code of die_this_pointer_is_const needs to be adjusted so that it
doesn't expect only a DW_TAG_pointer_type.

This is what this patch does.

* src/abg-dwarf-reader.cc (die_this_pointer_is_const): If the DIE
is not a DW_TAG_pointer_type then don't crash.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
src/abg-dwarf-reader.cc

index ac3fb1bc51ea610b63b9c188c9ed0466d8d890ac..f980c75592c6eb0b5c7fb888ec98bf984c01b8eb 100644 (file)
@@ -8714,12 +8714,14 @@ static bool
 die_this_pointer_is_const(Dwarf_Die* die)
 {
   assert(die);
-  assert(dwarf_tag(die) == DW_TAG_pointer_type);
 
-  Dwarf_Die pointed_to_type_die;
-  if (die_die_attribute(die, DW_AT_type, pointed_to_type_die))
-    if (dwarf_tag(&pointed_to_type_die) == DW_TAG_const_type)
-      return true;
+  if (dwarf_tag(die) == DW_TAG_pointer_type)
+    {
+      Dwarf_Die pointed_to_type_die;
+      if (die_die_attribute(die, DW_AT_type, pointed_to_type_die))
+       if (dwarf_tag(&pointed_to_type_die) == DW_TAG_const_type)
+         return true;
+    }
 
   return false;
 }