Chromium Code Reviews| Index: runtime/vm/profiler.cc |
| diff --git a/runtime/vm/profiler.cc b/runtime/vm/profiler.cc |
| index 46c62fb46a8980b672d7251d9b57918dfb82fc31..0b4a277ce9bf5b4ba81edbd3659ca13015d9b0ef 100644 |
| --- a/runtime/vm/profiler.cc |
| +++ b/runtime/vm/profiler.cc |
| @@ -874,13 +874,15 @@ Sample* SampleBuffer::ReserveSample() { |
| // |
| class ProfilerSampleStackWalker : public ValueObject { |
| public: |
| - ProfilerSampleStackWalker(Sample* sample, |
| + ProfilerSampleStackWalker(Heap* heap, |
| + Sample* sample, |
| uword stack_lower, |
| uword stack_upper, |
| uword pc, |
| uword fp, |
| uword sp) |
| - : sample_(sample), |
| + : heap_(heap), |
| + sample_(sample), |
| stack_upper_(stack_upper), |
| original_pc_(pc), |
| original_fp_(fp), |
| @@ -918,6 +920,9 @@ class ProfilerSampleStackWalker : public ValueObject { |
| } |
| int i = 0; |
| for (; i < FLAG_profile_depth; i++) { |
| +#if defined(DEBUG_STACK_WALK) |
| + VerifyCodeAddress(i, reinterpret_cast<uword>(pc)); |
| +#endif |
| sample_->SetAt(i, reinterpret_cast<uword>(pc)); |
| if (!ValidFramePointer(fp)) { |
| return i + 1; |
| @@ -939,6 +944,24 @@ class ProfilerSampleStackWalker : public ValueObject { |
| } |
| private: |
| +#if defined(DEBUG_STACK_WALK) |
| + void VerifyCodeAddress(int i, uword pc) { |
| + if (heap_ != NULL) { |
| + bool contained = heap_->Contains(pc); |
| + bool code_contained = heap_->CodeContains(pc); |
| + if (contained != code_contained) { |
|
siva
2014/02/27 00:00:26
Doesn't short circuit when it is not contained in
Cutch
2014/02/27 15:52:37
Done.
|
| + for (int j = 0; j < i; j++) { |
| + OS::Print("%d %" Px "\n", j, sample_->At(j)); |
| + } |
| + OS::Print("%d %" Px " <--\n", i, pc); |
| + OS::Print("---ASSERT-FAILED---\n"); |
| + OS::Print("%" Px " %" Px "\n", original_pc_, original_fp_); |
| + } |
| + ASSERT(contained == code_contained); |
| + } |
| + } |
| +#endif |
| + |
| uword* CallerPC(uword* fp) const { |
| ASSERT(fp != NULL); |
| return reinterpret_cast<uword*>(*(fp + kSavedCallerPcSlotFromFp)); |
| @@ -959,6 +982,7 @@ class ProfilerSampleStackWalker : public ValueObject { |
| return r; |
| } |
| + Heap* heap_; |
| Sample* sample_; |
| const uword stack_upper_; |
| const uword original_pc_; |
| @@ -991,8 +1015,9 @@ void Profiler::RecordSampleInterruptCallback( |
| stack_lower = 0; |
| stack_upper = 0; |
| } |
| - ProfilerSampleStackWalker stackWalker(sample, stack_lower, stack_upper, |
| - state.pc, state.fp, state.sp); |
| + ProfilerSampleStackWalker stackWalker(isolate->heap(), sample, stack_lower, |
| + stack_upper, state.pc, state.fp, |
| + state.sp); |
| stackWalker.walk(); |
| } |