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

Unified Diff: runtime/vm/profiler.cc

Issue 183633002: Turn stack walking verification into a flag (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 10 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 | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/profiler.cc
diff --git a/runtime/vm/profiler.cc b/runtime/vm/profiler.cc
index a80809cb43754027b476c64ea464ac6b8f7bb65f..0eb106f2d53588e6c93682f9243f285daa4c3dd8 100644
--- a/runtime/vm/profiler.cc
+++ b/runtime/vm/profiler.cc
@@ -33,6 +33,8 @@ DEFINE_FLAG(int, profile_period, 1000,
"Time between profiler samples in microseconds. Minimum 250.");
DEFINE_FLAG(int, profile_depth, 8,
"Maximum number stack frames walked. Minimum 1. Maximum 255.");
+DEFINE_FLAG(bool, profile_verify_stack_walk, false,
+ "Verify instruction addresses while walking the stack.");
bool Profiler::initialized_ = false;
SampleBuffer* Profiler::sample_buffer_ = NULL;
@@ -889,13 +891,7 @@ class ProfilerSampleStackWalker : public ValueObject {
ASSERT(sample_ != NULL);
}
-#if defined(DEBUG_STACK_WALK)
- void set_heap(Heap* heap) {
- heap_ = heap;
- }
-#endif
-
- int walk() {
+ int walk(Heap* heap) {
const intptr_t kMaxStep = 0x1000; // 4K.
const bool kWalkStack = true; // Walk the stack.
// Always store the exclusive PC.
@@ -924,9 +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
+ if (FLAG_profile_verify_stack_walk) {
+ VerifyCodeAddress(heap, i, reinterpret_cast<uword>(pc));
+ }
sample_->SetAt(i, reinterpret_cast<uword>(pc));
if (!ValidFramePointer(fp)) {
return i + 1;
@@ -948,10 +944,9 @@ class ProfilerSampleStackWalker : public ValueObject {
}
private:
-#if defined(DEBUG_STACK_WALK)
- void VerifyCodeAddress(int i, uword pc) {
- if (heap_ != NULL) {
- if (heap_->Contains(pc) && !heap_->CodeContains(pc)) {
+ void VerifyCodeAddress(Heap* heap, int i, uword pc) {
+ if (heap != NULL) {
+ if (heap->Contains(pc) && !heap->CodeContains(pc)) {
for (int j = 0; j < i; j++) {
OS::Print("%d %" Px "\n", j, sample_->At(j));
}
@@ -962,7 +957,6 @@ class ProfilerSampleStackWalker : public ValueObject {
}
}
}
-#endif
uword* CallerPC(uword* fp) const {
ASSERT(fp != NULL);
@@ -984,9 +978,7 @@ class ProfilerSampleStackWalker : public ValueObject {
return r;
}
-#if defined(DEBUG_STACK_WALK)
- Heap* heap_;
-#endif
+
Sample* sample_;
const uword stack_upper_;
const uword original_pc_;
@@ -1021,10 +1013,7 @@ void Profiler::RecordSampleInterruptCallback(
}
ProfilerSampleStackWalker stackWalker(sample, stack_lower, stack_upper,
state.pc, state.fp, state.sp);
-#if defined(DEBUG_STACK_WALK)
- stackWalker.set_heap(isolate->heap());
-#endif
- stackWalker.walk();
+ stackWalker.walk(isolate->heap());
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698