Index: src/platform-win32.cc |
diff --git a/src/platform-win32.cc b/src/platform-win32.cc |
index 1b0f9b24d546f3b259eb8bb95da810ca23082dcc..a8a62432130e8b99439c356404e3af9756a6b68b 100644 |
--- a/src/platform-win32.cc |
+++ b/src/platform-win32.cc |
@@ -1776,32 +1776,30 @@ class Sampler::PlatformData : public Malloced { |
TickSample sample; |
// If profiling, we record the pc and sp of the profiled thread. |
- if (sampler_->IsProfiling()) { |
- // Pause the profiled thread and get its context. |
- SuspendThread(profiled_thread_); |
+ if (sampler_->IsProfiling() |
+ && SuspendThread(profiled_thread_) != (DWORD)-1) { |
context.ContextFlags = CONTEXT_FULL; |
- GetThreadContext(profiled_thread_, &context); |
- // Invoke tick handler with program counter and stack pointer. |
+ if (GetThreadContext(profiled_thread_, &context) != 0) { |
#if V8_HOST_ARCH_X64 |
- UNIMPLEMENTED(); |
- sample.pc = context.Rip; |
- sample.sp = context.Rsp; |
- sample.fp = context.Rbp; |
+ UNIMPLEMENTED(); |
+ sample.pc = context.Rip; |
+ sample.sp = context.Rsp; |
+ sample.fp = context.Rbp; |
#else |
- sample.pc = context.Eip; |
- sample.sp = context.Esp; |
- sample.fp = context.Ebp; |
+ sample.pc = context.Eip; |
+ sample.sp = context.Esp; |
+ sample.fp = context.Ebp; |
#endif |
+ sampler_->SampleStack(&sample); |
+ } |
+ ResumeThread(profiled_thread_); |
} |
// We always sample the VM state. |
sample.state = Logger::state(); |
+ // Invoke tick handler with program counter and stack pointer. |
sampler_->Tick(&sample); |
- if (sampler_->IsProfiling()) { |
- ResumeThread(profiled_thread_); |
- } |
- |
// Wait until next sampling. |
Sleep(sampler_->interval_); |
} |