]> git.tdb.fi Git - gldbg.git/blobdiff - source/glprint.c
Fix generic attribute arrays and array enabledness tracking
[gldbg.git] / source / glprint.c
index 9721463eff76a4f552f954886553b4cf8f6c244c..6f645a7175bf6cd6daa746973267190f55dd7622 100644 (file)
@@ -8,11 +8,14 @@ Distributed under the GPL
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
+#include <ctype.h>
 #include "arraysize.h"
 #include "enums.h"
 #include "glprint.h"
 #include "tmpalloc.h"
 
+#define UNUSED __attribute__((unused))
+
 typedef struct sGlPrintData
 {
        char *buffer;
@@ -23,6 +26,7 @@ typedef struct sGlPrintData
 static void init_print(GlDecoder *);
 static void glprint_free(void *);
 static void print_gldError(void *, GLenum);
+static void print_unhandled(void *, unsigned short);
 
 GlDecoder *glprint_new(char *buffer, unsigned bufsize)
 {
@@ -44,6 +48,7 @@ GlDecoder *glprint_new(char *buffer, unsigned bufsize)
 
        init_print(dec);
        dec->gldError = print_gldError;
+       dec->unhandled = print_unhandled;
 
        return dec;
 }
@@ -73,6 +78,9 @@ static const char *print_array(const char *fmt, const void *data, unsigned elem_
        char *ptr;
        unsigned i;
 
+       if(!data)
+               return "NULL";
+
        for(cptr=fmt; (type<2 && *cptr); ++cptr)
        {
                if(*cptr=='%')
@@ -115,6 +123,12 @@ static const char *print_data(const void *data, unsigned size)
 {
        if(!data)
                return "NULL";
+       else if((unsigned long)data<0x100000)
+       {
+               char *buffer = tmpalloc(20);
+               snprintf(buffer, 20, "%p", data);
+               return buffer;
+       }
        else if(!size)
                return "/* data */";
        else
@@ -125,10 +139,16 @@ static const char *print_data(const void *data, unsigned size)
        }
 }
 
-#include "glprint.funcs"
+#include "gensrc/glprint.funcs"
 
 static void print_gldError(void *user_data, GLenum code)
 {
        GlPrintData *gpd = (GlPrintData *)user_data;
        snprintf(gpd->buffer, gpd->bufsize, "ERROR: %s", describe_enum(code, "ErrorCode"));
 }
+
+static void print_unhandled(void *user_data, unsigned short func UNUSED)
+{
+       GlPrintData *gpd = (GlPrintData *)user_data;
+       gpd->buffer[0] = 0;
+}