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

Unified Diff: runtime/bin/main.cc

Issue 10831005: Emit symbol maps for compiled code for use by the Linux perf tool. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: pre-review changes Created 8 years, 5 months 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 | « no previous file | runtime/bin/process.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/bin/main.cc
diff --git a/runtime/bin/main.cc b/runtime/bin/main.cc
index 7bcd30caa3dee129929b76f5f5abc1237af7a8d9..c96ee87bf51a60ac0fdd359b64887d2b6a43d317 100644
--- a/runtime/bin/main.cc
+++ b/runtime/bin/main.cc
@@ -35,6 +35,11 @@ static const char* original_working_directory = NULL;
static CommandLineOptions* import_map_options = NULL;
+// Global state that indicates whether perf_events symbol information
+// is to be generated or not.
+static File* perf_events_symbols_file = NULL;
+
+
// Global state that indicates whether pprof symbol information is
// to be generated or not.
static const char* generate_pprof_symbols_filename = NULL;
@@ -128,6 +133,23 @@ static void ProcessDebugOption(const char* port) {
}
+static void ProcessPerfEventsOption(const char* option) {
+ ASSERT(option != NULL);
+ if (perf_events_symbols_file == NULL) {
+#if defined(TARGET_OS_LINUX)
+ const char* format = "/tmp/perf-%ld.map";
+ intptr_t pid = Process::CurrentProcessId();
+ intptr_t len = snprintf(NULL, 0, format, pid);
+ char* filename = new char[len + 1];
+ snprintf(filename, len + 1, format, pid);
+ perf_events_symbols_file = File::Open(filename, File::kWriteTruncate);
+ ASSERT(perf_events_symbols_file != NULL);
+ delete[] filename;
+#endif
siva 2012/07/25 22:25:23 Could you abstract this away into os.h as OpenPerf
cshapiro 2012/07/25 22:52:54 I do not feel good about that as Linux is the only
siva 2012/07/25 23:19:52 Sorry I meant platform.h which is in the 'bin' dir
cshapiro 2012/07/26 00:14:19 Per our off-line conversation, I will add a TODO r
+ }
+}
+
+
static void ProcessPprofOption(const char* filename) {
ASSERT(filename != NULL);
generate_pprof_symbols_filename = filename;
@@ -154,6 +176,7 @@ static struct {
{ "--break_at=", ProcessBreakpointOption },
{ "--compile_all", ProcessCompileAllOption },
{ "--debug", ProcessDebugOption },
+ { "--generate_perf_events_symbols", ProcessPerfEventsOption },
{ "--generate_pprof_symbols=", ProcessPprofOption },
{ "--import_map=", ProcessImportMapOption },
{ "--package-root=", ProcessPackageRootOption },
@@ -178,6 +201,12 @@ static bool ProcessMainOptions(const char* option) {
}
+static void WriteToPerfEventsFile(const char* buffer, int64_t num_bytes) {
+ ASSERT(perf_events_symbols_file != NULL);
+ perf_events_symbols_file->WriteFully(buffer, num_bytes);
+}
+
+
static void WriteToFlowGraphFile(const char* buffer, int64_t num_bytes) {
ASSERT(flow_graph_file != NULL);
flow_graph_file->WriteFully(buffer, num_bytes);
@@ -217,6 +246,11 @@ static int ParseArguments(int argc,
i++;
}
}
+
+ if (perf_events_symbols_file != NULL) {
+ Dart_InitPerfEventsSupport(&WriteToPerfEventsFile);
+ }
+
if (generate_pprof_symbols_filename != NULL) {
Dart_InitPprofSupport();
}
« no previous file with comments | « no previous file | runtime/bin/process.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698