Changeset 53524 in vbox for trunk/src/VBox
- Timestamp:
- Dec 12, 2014 3:09:27 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/GuestHost/OpenGL/util/error.c
r53390 r53524 25 25 #ifdef RT_OS_WINDOWS 26 26 # include <windows.h> 27 # include "cr_environment.h" 27 28 #endif 28 29 … … 32 33 static void logMessageV(const char *pszPrefix, const char *pszFormat, va_list va) 33 34 { 34 char *pszMessage; 35 36 RTStrAPrintfV(&pszMessage, pszFormat, va); 37 if (pszMessage != NULL) 38 { 39 LogRel(("%s%s\n", pszPrefix, pszMessage)); 35 va_list vaCopy; 36 va_copy(vaCopy, va); 37 LogRel(("%s%N\n", pszPrefix, pszFormat, &vaCopy)); 38 va_end(vaCopy); 39 40 40 #ifdef IN_GUEST 41 RTStrmPrintf(g_pStdErr, "%s%s\n", pszPrefix, pszMessage);42 #endif 43 RTStrFree(pszMessage);44 } 41 va_copy(vaCopy, va); /* paranoia */ 42 RTStrmPrintf(g_pStdErr, "%s%N\n", pszPrefix, pszFormat, &vaCopy); 43 va_end(vaCopy); 44 #endif 45 45 } 46 46 … … 54 54 } 55 55 56 static void logDebugV(const char *pszPrefix, const char *pszFormat, va_list va)57 {58 char *pszMessage;59 60 RTStrAPrintfV(&pszMessage, pszFormat, va);61 if (pszMessage != NULL)62 {63 #if defined(DEBUG_vgalitsy) || defined(DEBUG_galitsyn)64 LogRel(("%s%s\n", pszPrefix, pszMessage));65 #else66 Log(("%s%s\n", pszPrefix, pszMessage));67 #endif68 RTStrFree(pszMessage);69 }70 }71 72 56 DECLEXPORT(void) crError(const char *pszFormat, ... ) 73 57 { 74 58 va_list va; 75 59 #ifdef WINDOWS 76 DWORD err; 77 #endif 78 79 #ifdef WINDOWS 80 if ((err = GetLastError()) != 0 && crGetenv("CR_WINDOWS_ERRORS") != NULL ) 81 { 82 char *pszWindowsMessage; 60 DWORD dwLastErr; 61 #endif 62 63 #ifdef WINDOWS 64 /* Log last error on windows. */ 65 dwLastErr = GetLastError(); 66 if (dwLastErr != 0 && crGetenv("CR_WINDOWS_ERRORS") != NULL) 67 { 68 LPTSTR pszWindowsMessage; 83 69 84 70 SetLastError(0); 85 FormatMessage( FORMAT_MESSAGE_ALLOCATE_BUFFER | 86 FORMAT_MESSAGE_FROM_SYSTEM | 87 FORMAT_MESSAGE_MAX_WIDTH_MASK, NULL, err, 88 MAKELANGID( LANG_NEUTRAL, SUBLANG_DEFAULT ), 89 (LPTSTR) &pszWindowsMessage, 0, NULL ); 71 FormatMessageA( FORMAT_MESSAGE_ALLOCATE_BUFFER 72 | FORMAT_MESSAGE_FROM_SYSTEM 73 | FORMAT_MESSAGE_MAX_WIDTH_MASK, 74 NULL, dwLastErr, 75 MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), 76 (LPTSTR)&pszWindowsMessage, 0, NULL); 90 77 if (pszWindowsMessage) 91 78 { 92 logMessage("OpenGL, Windows error: \n", "%s", pszWindowsMessage);79 logMessage("OpenGL, Windows error: ", "%u\n%s", dwLastErr, pszWindowsMessage); 93 80 LocalFree(pszWindowsMessage); 94 81 } 95 82 else 96 logMessage("OpenGL, Windows error: \n", "%ld", (long) err); 97 } 98 #endif 83 logMessage("OpenGL, Windows error: ", "%u", dwLastErr); 84 } 85 #endif 86 87 /* The message. */ 99 88 va_start(va, pszFormat); 100 89 logMessageV("OpenGL Error: ", pszFormat, va); 101 90 va_end(va); 91 92 /* Dump core or activate the debugger in debug builds. */ 102 93 AssertFailed(); 94 103 95 #ifdef IN_GUEST 104 96 /* Give things a chance to close down. */ … … 131 123 132 124 va_start(va, pszFormat); 133 logDebugV("OpenGL Debug: ", pszFormat, va); 125 #if defined(DEBUG_vgalitsy) || defined(DEBUG_galitsyn) 126 LogRel(("OpenGL Debug: %N\n", pszFormat, &va)); 127 #else 128 Log(("OpenGL Debug: %N\n", pszFormat, &va)); 129 #endif 134 130 va_end(va); 135 131 }
Note:
See TracChangeset
for help on using the changeset viewer.