Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(199)

Unified Diff: runtime/vm/heap_profiler.cc

Issue 11478012: Provide a mechanism for dumping of heap profiles on predefined events. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: cosmetic changes Created 8 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/vm/heap.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/heap_profiler.cc
diff --git a/runtime/vm/heap_profiler.cc b/runtime/vm/heap_profiler.cc
index 48d24c722b68ac70a13fdd28877c7e4cb0b7309a..86b6dfc17b7e4f3d5a45e1513b6643b98b8f7fa4 100644
--- a/runtime/vm/heap_profiler.cc
+++ b/runtime/vm/heap_profiler.cc
@@ -400,8 +400,17 @@ void HeapProfiler::WriteLoadClass(const RawClass* raw_class) {
record.WritePointer(raw_class);
// stack trace serial number
record.Write32(0);
- ASSERT(raw_class->ptr()->name_ != String::null());
- record.WritePointer(StringId(raw_class->ptr()->name_));
+ // class name string ID
+ if (raw_class->ptr()->name_ != String::null()) {
+ record.WritePointer(StringId(raw_class->ptr()->name_));
+ } else {
+ const char* format = "<an unnamed class with id %d>";
+ intptr_t len = OS::SNPrint(NULL, 0, format, raw_class->ptr()->id_);
+ char* str = new char[len + 1];
+ OS::SNPrint(str, len + 1, format, raw_class->ptr()->id_);
+ record.WritePointer(StringId(str));
+ delete[] str;
+ }
}
@@ -600,8 +609,9 @@ void HeapProfiler::WriteInstanceDump(const RawObject* raw_obj) {
RawField* raw_field =
reinterpret_cast<RawField*>(raw_array->ptr()->data()[i]);
if (!Field::StaticBit::decode(raw_field->ptr()->kind_bits_)) {
- intptr_t offset =
+ intptr_t offset_in_words =
Smi::Value(reinterpret_cast<RawSmi*>(raw_field->ptr()->value_));
+ intptr_t offset = offset_in_words * kWordSize;
RawObject* ptr = *reinterpret_cast<RawObject**>(base + offset);
sub.WritePointer(ObjectId(ptr));
}
« no previous file with comments | « runtime/vm/heap.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698