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

Side by Side Diff: runtime/bin/main.cc

Issue 11490026: Move generate_perf_events_symbols flag to VM (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Changing email to @google.com instead of @chromium.org Created 8 years 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | runtime/vm/code_observers.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include <stdlib.h> 5 #include <stdlib.h>
6 #include <string.h> 6 #include <string.h>
7 #include <stdio.h> 7 #include <stdio.h>
8 8
9 #include "include/dart_api.h" 9 #include "include/dart_api.h"
10 #include "include/dart_debugger_api.h" 10 #include "include/dart_debugger_api.h"
11 11
12 #include "bin/builtin.h" 12 #include "bin/builtin.h"
13 #include "bin/dartutils.h" 13 #include "bin/dartutils.h"
14 #include "bin/dbg_connection.h" 14 #include "bin/dbg_connection.h"
15 #include "bin/directory.h" 15 #include "bin/directory.h"
16 #include "bin/eventhandler.h" 16 #include "bin/eventhandler.h"
17 #include "bin/extensions.h" 17 #include "bin/extensions.h"
18 #include "bin/file.h" 18 #include "bin/file.h"
19 #include "bin/isolate_data.h" 19 #include "bin/isolate_data.h"
20 #include "bin/log.h" 20 #include "bin/log.h"
21 #include "bin/platform.h" 21 #include "bin/platform.h"
22 #include "bin/process.h" 22 #include "bin/process.h"
23 #include "platform/globals.h" 23 #include "platform/globals.h"
24 24
25 // snapshot_buffer points to a snapshot if we link in a snapshot otherwise 25 // snapshot_buffer points to a snapshot if we link in a snapshot otherwise
26 // it is initialized to NULL. 26 // it is initialized to NULL.
27 extern const uint8_t* snapshot_buffer; 27 extern const uint8_t* snapshot_buffer;
28 28
29
30 // Global state that indicates whether perf_events symbol information
31 // is to be generated or not.
32 static File* perf_events_symbols_file = NULL;
33
34
35 // Global state that indicates whether pprof symbol information is 29 // Global state that indicates whether pprof symbol information is
36 // to be generated or not. 30 // to be generated or not.
37 static const char* generate_pprof_symbols_filename = NULL; 31 static const char* generate_pprof_symbols_filename = NULL;
38 32
39 33
40 // Global state that stores a pointer to the application script snapshot. 34 // Global state that stores a pointer to the application script snapshot.
41 static bool use_script_snapshot = false; 35 static bool use_script_snapshot = false;
42 static File* snapshot_file = NULL; 36 static File* snapshot_file = NULL;
43 37
44 38
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 if (debug_port == 0) { 140 if (debug_port == 0) {
147 Log::PrintErr("unrecognized --debug option syntax. " 141 Log::PrintErr("unrecognized --debug option syntax. "
148 "Use --debug[:<port number>]\n"); 142 "Use --debug[:<port number>]\n");
149 return false; 143 return false;
150 } 144 }
151 breakpoint_at = "main"; 145 breakpoint_at = "main";
152 start_debugger = true; 146 start_debugger = true;
153 return true; 147 return true;
154 } 148 }
155 149
156
157 static bool ProcessPerfEventsOption(const char* option) {
158 ASSERT(option != NULL);
159 if (perf_events_symbols_file == NULL) {
160 // TODO(cshapiro): eliminate the #ifdef by moving this code to a
161 // Linux specific source file.
162 #if defined(TARGET_OS_LINUX)
163 const char* format = "/tmp/perf-%ld.map";
164 intptr_t pid = Process::CurrentProcessId();
165 intptr_t len = snprintf(NULL, 0, format, pid);
166 char* filename = new char[len + 1];
167 snprintf(filename, len + 1, format, pid);
168 perf_events_symbols_file = File::Open(filename, File::kWriteTruncate);
169 ASSERT(perf_events_symbols_file != NULL);
170 delete[] filename;
171 #endif
172 }
173 return true;
174 }
175
176
177 static bool ProcessPprofOption(const char* filename) { 150 static bool ProcessPprofOption(const char* filename) {
178 ASSERT(filename != NULL); 151 ASSERT(filename != NULL);
179 generate_pprof_symbols_filename = filename; 152 generate_pprof_symbols_filename = filename;
180 return true; 153 return true;
181 } 154 }
182 155
183 156
184 static bool ProcessScriptSnapshotOption(const char* filename) { 157 static bool ProcessScriptSnapshotOption(const char* filename) {
185 if (filename != NULL && strlen(filename) != 0) { 158 if (filename != NULL && strlen(filename) != 0) {
186 use_script_snapshot = true; 159 use_script_snapshot = true;
(...skipping 12 matching lines...) Expand all
199 { "--help", ProcessHelpOption }, 172 { "--help", ProcessHelpOption },
200 { "-h", ProcessHelpOption }, 173 { "-h", ProcessHelpOption },
201 { "--verbose", ProcessVerboseOption }, 174 { "--verbose", ProcessVerboseOption },
202 { "-v", ProcessVerboseOption }, 175 { "-v", ProcessVerboseOption },
203 { "--package-root=", ProcessPackageRootOption }, 176 { "--package-root=", ProcessPackageRootOption },
204 { "-p", ProcessPackageRootOption }, 177 { "-p", ProcessPackageRootOption },
205 // VM specific options to the standalone dart program. 178 // VM specific options to the standalone dart program.
206 { "--break_at=", ProcessBreakpointOption }, 179 { "--break_at=", ProcessBreakpointOption },
207 { "--compile_all", ProcessCompileAllOption }, 180 { "--compile_all", ProcessCompileAllOption },
208 { "--debug", ProcessDebugOption }, 181 { "--debug", ProcessDebugOption },
209 { "--generate_perf_events_symbols", ProcessPerfEventsOption },
210 { "--generate_pprof_symbols=", ProcessPprofOption }, 182 { "--generate_pprof_symbols=", ProcessPprofOption },
211 { "--use_script_snapshot=", ProcessScriptSnapshotOption }, 183 { "--use_script_snapshot=", ProcessScriptSnapshotOption },
212 { NULL, NULL } 184 { NULL, NULL }
213 }; 185 };
214 186
215 187
216 static bool ProcessMainOptions(const char* option) { 188 static bool ProcessMainOptions(const char* option) {
217 int i = 0; 189 int i = 0;
218 const char* name = main_options[0].option_name; 190 const char* name = main_options[0].option_name;
219 while (name != NULL) { 191 while (name != NULL) {
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
299 const char* kPrintFlags2 = "--print_flags"; 271 const char* kPrintFlags2 = "--print_flags";
300 if ((strncmp(argv[i], kPrintFlags1, strlen(kPrintFlags1)) == 0) || 272 if ((strncmp(argv[i], kPrintFlags1, strlen(kPrintFlags1)) == 0) ||
301 (strncmp(argv[i], kPrintFlags2, strlen(kPrintFlags2)) == 0)) { 273 (strncmp(argv[i], kPrintFlags2, strlen(kPrintFlags2)) == 0)) {
302 *print_flags_seen = true; 274 *print_flags_seen = true;
303 } 275 }
304 vm_options->AddArgument(argv[i]); 276 vm_options->AddArgument(argv[i]);
305 i++; 277 i++;
306 } 278 }
307 } 279 }
308 280
309 if (perf_events_symbols_file != NULL) {
310 Dart_InitPerfEventsSupport(perf_events_symbols_file);
311 }
312
313 if (generate_pprof_symbols_filename != NULL) { 281 if (generate_pprof_symbols_filename != NULL) {
314 Dart_InitPprofSupport(); 282 Dart_InitPprofSupport();
315 } 283 }
316 284
317 // Get the script name. 285 // Get the script name.
318 if (i < argc) { 286 if (i < argc) {
319 *script_name = argv[i]; 287 *script_name = argv[i];
320 i++; 288 i++;
321 } else { 289 } else {
322 return -1; 290 return -1;
(...skipping 466 matching lines...) Expand 10 before | Expand all | Expand 10 after
789 Dart_ShutdownIsolate(); 757 Dart_ShutdownIsolate();
790 // Terminate process exit-code handler. 758 // Terminate process exit-code handler.
791 Process::TerminateExitCodeHandler(); 759 Process::TerminateExitCodeHandler();
792 // Free copied argument strings if converted. 760 // Free copied argument strings if converted.
793 if (argv_converted) { 761 if (argv_converted) {
794 for (int i = 0; i < argc; i++) free(argv[i]); 762 for (int i = 0; i < argc; i++) free(argv[i]);
795 } 763 }
796 764
797 return 0; 765 return 0;
798 } 766 }
OLDNEW
« no previous file with comments | « no previous file | runtime/vm/code_observers.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698