VirtualBox

source: vbox/trunk/src/VBox/GuestHost/OpenGL/util/error.c@ 78292

Last change on this file since 78292 was 78190, checked in by vboxsync, 6 years ago

Merge first stage of the Chromium cleanup from the branch:

  • r129818 (Remove VBOX_WITH_CR_DISPLAY_LISTS and accompanying code as it was disabled since r108676 and was never brought back (see ​bugref:3456 and ​bugref:8485))
  • r129819 (HostServices/SharedOpenGL: Remove unused main entry point from upstream server process based implementation)
  • r129820 (HostServices/SharedOpenGL: Started eliminating all backends other than HGCM. They are not used and probably wouldn't work anymore anyway)
  • r129821 (HostServices/SharedOpenGL,GuestHost/OpenGLAdditions/common/crOpenGL: Kill crTimer* API as it is not used anywhere)
  • r129822 (HostServices/SharedOpenGL,GuestHost/OpenGLAdditions/common/crOpenGL: Kill most from cr_process.h apart from two used methods)
  • r129823 (HostServices/SharedOpenGL,GuestHost/OpenGLAdditions/common/crOpenGL: Kill crList* API as it is unused)
  • r129824 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Kill crHullInteriorBox API as it is unused)
  • r129825 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Kill crWarpPoint API as it is unused)
  • r129826 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Kill CrSa* API as it is unused and not even compiled in)
  • r129827 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Kill cr_bbox.h as it is unused)
  • r129828 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Remove a few crParseUrl() two uses)
  • r129829 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Remove last crParseURL() use)
  • r129830 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Remove crParseURL())
  • r129831 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Remove VBOX_WITH_COCOA_QT and related code when not set as it is the default for years now and we don't support anything else anymore)
  • r129832 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Remove unused cr_logo.h)
  • r129833 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Remove unused crut_api.h and crut_clientapi.h)
  • r129834 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Remove unused cr_dmx.h)
  • r129835 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Remove unused cr_perf.h)
  • r129836 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Remove cr_rand.h and friends as it is not actively used anywhere)
  • r129837 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Get rid of all the swapped versions in the packer SPU, we never change endianess from guest to host and don't need it)
  • r129838 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Remove more swapper versions in the packer related code)
  • r129839 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Remove more swapper versions in the packer related code)
  • r129840 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Remove unused pack_pica.c)
  • r129841 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Remove more swapper versions in the packer related code)
  • r129842 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Get rid of cr_endianess.h and friends)
  • r129843 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Get rid of unused lowercase.py)
  • r129844 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Get rid of unused cr_calllists.h and friends)
  • r129845 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Get rid of completely unused idpool.c, not even compiled in)
  • r129846 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Get rid of unused cr_debugopcodes.h and friends)
  • r129847 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Make the cr_mem.h API inline and get rid of the implementation in the util library)
  • r129848 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Get rid of SPUOptions and related code as it is of no use for us)
  • r129849 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Get rid of cr_environment.h and friends and convert usage to RTEnv* APIs)
  • r129850 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Get rid of unused renderspu_agl.c)
  • r129851 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Remove unused code in cr_htable.h)
  • r129853 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Introduce a state paremeter for the unpacker workers instead of reyling on global variables, work in progress)
  • r129854 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Let the caller of crUnpack set up the initial state. This allows to get rid of the global return_ptr and writeback_ptr as they get supplied in the unpacker state by the server)
  • r129855 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Get rid of the cr_lastDispatch and cr_unpackDispatch as they are of no use now)
  • r129856 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Get rid of the global cr_unpackData and cr_unpackDataEnd symbols by indtroducing another hack to make it possible for certail server dispatch callbacks to access the data buffer)
  • r129857 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: build fix for release builds)
  • r129858 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Make the pointer to the unpacker state non const (is required for the access verification))
  • r129859 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: First iteration of the buffer size validation to prevent out of bound read access + added todos for places where additional checks are needed)
  • r129860 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Working on remaining verification todos)
  • r129861 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Working on remaining verification todos)
  • r129871 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Working on remaining verification todos)
  • r129872 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Stop as soon as the unpacker encountered an error)
  • r129876 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Working on remaining verification todos)
  • r129880 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Working on remaining verification todos)
  • r129882 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Fixed some offsets in unpack_texture.c, 3DMark03 renders correctly again)
  • r130013 (HostServices/SharedOpenGL: Convert files to C++ so we can use C99 featuers on Windows with cl.exe)
  • r130014 (HostServices/SharedOpenGL,GuestHost/OpenGL: WIndows build fixes)
  • r130015 (HostServices/SharedOpenGL,GuestHost/OpenGL: More Windows build fixes)
  • r130036 (Config.kmk: Fix linker error on Windows by temporarily disabling the use of VBoxGuestR3DllMinW2K)
  • r130094 (src/VBox/GuestHost/OpenGL: Revert inlining the allocation/free functions in R3 completely as it doesn't work on Windows if memory is allocated and freed across different DLLs which don't share a common CRT, causes crashes in RtlValidtaeHeap())
  • r130095 (src/VBox/GuestHost/OpenGL,src/VBox/Additions/common/crOpenGL/pack: Don't use floating point specifiers in packspu_GetString() to avoid R6002 errors (couldn't fully understand why they occur suddenly after the rework but this gets rid of it))
  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 5.2 KB
Line 
1/* $Id: error.c 78190 2019-04-18 00:07:07Z vboxsync $ */
2/** @file
3 * VBox crOpenGL error logging
4 */
5
6/*
7 * Copyright (C) 2014-2019 Oracle Corporation
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.virtualbox.org. This file is free software;
11 * you can redistribute it and/or modify it under the terms of the GNU
12 * General Public License (GPL) as published by the Free Software
13 * Foundation, in version 2 as it comes in the "COPYING" file of the
14 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16 */
17
18#define LOG_GROUP LOG_GROUP_SHARED_CROPENGL
19
20#include <iprt/string.h>
21#include <iprt/stream.h>
22#include <iprt/initterm.h>
23#include <iprt/asm.h>
24#include <iprt/assert.h>
25#include <iprt/buildconfig.h>
26
27
28#include <VBox/log.h>
29#include <iprt/env.h>
30
31#ifdef RT_OS_WINDOWS
32# include <iprt/win/windows.h>
33# include "cr_error.h"
34# include "VBox/VBoxGuestLib.h"
35# include "iprt/initterm.h"
36#else
37# include "cr_error.h"
38#endif
39
40#include <signal.h>
41#include <stdlib.h>
42
43
44/*
45 * Stuff that needs to be dragged into the link because other DLLs needs it.
46 * See also VBoxDeps.cpp in iprt and xpcom.
47 */
48#ifdef _MSC_VER
49# pragma warning(push)
50# pragma warning(disable:4232) /* nonstandard extension used: 'g_VBoxRTDeps' : address of dllimport 'RTBldCfgRevision' is not static, identiy not guaranteed */
51#endif
52PFNRT g_VBoxRTDeps[] =
53{
54 (PFNRT)RTAssertShouldPanic,
55 (PFNRT)ASMAtomicReadU64,
56 (PFNRT)ASMAtomicCmpXchgU64,
57 (PFNRT)ASMBitFirstSet,
58 (PFNRT)RTBldCfgRevision,
59};
60#ifdef _MSC_VER
61# pragma warning(pop)
62#endif
63
64
65static void logMessageV(const char *pszPrefix, const char *pszFormat, va_list va)
66{
67 va_list vaCopy;
68 if (RTR3InitIsInitialized())
69 {
70 va_copy(vaCopy, va);
71 LogRel(("%s%N\n", pszPrefix, pszFormat, &vaCopy));
72 va_end(vaCopy);
73 }
74
75#ifdef IN_GUEST /** @todo Could be subject to pre-iprt-init issues, but hopefully not... */
76 va_copy(vaCopy, va);
77 RTStrmPrintf(g_pStdErr, "%s%N\n", pszPrefix, pszFormat, &vaCopy);
78 va_end(vaCopy);
79#endif
80}
81
82#ifdef WINDOWS
83static void logMessage(const char *pszPrefix, const char *pszFormat, ...)
84{
85 va_list va;
86
87 va_start(va, pszFormat);
88 logMessageV(pszPrefix, pszFormat, va);
89 va_end(va);
90}
91#endif
92
93DECLEXPORT(void) crError(const char *pszFormat, ...)
94{
95 va_list va;
96#ifdef WINDOWS
97 DWORD dwLastErr;
98#endif
99
100#ifdef WINDOWS
101 /* Log last error on windows. */
102 dwLastErr = GetLastError();
103 if (dwLastErr != 0 && RTEnvGet("CR_WINDOWS_ERRORS") != NULL)
104 {
105 LPTSTR pszWindowsMessage;
106
107 SetLastError(0);
108 FormatMessageA( FORMAT_MESSAGE_ALLOCATE_BUFFER
109 | FORMAT_MESSAGE_FROM_SYSTEM
110 | FORMAT_MESSAGE_MAX_WIDTH_MASK,
111 NULL, dwLastErr,
112 MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
113 (LPTSTR)&pszWindowsMessage, 0, NULL);
114 if (pszWindowsMessage)
115 {
116 logMessage("OpenGL, Windows error: ", "%u\n%s", dwLastErr, pszWindowsMessage);
117 LocalFree(pszWindowsMessage);
118 }
119 else
120 logMessage("OpenGL, Windows error: ", "%u", dwLastErr);
121 }
122#endif
123
124 /* The message. */
125 va_start(va, pszFormat);
126 logMessageV("OpenGL Error: ", pszFormat, va);
127 va_end(va);
128
129#ifdef DEBUG
130 /* Let's interrupt App execution only on debug builds and return
131 * bad status to upper level on release ones. */
132# ifdef IN_GUEST
133 /* Trigger debugger's breakpoint handler. */
134 ASMBreakpoint();
135# else
136 /* Dump core or activate the debugger in debug builds. */
137 AssertFailed();
138# endif
139#endif /* DEBUG */
140}
141
142DECLEXPORT(void) crWarning(const char *pszFormat, ...)
143{
144 if (RTR3InitIsInitialized())
145 {
146 va_list va;
147
148 va_start(va, pszFormat);
149 logMessageV("OpenGL Warning: ", pszFormat, va);
150 va_end(va);
151 }
152}
153
154DECLEXPORT(void) crInfo(const char *pszFormat, ...)
155{
156 if (RTR3InitIsInitialized())
157 {
158 va_list va;
159
160 va_start(va, pszFormat);
161 logMessageV("OpenGL Info: ", pszFormat, va);
162 va_end(va);
163 }
164}
165
166DECLEXPORT(void) crDebug(const char *pszFormat, ...)
167{
168 if (RTR3InitIsInitialized())
169 {
170 va_list va;
171
172 va_start(va, pszFormat);
173#if defined(DEBUG_vgalitsy) || defined(DEBUG_galitsyn)
174 LogRel(("OpenGL Debug: %N\n", pszFormat, &va));
175#else
176 Log(("OpenGL Debug: %N\n", pszFormat, &va));
177#endif
178 va_end(va);
179 }
180}
181
182#if defined(RT_OS_WINDOWS)
183BOOL WINAPI DllMain(HINSTANCE hDLLInst, DWORD fdwReason, LPVOID lpvReserved)
184{
185 (void) lpvReserved; (void) hDLLInst;
186
187 switch (fdwReason)
188 {
189 case DLL_PROCESS_ATTACH:
190 {
191 int rc;
192 rc = RTR3InitDll(RTR3INIT_FLAGS_UNOBTRUSIVE); CRASSERT(rc==0);
193# ifdef IN_GUEST
194 rc = VbglR3Init();
195# endif
196 LogRel(("crUtil DLL loaded.\n"));
197# if defined(DEBUG_misha)
198 char aName[MAX_PATH];
199 GetModuleFileNameA(hDLLInst, aName, RT_ELEMENTS(aName));
200 crDbgCmdSymLoadPrint(aName, hDLLInst);
201# endif
202 break;
203 }
204
205 case DLL_PROCESS_DETACH:
206 {
207 LogRel(("crUtil DLL unloaded."));
208# ifdef IN_GUEST
209 VbglR3Term();
210# endif
211 }
212
213 default:
214 break;
215 }
216
217 return TRUE;
218}
219#endif
220
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette