trace: Allow to dump binary data.
authorJosé Fonseca <jrfonseca@tungstengraphics.com>
Fri, 8 Aug 2008 22:53:53 +0000 (23:53 +0100)
committerJosé Fonseca <jrfonseca@tungstengraphics.com>
Sat, 9 Aug 2008 13:10:25 +0000 (14:10 +0100)
src/gallium/drivers/trace/tr_dump.c
src/gallium/drivers/trace/tr_dump.h
src/gallium/drivers/trace/tr_state.c
src/gallium/drivers/trace/trace.xsl

index 359a903ab9121a329c936debb35d08d9139b4614..f545de30f4f7157ed5b01aeeaa22bd3a6e13deac 100644 (file)
@@ -272,6 +272,25 @@ void trace_dump_float(struct trace_stream *stream,
    trace_dump_writef(stream, "<float>%g</float>", value);
 }
 
+void trace_dump_bytes(struct trace_stream *stream, 
+                      const void *data,
+                      long unsigned size)
+{
+   static char hex_table[] = "0123456789ABCDE";
+   const uint8_t *p = data;
+   long unsigned i;
+   trace_dump_write(stream, "<bytes>");
+   for(i = 0; i < size; ++i) {
+      uint8_t byte = *p++;
+      char str[3];
+      str[0] = hex_table[byte >> 4];
+      str[1] = hex_table[byte & 0xf];
+      str[2] = 0;
+      trace_dump_write(stream, str);
+   }
+   trace_dump_write(stream, "</bytes>");
+}
+
 void trace_dump_string(struct trace_stream *stream, 
                        const char *str)
 {
index 7b15da30330120384ee32bb97d7f49739cb521c6..b2367c3288a0bd192051723a3ac002cbca15f827 100644 (file)
@@ -52,6 +52,7 @@ void trace_dump_bool(struct trace_stream *stream, int value);
 void trace_dump_int(struct trace_stream *stream, long int value);
 void trace_dump_uint(struct trace_stream *stream, long unsigned value);
 void trace_dump_float(struct trace_stream *stream, double value);
+void trace_dump_bytes(struct trace_stream *stream, const void *data, long unsigned size);
 void trace_dump_string(struct trace_stream *stream, const char *str);
 void trace_dump_enum(struct trace_stream *stream, const char *value);
 void trace_dump_array_begin(struct trace_stream *stream);
index f17006dd816883c688ee62f1e83093b3f281e4f9..e0e48185fac4f93f2060aa816c8bb7fe85d6c455 100644 (file)
@@ -51,23 +51,6 @@ void trace_dump_block(struct trace_stream *stream,
 }
 
 
-void trace_dump_buffer(struct trace_stream *stream, 
-                      const struct pipe_buffer *buffer)
-{
-   if(!buffer) {
-      trace_dump_null(stream);
-      return;
-   }
-   
-   trace_dump_struct_begin(stream, "pipe_buffer");
-   trace_dump_member(stream, uint, buffer, alignment);
-   trace_dump_member(stream, uint, buffer, usage);
-   trace_dump_member(stream, uint, buffer, size);
-   /* TODO: buffer data */
-   trace_dump_struct_end(stream);
-}
-
-
 void trace_dump_template(struct trace_stream *stream, 
                          const struct pipe_texture *templat)
 {
@@ -162,7 +145,11 @@ void trace_dump_poly_stipple(struct trace_stream *stream,
 
    trace_dump_struct_begin(stream, "pipe_poly_stipple");
 
-   trace_dump_member_array(stream, uint, state, stipple);
+   trace_dump_member_begin(stream, "stipple");
+   trace_dump_bytes(stream, 
+                    state->stipple, 
+                    sizeof(state->stipple));
+   trace_dump_member_end(stream);
    
    trace_dump_struct_end(stream);
 }
@@ -243,7 +230,7 @@ void trace_dump_constant_buffer(struct trace_stream *stream,
 
    trace_dump_struct_begin(stream, "pipe_constant_buffer");
 
-   trace_dump_member(stream, buffer, state, buffer);
+   trace_dump_member(stream, ptr, state, buffer);
    trace_dump_member(stream, uint, state, size);
 
    trace_dump_struct_end(stream);
@@ -253,21 +240,18 @@ void trace_dump_constant_buffer(struct trace_stream *stream,
 void trace_dump_shader_state(struct trace_stream *stream,
                              const struct pipe_shader_state *state)
 {
-   uint32_t *p = (uint32_t *)state->tokens;
-   unsigned n = tgsi_num_tokens(state->tokens);
-   
    assert(state);
    if(!state) {
       trace_dump_null(stream);
       return;
    }
 
-   assert(sizeof(struct tgsi_token) == 4);
-   
    trace_dump_struct_begin(stream, "pipe_shader_state");
 
    trace_dump_member_begin(stream, "tokens");
-   trace_dump_array(stream, uint, p, n);
+   trace_dump_bytes(stream, 
+                    state->tokens, 
+                    sizeof(struct tgsi_token) * tgsi_num_tokens(state->tokens));
    trace_dump_member_end(stream);
 
    trace_dump_struct_end(stream);
@@ -433,7 +417,7 @@ void trace_dump_surface(struct trace_stream *stream,
 
    trace_dump_struct_begin(stream, "pipe_surface");
 
-   trace_dump_member(stream, buffer, state, buffer);
+   trace_dump_member(stream, ptr, state, buffer);
    trace_dump_member(stream, format, state, format);
    trace_dump_member(stream, uint, state, status);
    trace_dump_member(stream, uint, state, clear_value);
@@ -475,7 +459,7 @@ void trace_dump_vertex_buffer(struct trace_stream *stream,
    trace_dump_member(stream, uint, state, pitch);
    trace_dump_member(stream, uint, state, max_index);
    trace_dump_member(stream, uint, state, buffer_offset);
-   trace_dump_member(stream, buffer, state, buffer);
+   trace_dump_member(stream, ptr, state, buffer);
 
    trace_dump_struct_end(stream);
 }
index 13039d44c42d6b61d99b2e7027de55e98d25df65..991e5bf93509ef4170ceefeac8cafab8575b68fc 100644 (file)
@@ -100,6 +100,12 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
                </span>
        </xsl:template>
 
+       <xsl:template match="bytes">
+               <span class="lit">
+                       <xsl:text>...</xsl:text>
+               </span>
+       </xsl:template>
+
        <xsl:template match="string">
                <span class="lit">
                        <xsl:text>"</xsl:text>