summaryrefslogtreecommitdiffstats
path: root/runtime/hprof
diff options
context:
space:
mode:
authorCalin Juravle <calin@google.com>2014-07-04 16:24:03 +0100
committerCalin Juravle <calin@google.com>2014-07-17 21:06:19 +0100
commit3280517651195602253ed92a2749964e96cad27e (patch)
tree9e91047bf950a7eddbb551534dc10078be74251c /runtime/hprof
parent6dfa4188d5cbe7cb1c89011cda80e1c261ae30f0 (diff)
downloadart-3280517651195602253ed92a2749964e96cad27e.zip
art-3280517651195602253ed92a2749964e96cad27e.tar.gz
art-3280517651195602253ed92a2749964e96cad27e.tar.bz2
Fix identifier size in the heap dump.
We're using addresses as IDs and previously we would have written sizeof(void*) as the identifier size in the header. Heap references are actually uint32_t so writting 4 bytes should be enough. Bug: 16016862 Change-Id: I785abf5030681b6009370b7b2d7552e8b4b54e67
Diffstat (limited to 'runtime/hprof')
-rw-r--r--runtime/hprof/hprof.cc8
1 files changed, 6 insertions, 2 deletions
diff --git a/runtime/hprof/hprof.cc b/runtime/hprof/hprof.cc
index 7e3b6ba..8c0f3fb 100644
--- a/runtime/hprof/hprof.cc
+++ b/runtime/hprof/hprof.cc
@@ -633,8 +633,12 @@ class Hprof {
// U1: NUL-terminated magic string.
fwrite(magic, 1, sizeof(magic), header_fp_);
- // U4: size of identifiers. We're using addresses as IDs, so make sure a pointer fits.
- U4_TO_BUF_BE(buf, 0, sizeof(void*));
+ // U4: size of identifiers. We're using addresses as IDs and our heap references are stored
+ // as uint32_t.
+ // Note of warning: hprof-conv hard-codes the size of identifiers to 4.
+ COMPILE_ASSERT(sizeof(mirror::HeapReference<mirror::Object>) == sizeof(uint32_t),
+ UnexpectedHeapReferenceSize);
+ U4_TO_BUF_BE(buf, 0, sizeof(uint32_t));
fwrite(buf, 1, sizeof(uint32_t), header_fp_);
// The current time, in milliseconds since 0:00 GMT, 1/1/70.