Add pprof support to skydb

After this CL, we're able to capture pprof profiles, but we're not quite able
to symbolize them properly.

R=eseidel@chromium.org

Review URL: https://codereview.chromium.org/854833004
This commit is contained in:
Adam Barth 2015-01-15 16:34:16 -08:00
parent 656c44bafb
commit ffa677551e
3 changed files with 20 additions and 1 deletions

View File

@ -15,6 +15,7 @@ mojo_native_application("prompt") {
deps = [
"//base",
"//base/allocator",
"//mojo/application",
"//mojo/common",
"//mojo/public/cpp/bindings",

View File

@ -5,7 +5,7 @@
#include <algorithm>
#include "base/bind.h"
#include "base/files/file_path.h"
#include "base/debug/profiler.h"
#include "base/memory/weak_ptr.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/stringprintf.h"
@ -91,6 +91,10 @@ class Prompt : public mojo::ApplicationDelegate,
Quit(connection_id);
else if (info.path == "/load")
Load(connection_id, info.data);
else if (info.path == "/start_profiling")
StartProfiling(connection_id);
else if (info.path == "/stop_profiling")
StopProfiling(connection_id);
else {
Help(info.path, connection_id);
}
@ -172,6 +176,16 @@ class Prompt : public mojo::ApplicationDelegate,
Respond(connection_id, trace);
}
void StartProfiling(int connection_id) {
base::debug::StartProfiling("sky_viewer.pprof");
Respond(connection_id, "Starting profiling (type 'stop_profiling' to stop");
}
void StopProfiling(int connection_id) {
base::debug::StopProfiling();
Respond(connection_id, "Stopped profiling");
}
bool is_tracing_;
DebuggerPtr debugger_;
tracing::TraceCoordinatorPtr tracing_;

View File

@ -387,6 +387,10 @@ class SkyDebugger(object):
'reload the current page')
self._add_basic_command(subparsers, 'inspect', '/inspect',
'stop the running sky instance')
self._add_basic_command(subparsers, 'start_profiling', '/start_profiling',
'starts profiling the running sky instance (Linux only)')
self._add_basic_command(subparsers, 'stop_profiling', '/stop_profiling',
'stios profiling the running sky instance (Linux only)')
load_parser = subparsers.add_parser('load',
help='load a new page in the currently running sky')