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

Side by Side Diff: src/platform-win32.cc

Issue 23710025: thread isolate for logging calls (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: rebase Created 7 years, 3 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 | « src/platform-solaris.cc ('k') | src/string-stream.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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 980 matching lines...) Expand 10 before | Expand all | Expand 10 after
991 // application is closed. 991 // application is closed.
992 } 992 }
993 993
994 #undef DBGHELP_FUNCTION_LIST 994 #undef DBGHELP_FUNCTION_LIST
995 #undef TLHELP32_FUNCTION_LIST 995 #undef TLHELP32_FUNCTION_LIST
996 #undef DLL_FUNC_VAR 996 #undef DLL_FUNC_VAR
997 #undef DLL_FUNC_TYPE 997 #undef DLL_FUNC_TYPE
998 998
999 999
1000 // Load the symbols for generating stack traces. 1000 // Load the symbols for generating stack traces.
1001 static bool LoadSymbols(HANDLE process_handle) { 1001 static bool LoadSymbols(Isolate* isolate, HANDLE process_handle) {
1002 static bool symbols_loaded = false; 1002 static bool symbols_loaded = false;
1003 1003
1004 if (symbols_loaded) return true; 1004 if (symbols_loaded) return true;
1005 1005
1006 BOOL ok; 1006 BOOL ok;
1007 1007
1008 // Initialize the symbol engine. 1008 // Initialize the symbol engine.
1009 ok = _SymInitialize(process_handle, // hProcess 1009 ok = _SymInitialize(process_handle, // hProcess
1010 NULL, // UserSearchPath 1010 NULL, // UserSearchPath
1011 false); // fInvadeProcess 1011 false); // fInvadeProcess
(...skipping 28 matching lines...) Expand all
1040 0, // hFile 1040 0, // hFile
1041 reinterpret_cast<PSTR>(module_entry.szExePath), // ImageName 1041 reinterpret_cast<PSTR>(module_entry.szExePath), // ImageName
1042 reinterpret_cast<PSTR>(module_entry.szModule), // ModuleName 1042 reinterpret_cast<PSTR>(module_entry.szModule), // ModuleName
1043 reinterpret_cast<DWORD64>(module_entry.modBaseAddr), // BaseOfDll 1043 reinterpret_cast<DWORD64>(module_entry.modBaseAddr), // BaseOfDll
1044 module_entry.modBaseSize); // SizeOfDll 1044 module_entry.modBaseSize); // SizeOfDll
1045 if (base == 0) { 1045 if (base == 0) {
1046 int err = GetLastError(); 1046 int err = GetLastError();
1047 if (err != ERROR_MOD_NOT_FOUND && 1047 if (err != ERROR_MOD_NOT_FOUND &&
1048 err != ERROR_INVALID_HANDLE) return false; 1048 err != ERROR_INVALID_HANDLE) return false;
1049 } 1049 }
1050 LOG(i::Isolate::Current(), 1050 LOG(isolate,
1051 SharedLibraryEvent( 1051 SharedLibraryEvent(
1052 module_entry.szExePath, 1052 module_entry.szExePath,
1053 reinterpret_cast<unsigned int>(module_entry.modBaseAddr), 1053 reinterpret_cast<unsigned int>(module_entry.modBaseAddr),
1054 reinterpret_cast<unsigned int>(module_entry.modBaseAddr + 1054 reinterpret_cast<unsigned int>(module_entry.modBaseAddr +
1055 module_entry.modBaseSize))); 1055 module_entry.modBaseSize)));
1056 cont = _Module32NextW(snapshot, &module_entry); 1056 cont = _Module32NextW(snapshot, &module_entry);
1057 } 1057 }
1058 CloseHandle(snapshot); 1058 CloseHandle(snapshot);
1059 1059
1060 symbols_loaded = true; 1060 symbols_loaded = true;
1061 return true; 1061 return true;
1062 } 1062 }
1063 1063
1064 1064
1065 void OS::LogSharedLibraryAddresses() { 1065 void OS::LogSharedLibraryAddresses(Isolate* isolate) {
1066 // SharedLibraryEvents are logged when loading symbol information. 1066 // SharedLibraryEvents are logged when loading symbol information.
1067 // Only the shared libraries loaded at the time of the call to 1067 // Only the shared libraries loaded at the time of the call to
1068 // LogSharedLibraryAddresses are logged. DLLs loaded after 1068 // LogSharedLibraryAddresses are logged. DLLs loaded after
1069 // initialization are not accounted for. 1069 // initialization are not accounted for.
1070 if (!LoadDbgHelpAndTlHelp32()) return; 1070 if (!LoadDbgHelpAndTlHelp32()) return;
1071 HANDLE process_handle = GetCurrentProcess(); 1071 HANDLE process_handle = GetCurrentProcess();
1072 LoadSymbols(process_handle); 1072 LoadSymbols(isolate, process_handle);
1073 } 1073 }
1074 1074
1075 1075
1076 void OS::SignalCodeMovingGC() { 1076 void OS::SignalCodeMovingGC() {
1077 } 1077 }
1078 1078
1079 1079
1080 // Walk the stack using the facilities in dbghelp.dll and tlhelp32.dll 1080 // Walk the stack using the facilities in dbghelp.dll and tlhelp32.dll
1081 1081
1082 // Switch off warning 4748 (/GS can not protect parameters and local variables 1082 // Switch off warning 4748 (/GS can not protect parameters and local variables
1083 // from local buffer overrun because optimizations are disabled in function) as 1083 // from local buffer overrun because optimizations are disabled in function) as
1084 // it is triggered by the use of inline assembler. 1084 // it is triggered by the use of inline assembler.
1085 #pragma warning(push) 1085 #pragma warning(push)
1086 #pragma warning(disable : 4748) 1086 #pragma warning(disable : 4748)
1087 int OS::StackWalk(Vector<OS::StackFrame> frames) { 1087 int OS::StackWalk(Vector<OS::StackFrame> frames) {
1088 BOOL ok; 1088 BOOL ok;
1089 1089
1090 // Load the required functions from DLL's. 1090 // Load the required functions from DLL's.
1091 if (!LoadDbgHelpAndTlHelp32()) return kStackWalkError; 1091 if (!LoadDbgHelpAndTlHelp32()) return kStackWalkError;
1092 1092
1093 // Get the process and thread handles. 1093 // Get the process and thread handles.
1094 HANDLE process_handle = GetCurrentProcess(); 1094 HANDLE process_handle = GetCurrentProcess();
1095 HANDLE thread_handle = GetCurrentThread(); 1095 HANDLE thread_handle = GetCurrentThread();
1096 1096
1097 // Read the symbols. 1097 // Read the symbols.
1098 if (!LoadSymbols(process_handle)) return kStackWalkError; 1098 if (!LoadSymbols(Isolate::Current(), process_handle)) return kStackWalkError;
1099 1099
1100 // Capture current context. 1100 // Capture current context.
1101 CONTEXT context; 1101 CONTEXT context;
1102 RtlCaptureContext(&context); 1102 RtlCaptureContext(&context);
1103 1103
1104 // Initialize the stack walking 1104 // Initialize the stack walking
1105 STACKFRAME64 stack_frame; 1105 STACKFRAME64 stack_frame;
1106 memset(&stack_frame, 0, sizeof(stack_frame)); 1106 memset(&stack_frame, 0, sizeof(stack_frame));
1107 #ifdef _WIN64 1107 #ifdef _WIN64
1108 stack_frame.AddrPC.Offset = context.Rip; 1108 stack_frame.AddrPC.Offset = context.Rip;
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
1194 1194
1195 // Return the number of frames filled in. 1195 // Return the number of frames filled in.
1196 return frames_count; 1196 return frames_count;
1197 } 1197 }
1198 1198
1199 1199
1200 // Restore warnings to previous settings. 1200 // Restore warnings to previous settings.
1201 #pragma warning(pop) 1201 #pragma warning(pop)
1202 1202
1203 #else // __MINGW32__ 1203 #else // __MINGW32__
1204 void OS::LogSharedLibraryAddresses() { } 1204 void OS::LogSharedLibraryAddresses(Isolate* isolate) { }
1205 void OS::SignalCodeMovingGC() { } 1205 void OS::SignalCodeMovingGC() { }
1206 int OS::StackWalk(Vector<OS::StackFrame> frames) { return 0; } 1206 int OS::StackWalk(Vector<OS::StackFrame> frames) { return 0; }
1207 #endif // __MINGW32__ 1207 #endif // __MINGW32__
1208 1208
1209 1209
1210 uint64_t OS::CpuFeaturesImpliedByPlatform() { 1210 uint64_t OS::CpuFeaturesImpliedByPlatform() {
1211 return 0; // Windows runs on anything. 1211 return 0; // Windows runs on anything.
1212 } 1212 }
1213 1213
1214 1214
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
1333 ASSERT(result); 1333 ASSERT(result);
1334 } 1334 }
1335 1335
1336 1336
1337 1337
1338 void Thread::YieldCPU() { 1338 void Thread::YieldCPU() {
1339 Sleep(0); 1339 Sleep(0);
1340 } 1340 }
1341 1341
1342 } } // namespace v8::internal 1342 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/platform-solaris.cc ('k') | src/string-stream.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698