Changeset 47151 in vbox for trunk/src/VBox/Additions/common
- Timestamp:
- Jul 15, 2013 10:47:42 AM (12 years ago)
- svn:sync-xref-src-repo-rev:
- 87253
- Location:
- trunk/src/VBox/Additions/common/crOpenGL
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/common/crOpenGL/load.c
r46757 r47151 397 397 crUnlockMutex(mutex); 398 398 # if defined(WINDOWS) 399 if ( RTThreadGetState(stub.hSyncThread)!=RTTHREADSTATE_TERMINATED)399 if (stub.hSyncThread && RTThreadGetState(stub.hSyncThread)!=RTTHREADSTATE_TERMINATED) 400 400 { 401 401 HANDLE hNative; … … 820 820 # ifdef VBOX_WITH_WDDM 821 821 HMODULE hVBoxD3D = NULL; 822 HRESULT hr;823 822 GLint spuConnection = 0; 824 823 # endif … … 938 937 int i; 939 938 int disable_sync = 0; 939 #if defined(WINDOWS) && defined(VBOX_WITH_WDDM) 940 HMODULE hVBoxD3D = NULL; 941 #endif 940 942 941 943 stubInitVars(); … … 954 956 } 955 957 #elif defined(WINDOWS) && defined(VBOX_WITH_WDDM) 956 if (stub.bNewPresent) 958 hVBoxD3D = NULL; 959 if (!GetModuleHandleEx(0, VBOX_MODNAME_DISPD3D, &hVBoxD3D)) 960 { 961 crDebug("GetModuleHandleEx failed err %d", GetLastError()); 962 hVBoxD3D = NULL; 963 } 964 965 if (hVBoxD3D) 957 966 { 958 967 disable_sync = 1; 959 968 crDebug("running with %s", VBOX_MODNAME_DISPD3D); 969 stub.trackWindowVisibleRgn = 0; 970 stub.trackWindowSize = 0; 971 stub.trackWindowPos = 0; 972 stub.trackWindowVisibility = 0; 960 973 stub.trackWindowVisibleRgn = 0; 961 974 stub.bRunningUnderWDDM = true; … … 1116 1129 #include <windows.h> 1117 1130 1118 #if def DEBUG_misha1131 #if 1//def DEBUG_misha 1119 1132 /* debugging: this is to be able to catch first-chance notifications 1120 1133 * for exceptions other than EXCEPTION_BREAKPOINT in kernel debugger */ … … 1123 1136 1124 1137 #ifdef VDBG_VEHANDLER 1125 static PVOID g_VBoxWDbgVEHandler = NULL; 1126 static DWORD g_VBoxWDbgVEHExit = 1; 1138 # include <dbghelp.h> 1139 static PVOID g_VBoxVehHandler = NULL; 1140 static DWORD g_VBoxVehEnable = 0; 1141 1142 /* generate a crash dump on exception */ 1143 #define VBOXVEH_F_DUMP 0x00000001 1144 /* generate a debugger breakpoint exception */ 1145 #define VBOXVEH_F_BREAK 0x00000002 1146 /* exit on exception */ 1147 #define VBOXVEH_F_EXIT 0x00000004 1148 1149 static DWORD g_VBoxVehFlags = VBOXVEH_F_DUMP 1150 #ifdef DEBUG_misha 1151 | VBOXVEH_F_BREAK 1152 #endif 1153 ; 1154 1155 typedef BOOL WINAPI FNVBOXDBG_MINIDUMPWRITEDUMP(HANDLE hProcess, 1156 DWORD ProcessId, 1157 HANDLE hFile, 1158 MINIDUMP_TYPE DumpType, 1159 PMINIDUMP_EXCEPTION_INFORMATION ExceptionParam, 1160 PMINIDUMP_USER_STREAM_INFORMATION UserStreamParam, 1161 PMINIDUMP_CALLBACK_INFORMATION CallbackParam); 1162 typedef FNVBOXDBG_MINIDUMPWRITEDUMP *PFNVBOXDBG_MINIDUMPWRITEDUMP; 1163 1164 static HMODULE g_hVBoxMdDbgHelp = NULL; 1165 static PFNVBOXDBG_MINIDUMPWRITEDUMP g_pfnVBoxMdMiniDumpWriteDump = NULL; 1166 static uint32_t g_cVBoxMdFilePrefixLen = 0; 1167 static WCHAR g_aszwVBoxMdFilePrefix[MAX_PATH]; 1168 static WCHAR g_aszwVBoxMdDumpCount = 0; 1169 static MINIDUMP_TYPE g_enmVBoxMdDumpType = MiniDumpNormal 1170 | MiniDumpWithDataSegs 1171 | MiniDumpWithFullMemory 1172 | MiniDumpWithHandleData 1173 //// | MiniDumpFilterMemory 1174 //// | MiniDumpScanMemory 1175 // | MiniDumpWithUnloadedModules 1176 //// | MiniDumpWithIndirectlyReferencedMemory 1177 //// | MiniDumpFilterModulePaths 1178 // | MiniDumpWithProcessThreadData 1179 // | MiniDumpWithPrivateReadWriteMemory 1180 //// | MiniDumpWithoutOptionalData 1181 // | MiniDumpWithFullMemoryInfo 1182 // | MiniDumpWithThreadInfo 1183 // | MiniDumpWithCodeSegs 1184 // | MiniDumpWithFullAuxiliaryState 1185 // | MiniDumpWithPrivateWriteCopyMemory 1186 // | MiniDumpIgnoreInaccessibleMemory 1187 // | MiniDumpWithTokenInformation 1188 //// | MiniDumpWithModuleHeaders 1189 //// | MiniDumpFilterTriage 1190 ; 1191 1192 1193 1194 #define VBOXMD_DUMP_DIR_PREFIX_DEFAULT L"C:\\dumps\\vboxdmp" 1195 1196 static HMODULE loadSystemDll(const char *pszName) 1197 { 1198 char szPath[MAX_PATH]; 1199 UINT cchPath = GetSystemDirectoryA(szPath, sizeof(szPath)); 1200 size_t cbName = strlen(pszName) + 1; 1201 if (cchPath + 1 + cbName > sizeof(szPath)) 1202 { 1203 SetLastError(ERROR_FILENAME_EXCED_RANGE); 1204 return NULL; 1205 } 1206 szPath[cchPath] = '\\'; 1207 memcpy(&szPath[cchPath + 1], pszName, cbName); 1208 return LoadLibraryA(szPath); 1209 } 1210 1211 static DWORD vboxMdMinidumpCreate(struct _EXCEPTION_POINTERS *pExceptionInfo) 1212 { 1213 WCHAR aszwMdFileName[MAX_PATH]; 1214 HANDLE hProcess = GetCurrentProcess(); 1215 DWORD ProcessId = GetCurrentProcessId(); 1216 MINIDUMP_EXCEPTION_INFORMATION ExceptionInfo; 1217 HANDLE hFile; 1218 DWORD winErr = ERROR_SUCCESS; 1219 1220 if (!g_pfnVBoxMdMiniDumpWriteDump) 1221 { 1222 if (!g_hVBoxMdDbgHelp) 1223 { 1224 g_hVBoxMdDbgHelp = loadSystemDll("DbgHelp.dll"); 1225 if (!g_hVBoxMdDbgHelp) 1226 return GetLastError(); 1227 } 1228 1229 g_pfnVBoxMdMiniDumpWriteDump = (PFNVBOXDBG_MINIDUMPWRITEDUMP)GetProcAddress(g_hVBoxMdDbgHelp, "MiniDumpWriteDump"); 1230 if (!g_pfnVBoxMdMiniDumpWriteDump) 1231 return GetLastError(); 1232 } 1233 1234 /* @todo: this is a tmp stuff until we get that info from the settings properly */ 1235 if (!g_cVBoxMdFilePrefixLen) 1236 { 1237 g_cVBoxMdFilePrefixLen = sizeof (VBOXMD_DUMP_DIR_PREFIX_DEFAULT)/sizeof (g_aszwVBoxMdFilePrefix[0]) - 1 /* <- don't include nul terminator */; 1238 memcpy(g_aszwVBoxMdFilePrefix, VBOXMD_DUMP_DIR_PREFIX_DEFAULT, sizeof (VBOXMD_DUMP_DIR_PREFIX_DEFAULT)); 1239 } 1240 1241 1242 if (RT_ELEMENTS(aszwMdFileName) <= g_cVBoxMdFilePrefixLen) 1243 { 1244 return ERROR_INVALID_STATE; 1245 } 1246 1247 ++g_aszwVBoxMdDumpCount; 1248 1249 memcpy(aszwMdFileName, g_aszwVBoxMdFilePrefix, g_cVBoxMdFilePrefixLen * sizeof (g_aszwVBoxMdFilePrefix[0])); 1250 swprintf(aszwMdFileName + g_cVBoxMdFilePrefixLen, RT_ELEMENTS(aszwMdFileName) - g_cVBoxMdFilePrefixLen, L"%d_%d.dmp", ProcessId, g_aszwVBoxMdDumpCount); 1251 1252 hFile = CreateFileW(aszwMdFileName, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); 1253 if (hFile == INVALID_HANDLE_VALUE) 1254 return GetLastError(); 1255 1256 ExceptionInfo.ThreadId = GetCurrentThreadId(); 1257 ExceptionInfo.ExceptionPointers = pExceptionInfo; 1258 ExceptionInfo.ClientPointers = FALSE; 1259 1260 if (!g_pfnVBoxMdMiniDumpWriteDump(hProcess, ProcessId, hFile, g_enmVBoxMdDumpType, &ExceptionInfo, NULL, NULL)) 1261 winErr = GetLastError(); 1262 1263 CloseHandle(hFile); 1264 return winErr; 1265 } 1266 1127 1267 LONG WINAPI vboxVDbgVectoredHandler(struct _EXCEPTION_POINTERS *pExceptionInfo) 1128 1268 { … … 1139 1279 case EXCEPTION_INT_DIVIDE_BY_ZERO: 1140 1280 case EXCEPTION_ILLEGAL_INSTRUCTION: 1141 CRASSERT(0); 1142 if (g_VBoxWDbgVEHExit) 1281 if (g_VBoxVehFlags & VBOXVEH_F_BREAK) 1282 { 1283 BOOL fBreak = TRUE; 1284 if (pExceptionRecord->ExceptionCode == EXCEPTION_BREAKPOINT) 1285 { 1286 HANDLE hProcess = GetCurrentProcess(); 1287 BOOL fDebuggerPresent = FALSE; 1288 /* we do not want to generate breakpoint exceptions recursively, so do it only when running under debugger */ 1289 if (CheckRemoteDebuggerPresent(hProcess, &fDebuggerPresent)) 1290 fBreak = !!fDebuggerPresent; 1291 else 1292 fBreak = FALSE; /* <- the function has failed, don't break for sanity */ 1293 } 1294 1295 if (fBreak) 1296 { 1297 RT_BREAKPOINT(); 1298 } 1299 } 1300 1301 if (g_VBoxVehFlags & VBOXVEH_F_DUMP) 1302 vboxMdMinidumpCreate(pExceptionInfo); 1303 1304 if (g_VBoxVehFlags & VBOXVEH_F_EXIT) 1143 1305 exit(1); 1144 1306 break; … … 1151 1313 void vboxVDbgVEHandlerRegister() 1152 1314 { 1153 CRASSERT(!g_VBox WDbgVEHandler);1154 g_VBox WDbgVEHandler = AddVectoredExceptionHandler(1,vboxVDbgVectoredHandler);1155 CRASSERT(g_VBox WDbgVEHandler);1315 CRASSERT(!g_VBoxVehHandler); 1316 g_VBoxVehHandler = AddVectoredExceptionHandler(1,vboxVDbgVectoredHandler); 1317 CRASSERT(g_VBoxVehHandler); 1156 1318 } 1157 1319 … … 1159 1321 { 1160 1322 ULONG uResult; 1161 if (g_VBox WDbgVEHandler)1162 { 1163 uResult = RemoveVectoredExceptionHandler(g_VBox WDbgVEHandler);1323 if (g_VBoxVehHandler) 1324 { 1325 uResult = RemoveVectoredExceptionHandler(g_VBoxVehHandler); 1164 1326 CRASSERT(uResult); 1165 g_VBox WDbgVEHandler = NULL;1327 g_VBoxVehHandler = NULL; 1166 1328 } 1167 1329 } … … 1186 1348 1187 1349 #ifdef VDBG_VEHANDLER 1188 vboxVDbgVEHandlerRegister(); 1350 g_VBoxVehEnable = !!crGetenv("CR_DBG_VEH_ENABLE"); 1351 if (g_VBoxVehEnable) 1352 vboxVDbgVEHandlerRegister(); 1189 1353 #endif 1190 1354 … … 1201 1365 crDebug("Failed to connect to host (is guest 3d acceleration enabled?), aborting ICD load."); 1202 1366 #ifdef VDBG_VEHANDLER 1203 vboxVDbgVEHandlerUnregister(); 1367 if (g_VBoxVehEnable) 1368 vboxVDbgVEHandlerUnregister(); 1204 1369 #endif 1205 1370 return FALSE; … … 1207 1372 else 1208 1373 { 1209 /* @todo: impl proper detection */1210 #ifndef DEBUG_misha1211 stub.bNewPresent = true;1212 #endif1213 1214 1374 crNetFreeConnection(ns.conn); 1215 1375 } … … 1236 1396 1237 1397 #ifdef VDBG_VEHANDLER 1238 vboxVDbgVEHandlerUnregister(); 1398 if (g_VBoxVehEnable) 1399 vboxVDbgVEHandlerUnregister(); 1239 1400 #endif 1240 1401 break; -
trunk/src/VBox/Additions/common/crOpenGL/stub.h
r46757 r47151 261 261 # ifdef VBOX_WITH_WDDM 262 262 bool bRunningUnderWDDM; 263 bool bNewPresent;264 263 # endif 265 264 #endif
Note:
See TracChangeset
for help on using the changeset viewer.