OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 "platform/address_sanitizer.h" | 5 #include "platform/address_sanitizer.h" |
6 #include "platform/memory_sanitizer.h" | 6 #include "platform/memory_sanitizer.h" |
7 #include "platform/utils.h" | 7 #include "platform/utils.h" |
8 | 8 |
9 #include "vm/allocation.h" | 9 #include "vm/allocation.h" |
10 #include "vm/atomic.h" | 10 #include "vm/atomic.h" |
(...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
323 ClearProfileVisitor::ClearProfileVisitor(Isolate* isolate) | 323 ClearProfileVisitor::ClearProfileVisitor(Isolate* isolate) |
324 : SampleVisitor(isolate) {} | 324 : SampleVisitor(isolate) {} |
325 | 325 |
326 | 326 |
327 void ClearProfileVisitor::VisitSample(Sample* sample) { | 327 void ClearProfileVisitor::VisitSample(Sample* sample) { |
328 sample->Clear(); | 328 sample->Clear(); |
329 } | 329 } |
330 | 330 |
331 | 331 |
332 static void DumpStackFrame(intptr_t frame_index, uword pc) { | 332 static void DumpStackFrame(intptr_t frame_index, uword pc) { |
| 333 Isolate* isolate = Isolate::Current(); |
| 334 if ((isolate != NULL) && isolate->is_runnable()) { |
| 335 Code& code = Code::Handle(Code::LookupCodeInVmIsolate(pc)); |
| 336 if (!code.IsNull()) { |
| 337 OS::PrintErr(" [0x%" Pp "] %s\n", pc, code.QualifiedName()); |
| 338 return; |
| 339 } |
| 340 code = Code::LookupCode(pc); |
| 341 if (!code.IsNull()) { |
| 342 OS::PrintErr(" [0x%" Pp "] %s\n", pc, code.QualifiedName()); |
| 343 return; |
| 344 } |
| 345 } |
| 346 |
333 uintptr_t start = 0; | 347 uintptr_t start = 0; |
334 char* native_symbol_name = NativeSymbolResolver::LookupSymbolName(pc, &start); | 348 char* native_symbol_name = NativeSymbolResolver::LookupSymbolName(pc, &start); |
335 if (native_symbol_name == NULL) { | 349 if (native_symbol_name == NULL) { |
336 OS::PrintErr(" [0x%" Pp "] Unknown symbol\n", pc); | 350 OS::PrintErr(" [0x%" Pp "] Unknown symbol\n", pc); |
337 } else { | 351 } else { |
338 OS::PrintErr(" [0x%" Pp "] %s\n", pc, native_symbol_name); | 352 OS::PrintErr(" [0x%" Pp "] %s\n", pc, native_symbol_name); |
339 NativeSymbolResolver::FreeSymbolName(native_symbol_name); | 353 NativeSymbolResolver::FreeSymbolName(native_symbol_name); |
340 } | 354 } |
341 } | 355 } |
342 | 356 |
343 | 357 |
344 static void DumpStackFrame(intptr_t frame_index, uword pc, const Code& code) { | |
345 if (code.IsNull()) { | |
346 DumpStackFrame(frame_index, pc); | |
347 } else { | |
348 OS::PrintErr("Frame[%" Pd "] = Dart:`%s` [0x%" Px "]\n", frame_index, | |
349 code.ToCString(), pc); | |
350 } | |
351 } | |
352 | |
353 | |
354 class ProfilerStackWalker : public ValueObject { | 358 class ProfilerStackWalker : public ValueObject { |
355 public: | 359 public: |
356 ProfilerStackWalker(Isolate* isolate, | 360 ProfilerStackWalker(Isolate* isolate, |
357 Sample* head_sample, | 361 Sample* head_sample, |
358 SampleBuffer* sample_buffer) | 362 SampleBuffer* sample_buffer) |
359 : isolate_(isolate), | 363 : isolate_(isolate), |
360 sample_(head_sample), | 364 sample_(head_sample), |
361 sample_buffer_(sample_buffer), | 365 sample_buffer_(sample_buffer), |
362 frame_index_(0), | 366 frame_index_(0), |
363 total_frames_(0) { | 367 total_frames_(0) { |
364 ASSERT(isolate_ != NULL); | 368 ASSERT(isolate_ != NULL); |
365 if (sample_ == NULL) { | 369 if (sample_ == NULL) { |
366 ASSERT(sample_buffer_ == NULL); | 370 ASSERT(sample_buffer_ == NULL); |
367 } else { | 371 } else { |
368 ASSERT(sample_buffer_ != NULL); | 372 ASSERT(sample_buffer_ != NULL); |
369 ASSERT(sample_->head_sample()); | 373 ASSERT(sample_->head_sample()); |
370 } | 374 } |
371 } | 375 } |
372 | 376 |
373 bool Append(uword pc, const Code& code) { | |
374 if (sample_ == NULL) { | |
375 DumpStackFrame(frame_index_, pc, code); | |
376 frame_index_++; | |
377 total_frames_++; | |
378 return true; | |
379 } | |
380 return Append(pc); | |
381 } | |
382 | |
383 bool Append(uword pc) { | 377 bool Append(uword pc) { |
384 if (sample_ == NULL) { | 378 if (sample_ == NULL) { |
385 DumpStackFrame(frame_index_, pc); | 379 DumpStackFrame(frame_index_, pc); |
386 frame_index_++; | 380 frame_index_++; |
387 total_frames_++; | 381 total_frames_++; |
388 return true; | 382 return true; |
389 } | 383 } |
390 if (total_frames_ >= FLAG_max_profile_depth) { | 384 if (total_frames_ >= FLAG_max_profile_depth) { |
391 sample_->set_truncated_trace(true); | 385 sample_->set_truncated_trace(true); |
392 return false; | 386 return false; |
(...skipping 1126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1519 | 1513 |
1520 | 1514 |
1521 ProcessedSampleBuffer::ProcessedSampleBuffer() | 1515 ProcessedSampleBuffer::ProcessedSampleBuffer() |
1522 : code_lookup_table_(new CodeLookupTable(Thread::Current())) { | 1516 : code_lookup_table_(new CodeLookupTable(Thread::Current())) { |
1523 ASSERT(code_lookup_table_ != NULL); | 1517 ASSERT(code_lookup_table_ != NULL); |
1524 } | 1518 } |
1525 | 1519 |
1526 #endif // !PRODUCT | 1520 #endif // !PRODUCT |
1527 | 1521 |
1528 } // namespace dart | 1522 } // namespace dart |
OLD | NEW |