]> git.cworth.org Git - apitrace/commitdiff
Trace parse debugging.
authorJosé Fonseca <jfonseca@vmware.com>
Thu, 25 Nov 2010 15:48:46 +0000 (15:48 +0000)
committerJosé Fonseca <jfonseca@vmware.com>
Thu, 25 Nov 2010 15:48:46 +0000 (15:48 +0000)
dump.cpp
trace_parser.hpp

index 8c757ebf3e07776525a52721f4e4b4be2964a403..d46fbe9a37286e6086bc5e1a44c0c87b0d5a20ea 100644 (file)
--- a/dump.cpp
+++ b/dump.cpp
@@ -33,8 +33,10 @@ int main(int argc, char **argv)
       Trace::Parser p;
       if (p.open(argv[i])) {
           Trace::Call *call;
-          while ((call = p.parse_call())) {
+          call = p.parse_call();
+          while (call) {
               std::cout << *call;
+              call = p.parse_call();
           }
       }
    }
index ed9fc7ecb4327b19b83fa131f55f63d4e9b5cdf2..6a2c92f352ddedfba4b021220d36ef6f9230f76e 100644 (file)
@@ -39,6 +39,9 @@
 #include "trace_model.hpp"
 
 
+#define TRACE_VERBOSE 0
+
+
 namespace Trace {
 
 
@@ -254,12 +257,17 @@ done:
        std::string name;
        size_t id = read_uint();
        if (id >= names.size()) {
+           assert(id == names.size());
            name = read_string();
            names[id] = name;
            return name;
        } else {
-           return names[id];
+           name = names[id];
        }
+#if TRACE_VERBOSE
+       std::cerr << "\tNAME " << id << " " << name << "\n";
+#endif
+       return name;
    }
    
    std::string read_string(void) {
@@ -271,8 +279,8 @@ done:
       gzread(file, buf, len);
       std::string value(buf, len);
       delete [] buf;
-#ifdef TRACE_VERBOSE
-      std::cerr << '"' << value << '"' << "\n";
+#if TRACE_VERBOSE
+      std::cerr << "\tSTRING \"" << value << "\"\n";
 #endif
       return value;
    }
@@ -289,19 +297,19 @@ done:
          value |= (unsigned long long)(c & 0x7f) << shift;
          shift += 7;
       } while(c & 0x80);
-#ifdef TRACE_VERBOSE
-      std::cerr << value << "\n";
+#if TRACE_VERBOSE
+      std::cerr << "\tUINT " << value << "\n";
 #endif
       return value;
    }
 
    int read_byte(void) {
       int c = gzgetc(file);
-#ifdef TRACE_VERBOSE
+#if TRACE_VERBOSE
       if (c < 0)
-         std::cerr << "EOF" << "\n";
+         std::cerr << "\tEOF" << "\n";
       else
-         std::cerr << "0x" << std::hex << c << "\n";
+         std::cerr << "\tBYTE 0x" << std::hex << c << std::dec << "\n";
 #endif
       return c;
    }