diff options
author | Eric Anholt <[email protected]> | 2018-11-15 17:31:28 -0800 |
---|---|---|
committer | Eric Anholt <[email protected]> | 2018-11-16 17:49:31 -0800 |
commit | 7e9fc11ff8ee47ad25d96f618f5d1a1c26590083 (patch) | |
tree | 24c363d309addae2e54881024d050e7ed81025df /src/egl/main | |
parent | d971a4230d54069c996bca78b6ed6a6a23377821 (diff) |
egl: Print the actual message to the console from _eglError().
Previously we would print errors on the console like:
libEGL debug: EGL user error 0x3001 (EGL_NOT_INITIALIZED) in eglInitialize
When we had everything we needed for:
libEGL debug: EGL user error 0x3001 (EGL_NOT_INITIALIZED) in eglInitialize: DRI2: failed to find EGLDevice
(for a gbm error in my case)
Reviewed-by: Emil Velikov <[email protected]>
Diffstat (limited to 'src/egl/main')
-rw-r--r-- | src/egl/main/eglcurrent.c | 32 |
1 files changed, 20 insertions, 12 deletions
diff --git a/src/egl/main/eglcurrent.c b/src/egl/main/eglcurrent.c index 7af3011b757..479f231fb8f 100644 --- a/src/egl/main/eglcurrent.c +++ b/src/egl/main/eglcurrent.c @@ -310,20 +310,28 @@ _eglDebugReport(EGLenum error, const char *funcName, mtx_unlock(_eglGlobal.Mutex); - if (callback != NULL) { - char *buf = NULL; + char *message_buf = NULL; + if (message != NULL) { + va_start(args, message); + if (vasprintf(&message_buf, message, args) < 0) + message_buf = NULL; + va_end(args); + } - if (message != NULL) { - va_start(args, message); - if (vasprintf(&buf, message, args) < 0) - buf = NULL; + if (callback != NULL) { + callback(error, funcName, type, thr->Label, thr->CurrentObjectLabel, + message_buf); + } - va_end(args); + if (type == EGL_DEBUG_MSG_CRITICAL_KHR || type == EGL_DEBUG_MSG_ERROR_KHR) { + char *func_message_buf = NULL; + /* Note: _eglError() is often called with msg == thr->currentFuncName */ + if (message_buf && funcName && strcmp(message_buf, funcName) != 0) { + if (asprintf(&func_message_buf, "%s: %s", funcName, message_buf) < 0) + func_message_buf = NULL; } - callback(error, funcName, type, thr->Label, thr->CurrentObjectLabel, buf); - free(buf); + _eglInternalError(error, func_message_buf ? func_message_buf : funcName); + free(func_message_buf); } - - if (type == EGL_DEBUG_MSG_CRITICAL_KHR || type == EGL_DEBUG_MSG_ERROR_KHR) - _eglInternalError(error, funcName); + free(message_buf); } |