From bdc94b43a90d003755255c59d94569b4a79c1126 Mon Sep 17 00:00:00 2001 From: Mikko Harju Date: Wed, 12 Oct 2011 09:41:10 +0300 Subject: [PATCH] Fix V8 heap snapshot in profiler service Fixes the message parsing (use the option also for heap snapshot commands). Do not directly serialize the snapshot to the QByteArray under QDataStream. Change-Id: I3ad15a2debd6c2f912854610b6434744e0acd788 Reviewed-by: Christiaan Janssen --- src/declarative/debugger/qv8profilerservice.cpp | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/src/declarative/debugger/qv8profilerservice.cpp b/src/declarative/debugger/qv8profilerservice.cpp index 0afa4fa..9195729 100644 --- a/src/declarative/debugger/qv8profilerservice.cpp +++ b/src/declarative/debugger/qv8profilerservice.cpp @@ -160,14 +160,12 @@ void QV8ProfilerService::messageReceived(const QByteArray &message) } if (command == "V8SNAPSHOT") { - QByteArray snapshotType; - ds >> snapshotType; - - if (snapshotType == "full") - d->takeSnapshot(v8::HeapSnapshot::kFull); - } else if (command == "deletesnapshots") { + if (option == "full") + d->takeSnapshot(v8::HeapSnapshot::kFull); + else if (option == "delete") { v8::HeapProfiler::DeleteAllSnapshots(); } + } QDeclarativeDebugService::messageReceived(message); } @@ -218,14 +216,14 @@ void QV8ProfilerServicePrivate::takeSnapshot(v8::HeapSnapshot::Type snapshotType v8::HandleScope scope; v8::Local title = v8::String::New(""); + QByteArray jsonSnapshot; + ByteArrayOutputStream bos(&jsonSnapshot); const v8::HeapSnapshot *snapshot = v8::HeapProfiler::TakeSnapshot(title, snapshotType); + snapshot->Serialize(&bos, v8::HeapSnapshot::kJSON); QByteArray data; QDataStream ds(&data, QIODevice::WriteOnly); - ds << (int)QV8ProfilerService::V8Snapshot; - - ByteArrayOutputStream bos(&data); - snapshot->Serialize(&bos, v8::HeapSnapshot::kJSON); + ds << (int)QV8ProfilerService::V8Snapshot << jsonSnapshot; q->sendMessage(data); } -- 2.7.4