Chromium Code Reviews| Index: Source/platform/heap/Heap.cpp |
| diff --git a/Source/platform/heap/Heap.cpp b/Source/platform/heap/Heap.cpp |
| index 5d6ff063e6de245e9a040cce3ef058e9371e1213..72db0042679745f777c1af6f30db7bd97e194e8e 100644 |
| --- a/Source/platform/heap/Heap.cpp |
| +++ b/Source/platform/heap/Heap.cpp |
| @@ -1472,10 +1472,12 @@ public: |
| static void dumpPathToObjectFromObjectGraph(const ObjectGraph& graph, uintptr_t target) |
| { |
| - fprintf(stderr, "Path to %lx of %s\n", target, classOf(reinterpret_cast<const void*>(target)).ascii().data()); |
| ObjectGraph::const_iterator it = graph.find(target); |
| + if (it == graph.end()) |
| + return; |
| + fprintf(stderr, "Path to %lx of %s\n", target, classOf(reinterpret_cast<const void*>(target)).ascii().data()); |
| while (it != graph.end()) { |
| - fprintf(stderr, "<- %lx of %s\n", it->value.first, it->value.second.ascii().data()); |
| + fprintf(stderr, "<- %lx of %s\n", it->value.first, it->value.second.utf8().data()); |
| it = graph.find(it->value.first); |
| } |
| fprintf(stderr, "\n"); |
| @@ -1607,6 +1609,37 @@ void Heap::dumpPathToObjectOnNextGC(void* p) |
| { |
| static_cast<MarkingVisitor*>(s_markingVisitor)->dumpPathToObjectOnNextGC(p); |
| } |
| + |
| +String Heap::createBacktraceString() |
| +{ |
| + // Skip the followings: |
| + // - WTFGetBacktrace |
| + // - Heap::createBacktraceString |
| + // - Persistent::recordBacktrace |
| + // - Persistent::Persistent |
| + const int framesToSkip = 4; |
|
haraken
2014/06/16 01:15:40
It would be better if we could determine this numb
tkent
2014/06/16 02:34:47
Done.
|
| + const int framesToShow = 4; |
| + typedef void* FramePointer; |
| + FramePointer* stackFrame = static_cast<FramePointer*>(alloca((framesToShow + framesToSkip) * sizeof(FramePointer))); |
| + int stackFrameSize = framesToShow + framesToSkip; |
| + WTFGetBacktrace(stackFrame, &stackFrameSize); |
| + |
| + StringBuilder builder; |
| + builder.append("Persistent"); |
| + bool gotFirstName = false; |
| + for (int i = framesToSkip; i < stackFrameSize; ++i) { |
| + FrameToNameScope frameToName(stackFrame[i]); |
| + if (!frameToName.nullableName()) |
| + continue; |
| + if (!gotFirstName) { |
| + gotFirstName = true; |
| + builder.append(" ... Backtrace:"); |
| + } |
| + builder.append("\n\t"); |
| + builder.append(frameToName.nullableName()); |
| + } |
| + return builder.toString().replace("WebCore::", ""); |
| +} |
| #endif |
| void Heap::pushTraceCallback(void* object, TraceCallback callback) |