From: Mikko Harju Date: Wed, 12 Oct 2011 06:41:10 +0000 (+0300) Subject: Fix V8 heap snapshot in profiler service X-Git-Tag: qt-v5.0.0-alpha1~1392 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=bdc94b43a90d003755255c59d94569b4a79c1126;p=profile%2Fivi%2Fqtdeclarative.git 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 --- 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); }