OLD | NEW |
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 "vm/globals.h" | 5 #include "vm/globals.h" |
6 #if defined(TARGET_OS_LINUX) | 6 #if defined(TARGET_OS_LINUX) |
7 | 7 |
8 #include "vm/os.h" | 8 #include "vm/os.h" |
9 | 9 |
10 #include <errno.h> // NOLINT | 10 #include <errno.h> // NOLINT |
(...skipping 28 matching lines...) Expand all Loading... |
39 "Writes pprof events symbols to the provided file"); | 39 "Writes pprof events symbols to the provided file"); |
40 | 40 |
41 class LowLevelProfileCodeObserver : public CodeObserver { | 41 class LowLevelProfileCodeObserver : public CodeObserver { |
42 public: | 42 public: |
43 LowLevelProfileCodeObserver() { | 43 LowLevelProfileCodeObserver() { |
44 Dart_FileOpenCallback file_open = Isolate::file_open_callback(); | 44 Dart_FileOpenCallback file_open = Isolate::file_open_callback(); |
45 if (file_open == NULL) { | 45 if (file_open == NULL) { |
46 return; | 46 return; |
47 } | 47 } |
48 const char* filename = "v8.log.ll"; | 48 const char* filename = "v8.log.ll"; |
49 log_file_ = (*file_open)(filename); | 49 log_file_ = (*file_open)(filename, true); |
50 #if defined(TARGET_ARCH_IA32) | 50 #if defined(TARGET_ARCH_IA32) |
51 const char arch[] = "ia32"; | 51 const char arch[] = "ia32"; |
52 #elif defined(TARGET_ARCH_X64) | 52 #elif defined(TARGET_ARCH_X64) |
53 const char arch[] = "x64"; | 53 const char arch[] = "x64"; |
54 #elif defined(TARGET_ARCH_ARM) | 54 #elif defined(TARGET_ARCH_ARM) |
55 const char arch[] = "arm"; | 55 const char arch[] = "arm"; |
56 #elif defined(TARGET_ARCH_MIPS) | 56 #elif defined(TARGET_ARCH_MIPS) |
57 const char arch[] = "mips"; | 57 const char arch[] = "mips"; |
58 #else | 58 #else |
59 const char arch[] = "unknown"; | 59 const char arch[] = "unknown"; |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
127 PerfCodeObserver() { | 127 PerfCodeObserver() { |
128 Dart_FileOpenCallback file_open = Isolate::file_open_callback(); | 128 Dart_FileOpenCallback file_open = Isolate::file_open_callback(); |
129 if (file_open == NULL) { | 129 if (file_open == NULL) { |
130 return; | 130 return; |
131 } | 131 } |
132 const char* format = "/tmp/perf-%ld.map"; | 132 const char* format = "/tmp/perf-%ld.map"; |
133 intptr_t pid = getpid(); | 133 intptr_t pid = getpid(); |
134 intptr_t len = OS::SNPrint(NULL, 0, format, pid); | 134 intptr_t len = OS::SNPrint(NULL, 0, format, pid); |
135 char* filename = new char[len + 1]; | 135 char* filename = new char[len + 1]; |
136 OS::SNPrint(filename, len + 1, format, pid); | 136 OS::SNPrint(filename, len + 1, format, pid); |
137 out_file_ = (*file_open)(filename); | 137 out_file_ = (*file_open)(filename, true); |
138 } | 138 } |
139 | 139 |
140 ~PerfCodeObserver() { | 140 ~PerfCodeObserver() { |
141 Dart_FileCloseCallback file_close = Isolate::file_close_callback(); | 141 Dart_FileCloseCallback file_close = Isolate::file_close_callback(); |
142 if (file_close == NULL) { | 142 if (file_close == NULL) { |
143 return; | 143 return; |
144 } | 144 } |
145 ASSERT(out_file_ != NULL); | 145 ASSERT(out_file_ != NULL); |
146 (*file_close)(out_file_); | 146 (*file_close)(out_file_); |
147 } | 147 } |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
188 return; | 188 return; |
189 } | 189 } |
190 Dart_FileWriteCallback file_write = Isolate::file_write_callback(); | 190 Dart_FileWriteCallback file_write = Isolate::file_write_callback(); |
191 if (file_write == NULL) { | 191 if (file_write == NULL) { |
192 return; | 192 return; |
193 } | 193 } |
194 if (FLAG_generate_pprof_symbols == NULL) { | 194 if (FLAG_generate_pprof_symbols == NULL) { |
195 return; | 195 return; |
196 } | 196 } |
197 const char* filename = FLAG_generate_pprof_symbols; | 197 const char* filename = FLAG_generate_pprof_symbols; |
198 void* out_file = (*file_open)(filename); | 198 void* out_file = (*file_open)(filename, true); |
199 ASSERT(out_file != NULL); | 199 ASSERT(out_file != NULL); |
200 DebugInfo::ByteBuffer* debug_region = new DebugInfo::ByteBuffer(); | 200 DebugInfo::ByteBuffer* debug_region = new DebugInfo::ByteBuffer(); |
201 ASSERT(debug_region != NULL); | 201 ASSERT(debug_region != NULL); |
202 pprof_symbol_generator_->WriteToMemory(debug_region); | 202 pprof_symbol_generator_->WriteToMemory(debug_region); |
203 int buffer_size = debug_region->size(); | 203 int buffer_size = debug_region->size(); |
204 void* buffer = debug_region->data(); | 204 void* buffer = debug_region->data(); |
205 if (buffer_size > 0) { | 205 if (buffer_size > 0) { |
206 ASSERT(buffer != NULL); | 206 ASSERT(buffer != NULL); |
207 (*file_write)(buffer, buffer_size, out_file); | 207 (*file_write)(buffer, buffer_size, out_file); |
208 } | 208 } |
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
515 } | 515 } |
516 | 516 |
517 | 517 |
518 void OS::Exit(int code) { | 518 void OS::Exit(int code) { |
519 exit(code); | 519 exit(code); |
520 } | 520 } |
521 | 521 |
522 } // namespace dart | 522 } // namespace dart |
523 | 523 |
524 #endif // defined(TARGET_OS_LINUX) | 524 #endif // defined(TARGET_OS_LINUX) |
OLD | NEW |