| 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 30 matching lines...) Expand all Loading... |
| 41 #endif | 41 #endif |
| 42 #ifndef NOSERVICE | 42 #ifndef NOSERVICE |
| 43 #define NOSERVICE | 43 #define NOSERVICE |
| 44 #endif | 44 #endif |
| 45 #ifndef NOSOUND | 45 #ifndef NOSOUND |
| 46 #define NOSOUND | 46 #define NOSOUND |
| 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 XP or higher (this is required for the RtlCaptureContext |
| 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 0x501 |
| 55 #endif | 55 #endif |
| 56 | 56 |
| 57 #include <windows.h> | 57 #include <windows.h> |
| 58 | 58 |
| 59 #include <time.h> // For LocalOffset() implementation. | 59 #include <time.h> // For LocalOffset() implementation. |
| 60 #include <mmsystem.h> // For timeGetTime(). | 60 #include <mmsystem.h> // For timeGetTime(). |
| 61 #ifdef __MINGW32__ | 61 #ifdef __MINGW32__ |
| 62 // 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 |
| 63 // header files to expose getaddrinfo. | 63 // header files to expose getaddrinfo. |
| 64 #undef _WIN32_WINNT | 64 #undef _WIN32_WINNT |
| (...skipping 1111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1176 | 1176 |
| 1177 // Get the process and thread handles. | 1177 // Get the process and thread handles. |
| 1178 HANDLE process_handle = GetCurrentProcess(); | 1178 HANDLE process_handle = GetCurrentProcess(); |
| 1179 HANDLE thread_handle = GetCurrentThread(); | 1179 HANDLE thread_handle = GetCurrentThread(); |
| 1180 | 1180 |
| 1181 // Read the symbols. | 1181 // Read the symbols. |
| 1182 if (!LoadSymbols(process_handle)) return kStackWalkError; | 1182 if (!LoadSymbols(process_handle)) return kStackWalkError; |
| 1183 | 1183 |
| 1184 // Capture current context. | 1184 // Capture current context. |
| 1185 CONTEXT context; | 1185 CONTEXT context; |
| 1186 memset(&context, 0, sizeof(context)); | 1186 RtlCaptureContext(&context); |
| 1187 context.ContextFlags = CONTEXT_CONTROL; | |
| 1188 context.ContextFlags = CONTEXT_CONTROL; | |
| 1189 #ifdef _WIN64 | |
| 1190 // TODO(X64): Implement context capture. | |
| 1191 #else | |
| 1192 __asm call x | |
| 1193 __asm x: pop eax | |
| 1194 __asm mov context.Eip, eax | |
| 1195 __asm mov context.Ebp, ebp | |
| 1196 __asm mov context.Esp, esp | |
| 1197 // NOTE: At some point, we could use RtlCaptureContext(&context) to | |
| 1198 // capture the context instead of inline assembler. However it is | |
| 1199 // only available on XP, Vista, Server 2003 and Server 2008 which | |
| 1200 // might not be sufficient. | |
| 1201 #endif | |
| 1202 | 1187 |
| 1203 // Initialize the stack walking | 1188 // Initialize the stack walking |
| 1204 STACKFRAME64 stack_frame; | 1189 STACKFRAME64 stack_frame; |
| 1205 memset(&stack_frame, 0, sizeof(stack_frame)); | 1190 memset(&stack_frame, 0, sizeof(stack_frame)); |
| 1206 #ifdef _WIN64 | 1191 #ifdef _WIN64 |
| 1207 stack_frame.AddrPC.Offset = context.Rip; | 1192 stack_frame.AddrPC.Offset = context.Rip; |
| 1208 stack_frame.AddrFrame.Offset = context.Rbp; | 1193 stack_frame.AddrFrame.Offset = context.Rbp; |
| 1209 stack_frame.AddrStack.Offset = context.Rsp; | 1194 stack_frame.AddrStack.Offset = context.Rsp; |
| 1210 #else | 1195 #else |
| 1211 stack_frame.AddrPC.Offset = context.Eip; | 1196 stack_frame.AddrPC.Offset = context.Eip; |
| (...skipping 668 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1880 | 1865 |
| 1881 // Release the thread handles | 1866 // Release the thread handles |
| 1882 CloseHandle(data_->sampler_thread_); | 1867 CloseHandle(data_->sampler_thread_); |
| 1883 CloseHandle(data_->profiled_thread_); | 1868 CloseHandle(data_->profiled_thread_); |
| 1884 } | 1869 } |
| 1885 | 1870 |
| 1886 | 1871 |
| 1887 #endif // ENABLE_LOGGING_AND_PROFILING | 1872 #endif // ENABLE_LOGGING_AND_PROFILING |
| 1888 | 1873 |
| 1889 } } // namespace v8::internal | 1874 } } // namespace v8::internal |
| OLD | NEW |