Emit some additional debug info for java.lang.String
The value part of java.lang.String is not a proper ArtField so the
default debug info writing code don't emit debug info about that. This
CL add logic to emit debug info for a new member what represents the
first element of the underlying string data what can be used by the
consumer of the debug info to display the value of the string.
Change-Id: Ibc11b143e79aa8866000d02922bcd6069cfcd4c2
diff --git a/compiler/elf_writer_debug.cc b/compiler/elf_writer_debug.cc
index dd50f69..4eb1ca2 100644
--- a/compiler/elf_writer_debug.cc
+++ b/compiler/elf_writer_debug.cc
@@ -653,6 +653,21 @@
info_.EndTag(); // DW_TAG_member.
}
+ if (type->IsStringClass()) {
+ // Emit debug info about an artifical class member for java.lang.String which represents
+ // the first element of the data stored in a string instance. Consumers of the debug
+ // info will be able to read the content of java.lang.String based on the count (real
+ // field) and based on the location of this data member.
+ info_.StartTag(DW_TAG_member);
+ WriteName("value");
+ // We don't support fields with C like array types so we just say its type is java char.
+ WriteLazyType("C"); // char.
+ info_.WriteUdata(DW_AT_data_member_location,
+ mirror::String::ValueOffset().Uint32Value());
+ info_.WriteSdata(DW_AT_accessibility, DW_ACCESS_private);
+ info_.EndTag(); // DW_TAG_member.
+ }
+
EndClassTag(desc);
}
}
@@ -883,6 +898,8 @@
info_.EndTag();
} else {
// Primitive types.
+ DCHECK_EQ(desc.size(), 1u);
+
const char* name;
uint32_t encoding;
uint32_t byte_size;