OLD | NEW |
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 #endif | 47 #endif |
48 #ifndef NOMCX | 48 #ifndef NOMCX |
49 #define NOMCX | 49 #define NOMCX |
50 #endif | 50 #endif |
51 // Require Windows 2000 or higher (this is required for the IsDebuggerPresent | 51 // Require Windows 2000 or higher (this is required for the IsDebuggerPresent |
52 // function to be present). | 52 // function to be present). |
53 #ifndef _WIN32_WINNT | 53 #ifndef _WIN32_WINNT |
54 #define _WIN32_WINNT 0x500 | 54 #define _WIN32_WINNT 0x500 |
55 #endif | 55 #endif |
56 | 56 |
57 #ifdef _WIN64 | |
58 #error Windows 64-bit blatforms not supported | |
59 #endif | |
60 | |
61 #include <windows.h> | 57 #include <windows.h> |
62 | 58 |
63 #include <time.h> // For LocalOffset() implementation. | 59 #include <time.h> // For LocalOffset() implementation. |
64 #include <mmsystem.h> // For timeGetTime(). | 60 #include <mmsystem.h> // For timeGetTime(). |
65 #ifdef __MINGW32__ | 61 #ifdef __MINGW32__ |
66 // Require Windows XP or higher when compiling with MinGW. This is for MinGW | 62 // Require Windows XP or higher when compiling with MinGW. This is for MinGW |
67 // header files to expose getaddrinfo. | 63 // header files to expose getaddrinfo. |
68 #undef _WIN32_WINNT | 64 #undef _WIN32_WINNT |
69 #define _WIN32_WINNT 0x501 | 65 #define _WIN32_WINNT 0x501 |
70 #endif // __MINGW32__ | 66 #endif // __MINGW32__ |
(...skipping 1112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1183 HANDLE thread_handle = GetCurrentThread(); | 1179 HANDLE thread_handle = GetCurrentThread(); |
1184 | 1180 |
1185 // Read the symbols. | 1181 // Read the symbols. |
1186 if (!LoadSymbols(process_handle)) return kStackWalkError; | 1182 if (!LoadSymbols(process_handle)) return kStackWalkError; |
1187 | 1183 |
1188 // Capture current context. | 1184 // Capture current context. |
1189 CONTEXT context; | 1185 CONTEXT context; |
1190 memset(&context, 0, sizeof(context)); | 1186 memset(&context, 0, sizeof(context)); |
1191 context.ContextFlags = CONTEXT_CONTROL; | 1187 context.ContextFlags = CONTEXT_CONTROL; |
1192 context.ContextFlags = CONTEXT_CONTROL; | 1188 context.ContextFlags = CONTEXT_CONTROL; |
| 1189 #ifdef _WIN64 |
| 1190 // TODO(X64): Implement context capture. |
| 1191 #else |
1193 __asm call x | 1192 __asm call x |
1194 __asm x: pop eax | 1193 __asm x: pop eax |
1195 __asm mov context.Eip, eax | 1194 __asm mov context.Eip, eax |
1196 __asm mov context.Ebp, ebp | 1195 __asm mov context.Ebp, ebp |
1197 __asm mov context.Esp, esp | 1196 __asm mov context.Esp, esp |
1198 // NOTE: At some point, we could use RtlCaptureContext(&context) to | 1197 // NOTE: At some point, we could use RtlCaptureContext(&context) to |
1199 // capture the context instead of inline assembler. However it is | 1198 // capture the context instead of inline assembler. However it is |
1200 // only available on XP, Vista, Server 2003 and Server 2008 which | 1199 // only available on XP, Vista, Server 2003 and Server 2008 which |
1201 // might not be sufficient. | 1200 // might not be sufficient. |
| 1201 #endif |
1202 | 1202 |
1203 // Initialize the stack walking | 1203 // Initialize the stack walking |
1204 STACKFRAME64 stack_frame; | 1204 STACKFRAME64 stack_frame; |
1205 memset(&stack_frame, 0, sizeof(stack_frame)); | 1205 memset(&stack_frame, 0, sizeof(stack_frame)); |
| 1206 #ifdef _WIN64 |
| 1207 stack_frame.AddrPC.Offset = context.Rip; |
| 1208 stack_frame.AddrFrame.Offset = context.Rbp; |
| 1209 stack_frame.AddrStack.Offset = context.Rsp; |
| 1210 #else |
1206 stack_frame.AddrPC.Offset = context.Eip; | 1211 stack_frame.AddrPC.Offset = context.Eip; |
| 1212 stack_frame.AddrFrame.Offset = context.Ebp; |
| 1213 stack_frame.AddrStack.Offset = context.Esp; |
| 1214 #endif |
1207 stack_frame.AddrPC.Mode = AddrModeFlat; | 1215 stack_frame.AddrPC.Mode = AddrModeFlat; |
1208 stack_frame.AddrFrame.Offset = context.Ebp; | |
1209 stack_frame.AddrFrame.Mode = AddrModeFlat; | 1216 stack_frame.AddrFrame.Mode = AddrModeFlat; |
1210 stack_frame.AddrStack.Offset = context.Esp; | |
1211 stack_frame.AddrStack.Mode = AddrModeFlat; | 1217 stack_frame.AddrStack.Mode = AddrModeFlat; |
1212 int frames_count = 0; | 1218 int frames_count = 0; |
1213 | 1219 |
1214 // Collect stack frames. | 1220 // Collect stack frames. |
1215 int frames_size = frames.length(); | 1221 int frames_size = frames.length(); |
1216 while (frames_count < frames_size) { | 1222 while (frames_count < frames_size) { |
1217 ok = _StackWalk64( | 1223 ok = _StackWalk64( |
1218 IMAGE_FILE_MACHINE_I386, // MachineType | 1224 IMAGE_FILE_MACHINE_I386, // MachineType |
1219 process_handle, // hProcess | 1225 process_handle, // hProcess |
1220 thread_handle, // hThread | 1226 thread_handle, // hThread |
(...skipping 651 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1872 | 1878 |
1873 // Release the thread handles | 1879 // Release the thread handles |
1874 CloseHandle(data_->sampler_thread_); | 1880 CloseHandle(data_->sampler_thread_); |
1875 CloseHandle(data_->profiled_thread_); | 1881 CloseHandle(data_->profiled_thread_); |
1876 } | 1882 } |
1877 | 1883 |
1878 | 1884 |
1879 #endif // ENABLE_LOGGING_AND_PROFILING | 1885 #endif // ENABLE_LOGGING_AND_PROFILING |
1880 | 1886 |
1881 } } // namespace v8::internal | 1887 } } // namespace v8::internal |
OLD | NEW |