Use more compact encoding for DWARF flags.

Use DW_FORM_flag_present when possible (new in DWARF4).
This avoids encoding the value in entries if it is always true.

Change-Id: Ib31908399b4d0fea7f7c175240aa9b0d6d473b5a
diff --git a/compiler/dwarf/debug_info_entry_writer.h b/compiler/dwarf/debug_info_entry_writer.h
index e5bbed3..5e3d2c8 100644
--- a/compiler/dwarf/debug_info_entry_writer.h
+++ b/compiler/dwarf/debug_info_entry_writer.h
@@ -164,6 +164,10 @@
     this->PushUint8(value ? 1 : 0);
   }
 
+  void WriteFlagPresent(Attribute attrib) {
+    AddAbbrevAttribute(attrib, DW_FORM_flag_present);
+  }
+
   void WriteRef4(Attribute attrib, uint32_t cu_offset) {
     AddAbbrevAttribute(attrib, DW_FORM_ref4);
     this->PushUint32(cu_offset);
diff --git a/compiler/elf_writer_debug.cc b/compiler/elf_writer_debug.cc
index 6a69d59..b93c9df 100644
--- a/compiler/elf_writer_debug.cc
+++ b/compiler/elf_writer_debug.cc
@@ -516,7 +516,7 @@
           // Declare the class that owns this method.
           size_t class_offset = StartClassTag(dex_class_desc);
           info_.UpdateUint32(type_attrib_offset, class_offset);
-          info_.WriteFlag(DW_AT_declaration, true);
+          info_.WriteFlagPresent(DW_AT_declaration);
           // Check that each class is defined only once.
           bool unique = owner_->defined_dex_classes_.insert(dex_class_desc).second;
           CHECK(unique) << "Redefinition of " << dex_class_desc;
@@ -542,7 +542,7 @@
         if (!is_static) {
           info_.StartTag(DW_TAG_formal_parameter);
           WriteName("this");
-          info_.WriteFlag(DW_AT_artificial, true);
+          info_.WriteFlagPresent(DW_AT_artificial);
           WriteLazyType(dex_class_desc);
           if (dex_code != nullptr) {
             // Write the stack location of the parameter.
@@ -660,7 +660,7 @@
             std::string tmp_storage;
             const char* base_class_desc = base_class->GetDescriptor(&tmp_storage);
             base_class_declaration_offset = StartClassTag(base_class_desc);
-            info_.WriteFlag(DW_AT_declaration, true);
+            info_.WriteFlagPresent(DW_AT_declaration);
             WriteLinkageName(base_class);
             EndClassTag();
           }
@@ -682,7 +682,7 @@
             info_.StartTag(DW_TAG_member);
             WriteName(".dynamic_type");
             WriteLazyType(sizeof(uintptr_t) == 8 ? "J" : "I");
-            info_.WriteFlag(DW_AT_artificial, true);
+            info_.WriteFlagPresent(DW_AT_artificial);
             // Create DWARF expression to get the value of the methods_ field.
             Expression expr(&expr_buffer);
             // The address of the object has been implicitly pushed on the stack.
@@ -960,7 +960,7 @@
       if (desc[0] == 'L') {
         // Class type. For example: Lpackage/name;
         size_t class_offset = StartClassTag(desc.c_str());
-        info_.WriteFlag(DW_AT_declaration, true);
+        info_.WriteFlagPresent(DW_AT_declaration);
         EndClassTag();
         // Reference to the class type.
         offset = info_.StartTag(DW_TAG_reference_type);
@@ -971,7 +971,7 @@
         size_t element_type = WriteTypeDeclaration(desc.substr(1));
         CloseNamespacesAboveDepth(0);  // Declare in root namespace.
         size_t array_type = info_.StartTag(DW_TAG_array_type);
-        info_.WriteFlag(DW_AT_declaration, true);
+        info_.WriteFlagPresent(DW_AT_declaration);
         info_.WriteRef(DW_AT_type, element_type);
         info_.EndTag();
         offset = info_.StartTag(DW_TAG_reference_type);