summaryrefslogtreecommitdiffstats
path: root/runtime/hprof
diff options
context:
space:
mode:
authorJeff Hao <jeffhao@google.com>2015-05-14 17:19:15 -0700
committerJeff Hao <jeffhao@google.com>2015-05-14 17:19:15 -0700
commita32474e8fe607eeee783cf681b70efbcb569de12 (patch)
tree27c395291e8ed8f24ffd94e26049b3fc382c8aee /runtime/hprof
parent039ab3d4b0dcb008f7598c87f9d4569ee94e5690 (diff)
downloadart-a32474e8fe607eeee783cf681b70efbcb569de12.zip
art-a32474e8fe607eeee783cf681b70efbcb569de12.tar.gz
art-a32474e8fe607eeee783cf681b70efbcb569de12.tar.bz2
In hprof, use an address within string for char array of empty string.
Bug: 21089461 Change-Id: I203345caf74fba2e9bf0549256147d84d1bb829e
Diffstat (limited to 'runtime/hprof')
-rw-r--r--runtime/hprof/hprof.cc11
1 files changed, 9 insertions, 2 deletions
diff --git a/runtime/hprof/hprof.cc b/runtime/hprof/hprof.cc
index 868cb23..efead51 100644
--- a/runtime/hprof/hprof.cc
+++ b/runtime/hprof/hprof.cc
@@ -1150,13 +1150,20 @@ void Hprof::DumpHeapInstanceObject(mirror::Object* obj, mirror::Class* klass) {
// Output native value character array for strings.
if (orig_klass->IsStringClass()) {
mirror::String* s = obj->AsString();
- __ AddObjectId(reinterpret_cast<mirror::Object*>(s->GetValue()));
+ mirror::Object* value;
+ if (s->GetLength() == 0) {
+ // If string is empty, use an object-aligned address within the string for the value.
+ value = reinterpret_cast<mirror::Object*>(reinterpret_cast<uintptr_t>(s) + kObjectAlignment);
+ } else {
+ value = reinterpret_cast<mirror::Object*>(s->GetValue());
+ }
+ __ AddObjectId(value);
// Patch the instance field length.
__ UpdateU4(size_patch_offset, output_->Length() - (size_patch_offset + 4));
__ AddU1(HPROF_PRIMITIVE_ARRAY_DUMP);
- __ AddObjectId(reinterpret_cast<mirror::Object*>(s->GetValue()));
+ __ AddObjectId(value);
__ AddU4(StackTraceSerialNumber(obj));
__ AddU4(s->GetLength());
__ AddU1(hprof_basic_char);