Mesa (mesa_7_5_branch): mesa: recognize and eliminate repeated error messages

Keith Whitwell keithw at kemper.freedesktop.org
Wed Jul 15 12:32:29 UTC 2009


Module: Mesa
Branch: mesa_7_5_branch
Commit: fdeb77899052302053459b8a840a747346e30468
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=fdeb77899052302053459b8a840a747346e30468

Author: Keith Whitwell <keithw at vmware.com>
Date:   Wed Jul 15 13:29:58 2009 +0100

mesa: recognize and eliminate repeated error messages

---

 src/mesa/main/imports.c |   34 +++++++++++++++++++++++++++++++---
 src/mesa/main/mtypes.h  |    7 +++++++
 2 files changed, 38 insertions(+), 3 deletions(-)

diff --git a/src/mesa/main/imports.c b/src/mesa/main/imports.c
index 3916c62..1722579 100644
--- a/src/mesa/main/imports.c
+++ b/src/mesa/main/imports.c
@@ -1021,6 +1021,22 @@ output_if_debug(const char *prefixString, const char *outputString,
    }
 }
 
+static const char *error_string( GLenum error );
+
+static void flush_delayed_errors( GLcontext *ctx )
+{
+   char s2[MAXSTRING];
+
+   if (ctx->ErrorDebugCount) {
+      _mesa_snprintf(s2, MAXSTRING, "%d similar %s errors", 
+                     ctx->ErrorDebugCount,
+                     error_string(ctx->ErrorValue));
+
+      output_if_debug("Mesa: ", s2, GL_TRUE);
+
+      ctx->ErrorDebugCount = 0;
+   }
+}
 
 /**
  * Report a warning (a recoverable error condition) to stderr if
@@ -1034,10 +1050,12 @@ _mesa_warning( GLcontext *ctx, const char *fmtString, ... )
 {
    char str[MAXSTRING];
    va_list args;
-   (void) ctx;
    va_start( args, fmtString );  
    (void) vsnprintf( str, MAXSTRING, fmtString, args );
    va_end( args );
+   
+   if (ctx)
+      flush_delayed_errors( ctx );
 
    output_if_debug("Mesa warning", str, GL_TRUE);
 }
@@ -1126,16 +1144,26 @@ _mesa_error( GLcontext *ctx, GLenum error, const char *fmtString, ... )
 #endif
    }
 
-   if (debug) {
-      {
+   if (debug) {      
+      if (ctx->ErrorValue == error &&
+          ctx->ErrorDebugFmtString == fmtString) {
+         ctx->ErrorDebugCount++;
+      }
+      else {
          char s[MAXSTRING], s2[MAXSTRING];
          va_list args;
+
+         flush_delayed_errors( ctx );
+         
          va_start(args, fmtString);
          vsnprintf(s, MAXSTRING, fmtString, args);
          va_end(args);
 
          _mesa_snprintf(s2, MAXSTRING, "%s in %s", error_string(error), s);
          output_if_debug("Mesa: User error", s2, GL_TRUE);
+         
+         ctx->ErrorDebugFmtString = fmtString;
+         ctx->ErrorDebugCount = 0;
       }
    }
 
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index bdaa497..3b0ebcb 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -2955,6 +2955,13 @@ struct __GLcontextRec
 #endif
 
    GLenum ErrorValue;        /**< Last error code */
+
+   /**
+    * Recognize and silence repeated error debug messages in buggy apps.
+    */
+   const char *ErrorDebugFmtString;
+   GLuint ErrorDebugCount;
+
    GLenum RenderMode;        /**< either GL_RENDER, GL_SELECT, GL_FEEDBACK */
    GLbitfield NewState;      /**< bitwise-or of _NEW_* flags */
 




More information about the mesa-commit mailing list