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 1143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1154 } | 1154 } |
1155 | 1155 |
1156 | 1156 |
1157 // Walk the stack using the facilities in dbghelp.dll and tlhelp32.dll | 1157 // Walk the stack using the facilities in dbghelp.dll and tlhelp32.dll |
1158 | 1158 |
1159 // Switch off warning 4748 (/GS can not protect parameters and local variables | 1159 // Switch off warning 4748 (/GS can not protect parameters and local variables |
1160 // from local buffer overrun because optimizations are disabled in function) as | 1160 // from local buffer overrun because optimizations are disabled in function) as |
1161 // it is triggered by the use of inline assembler. | 1161 // it is triggered by the use of inline assembler. |
1162 #pragma warning(push) | 1162 #pragma warning(push) |
1163 #pragma warning(disable : 4748) | 1163 #pragma warning(disable : 4748) |
1164 int OS::StackWalk(OS::StackFrame* frames, int frames_size) { | 1164 int OS::StackWalk(Vector<OS::StackFrame> frames) { |
1165 BOOL ok; | 1165 BOOL ok; |
1166 | 1166 |
1167 // Load the required functions from DLL's. | 1167 // Load the required functions from DLL's. |
1168 if (!LoadDbgHelpAndTlHelp32()) return kStackWalkError; | 1168 if (!LoadDbgHelpAndTlHelp32()) return kStackWalkError; |
1169 | 1169 |
1170 // Get the process and thread handles. | 1170 // Get the process and thread handles. |
1171 HANDLE process_handle = GetCurrentProcess(); | 1171 HANDLE process_handle = GetCurrentProcess(); |
1172 HANDLE thread_handle = GetCurrentThread(); | 1172 HANDLE thread_handle = GetCurrentThread(); |
1173 | 1173 |
1174 // Read the symbols. | 1174 // Read the symbols. |
(...skipping 19 matching lines...) Expand all Loading... |
1194 memset(&stack_frame, 0, sizeof(stack_frame)); | 1194 memset(&stack_frame, 0, sizeof(stack_frame)); |
1195 stack_frame.AddrPC.Offset = context.Eip; | 1195 stack_frame.AddrPC.Offset = context.Eip; |
1196 stack_frame.AddrPC.Mode = AddrModeFlat; | 1196 stack_frame.AddrPC.Mode = AddrModeFlat; |
1197 stack_frame.AddrFrame.Offset = context.Ebp; | 1197 stack_frame.AddrFrame.Offset = context.Ebp; |
1198 stack_frame.AddrFrame.Mode = AddrModeFlat; | 1198 stack_frame.AddrFrame.Mode = AddrModeFlat; |
1199 stack_frame.AddrStack.Offset = context.Esp; | 1199 stack_frame.AddrStack.Offset = context.Esp; |
1200 stack_frame.AddrStack.Mode = AddrModeFlat; | 1200 stack_frame.AddrStack.Mode = AddrModeFlat; |
1201 int frames_count = 0; | 1201 int frames_count = 0; |
1202 | 1202 |
1203 // Collect stack frames. | 1203 // Collect stack frames. |
| 1204 int frames_size = frames.length(); |
1204 while (frames_count < frames_size) { | 1205 while (frames_count < frames_size) { |
1205 ok = _StackWalk64( | 1206 ok = _StackWalk64( |
1206 IMAGE_FILE_MACHINE_I386, // MachineType | 1207 IMAGE_FILE_MACHINE_I386, // MachineType |
1207 process_handle, // hProcess | 1208 process_handle, // hProcess |
1208 thread_handle, // hThread | 1209 thread_handle, // hThread |
1209 &stack_frame, // StackFrame | 1210 &stack_frame, // StackFrame |
1210 &context, // ContextRecord | 1211 &context, // ContextRecord |
1211 NULL, // ReadMemoryRoutine | 1212 NULL, // ReadMemoryRoutine |
1212 _SymFunctionTableAccess64, // FunctionTableAccessRoutine | 1213 _SymFunctionTableAccess64, // FunctionTableAccessRoutine |
1213 _SymGetModuleBase64, // GetModuleBaseRoutine | 1214 _SymGetModuleBase64, // GetModuleBaseRoutine |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1277 | 1278 |
1278 // Return the number of frames filled in. | 1279 // Return the number of frames filled in. |
1279 return frames_count; | 1280 return frames_count; |
1280 } | 1281 } |
1281 | 1282 |
1282 // Restore warnings to previous settings. | 1283 // Restore warnings to previous settings. |
1283 #pragma warning(pop) | 1284 #pragma warning(pop) |
1284 | 1285 |
1285 #else // __MINGW32__ | 1286 #else // __MINGW32__ |
1286 void OS::LogSharedLibraryAddresses() { } | 1287 void OS::LogSharedLibraryAddresses() { } |
1287 int OS::StackWalk(OS::StackFrame* frames, int frames_size) { return 0; } | 1288 int OS::StackWalk(Vector<OS::StackFrame> frames) { return 0; } |
1288 #endif // __MINGW32__ | 1289 #endif // __MINGW32__ |
1289 | 1290 |
1290 | 1291 |
1291 double OS::nan_value() { | 1292 double OS::nan_value() { |
1292 #ifdef _MSC_VER | 1293 #ifdef _MSC_VER |
1293 static const __int64 nanval = 0xfff8000000000000; | 1294 static const __int64 nanval = 0xfff8000000000000; |
1294 return *reinterpret_cast<const double*>(&nanval); | 1295 return *reinterpret_cast<const double*>(&nanval); |
1295 #else // _MSC_VER | 1296 #else // _MSC_VER |
1296 return NAN; | 1297 return NAN; |
1297 #endif // _MSC_VER | 1298 #endif // _MSC_VER |
(...skipping 557 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1855 | 1856 |
1856 // Release the thread handles | 1857 // Release the thread handles |
1857 CloseHandle(data_->sampler_thread_); | 1858 CloseHandle(data_->sampler_thread_); |
1858 CloseHandle(data_->profiled_thread_); | 1859 CloseHandle(data_->profiled_thread_); |
1859 } | 1860 } |
1860 | 1861 |
1861 | 1862 |
1862 #endif // ENABLE_LOGGING_AND_PROFILING | 1863 #endif // ENABLE_LOGGING_AND_PROFILING |
1863 | 1864 |
1864 } } // namespace v8::internal | 1865 } } // namespace v8::internal |
OLD | NEW |