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

Side by Side Diff: runtime/vm/thread_interrupter_win.cc

Issue 293133007: Guard against frames across pages, in the profiler. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 7 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « runtime/vm/profiler.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/globals.h" 5 #include "platform/globals.h"
6 #if defined(TARGET_OS_WINDOWS) 6 #if defined(TARGET_OS_WINDOWS)
7 7
8 #include "vm/thread_interrupter.h" 8 #include "vm/thread_interrupter.h"
9 9
10 namespace dart { 10 namespace dart {
11 11
12 DECLARE_FLAG(bool, thread_interrupter); 12 DECLARE_FLAG(bool, thread_interrupter);
13 DECLARE_FLAG(bool, trace_thread_interrupter); 13 DECLARE_FLAG(bool, trace_thread_interrupter);
14 14
15 #define kThreadError -1 15 #define kThreadError -1
16 16
17 class ThreadInterrupterWin : public AllStatic { 17 class ThreadInterrupterWin : public AllStatic {
18 public: 18 public:
19 static bool GrabRegisters(HANDLE handle, InterruptedThreadState* state) { 19 static bool GrabRegisters(HANDLE handle, InterruptedThreadState* state) {
20 CONTEXT context; 20 CONTEXT context;
21 memset(&context, 0, sizeof(context)); 21 memset(&context, 0, sizeof(context));
22 context.ContextFlags = CONTEXT_FULL; 22 context.ContextFlags = CONTEXT_CONTROL;
23 if (GetThreadContext(handle, &context) != 0) { 23 if (GetThreadContext(handle, &context) != 0) {
24 #if defined(TARGET_ARCH_IA32) 24 #if defined(TARGET_ARCH_IA32)
25 state->pc = static_cast<uintptr_t>(context.Eip); 25 state->pc = static_cast<uintptr_t>(context.Eip);
26 state->fp = static_cast<uintptr_t>(context.Ebp); 26 state->fp = static_cast<uintptr_t>(context.Ebp);
27 state->sp = static_cast<uintptr_t>(context.Esp); 27 state->sp = static_cast<uintptr_t>(context.Esp);
28 #elif defined(TARGET_ARCH_X64) 28 #elif defined(TARGET_ARCH_X64)
29 state->pc = reinterpret_cast<uintptr_t>(context.Rip); 29 state->pc = reinterpret_cast<uintptr_t>(context.Rip);
30 state->fp = reinterpret_cast<uintptr_t>(context.Rbp); 30 state->fp = reinterpret_cast<uintptr_t>(context.Rbp);
31 state->sp = reinterpret_cast<uintptr_t>(context.Rsp); 31 state->sp = reinterpret_cast<uintptr_t>(context.Rsp);
32 #else 32 #else
33 UNIMPLEMENTED(); 33 UNIMPLEMENTED();
34 #endif 34 #endif
35 return true; 35 return true;
36 } 36 }
37 return false; 37 return false;
38 } 38 }
39 39
40 40
41 static void Interrupt(InterruptableThreadState* state) { 41 static void Interrupt(InterruptableThreadState* state) {
42 ASSERT(!Thread::Compare(GetCurrentThreadId(), state->id)); 42 ASSERT(!Thread::Compare(GetCurrentThreadId(), state->id));
43 HANDLE handle = OpenThread(THREAD_GET_CONTEXT | 43 HANDLE handle = OpenThread(THREAD_GET_CONTEXT |
44 THREAD_QUERY_INFORMATION |
44 THREAD_SUSPEND_RESUME, 45 THREAD_SUSPEND_RESUME,
45 false, 46 false,
46 state->id); 47 state->id);
47 ASSERT(handle != NULL); 48 ASSERT(handle != NULL);
48 DWORD result = SuspendThread(handle); 49 DWORD result = SuspendThread(handle);
49 if (result == kThreadError) { 50 if (result == kThreadError) {
50 if (FLAG_trace_thread_interrupter) { 51 if (FLAG_trace_thread_interrupter) {
51 OS::Print("ThreadInterrupted failed to suspend thread %p\n", 52 OS::Print("ThreadInterrupted failed to suspend thread %p\n",
52 reinterpret_cast<void*>(state->id)); 53 reinterpret_cast<void*>(state->id));
53 } 54 }
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 95
95 void ThreadInterrupter::InstallSignalHandler() { 96 void ThreadInterrupter::InstallSignalHandler() {
96 // Nothing to do on Windows. 97 // Nothing to do on Windows.
97 } 98 }
98 99
99 100
100 } // namespace dart 101 } // namespace dart
101 102
102 #endif // defined(TARGET_OS_WINDOWS) 103 #endif // defined(TARGET_OS_WINDOWS)
103 104
OLDNEW
« no previous file with comments | « runtime/vm/profiler.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698