tr_dump.h File Reference

Trace data dumping primitives. More...

Include dependency graph for tr_dump.h:

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Defines

#define trace_dump_arg(_type, _arg)
#define trace_dump_ret(_type, _arg)
#define trace_dump_array(_type, _obj, _size)
#define trace_dump_struct_array(_type, _obj, _size)
#define trace_dump_member(_type, _obj, _member)
#define trace_dump_arg_array(_type, _arg, _size)
#define trace_dump_member_array(_type, _obj, _member)

Functions

boolean trace_dump_trace_begin (void)
boolean trace_dump_enabled (void)
void trace_dump_trace_end (void)
void trace_dump_call_begin (const char *klass, const char *method)
void trace_dump_call_end (void)
void trace_dump_arg_begin (const char *name)
void trace_dump_arg_end (void)
void trace_dump_ret_begin (void)
void trace_dump_ret_end (void)
void trace_dump_bool (int value)
void trace_dump_int (long long int value)
void trace_dump_uint (long long unsigned value)
void trace_dump_float (double value)
void trace_dump_bytes (const void *data, long unsigned size)
void trace_dump_string (const char *str)
void trace_dump_enum (const char *value)
void trace_dump_array_begin (void)
void trace_dump_array_end (void)
void trace_dump_elem_begin (void)
void trace_dump_elem_end (void)
void trace_dump_struct_begin (const char *name)
void trace_dump_struct_end (void)
void trace_dump_member_begin (const char *name)
void trace_dump_member_end (void)
void trace_dump_null (void)
void trace_dump_ptr (const void *value)


Detailed Description

Trace data dumping primitives.

Definition in file tr_dump.h.


Define Documentation

#define trace_dump_arg ( _type,
_arg   ) 

Value:

do { \
      trace_dump_arg_begin(#_arg); \
      trace_dump_##_type(_arg); \
      trace_dump_arg_end(); \
   } while(0)

Definition at line 72 of file tr_dump.h.

#define trace_dump_arg_array ( _type,
_arg,
_size   ) 

Value:

do { \
      trace_dump_arg_begin(#_arg); \
      trace_dump_array(_type, _arg, _size); \
      trace_dump_arg_end(); \
   } while(0)

Definition at line 117 of file tr_dump.h.

#define trace_dump_array ( _type,
_obj,
_size   ) 

Value:

do { \
      unsigned long idx; \
      trace_dump_array_begin(); \
      for(idx = 0; idx < (_size); ++idx) { \
         trace_dump_elem_begin(); \
         trace_dump_##_type((_obj)[idx]); \
         trace_dump_elem_end(); \
      } \
      trace_dump_array_end(); \
   } while(0)

Definition at line 86 of file tr_dump.h.

#define trace_dump_member ( _type,
_obj,
_member   ) 

Value:

do { \
      trace_dump_member_begin(#_member); \
      trace_dump_##_type((_obj)->_member); \
      trace_dump_member_end(); \
   } while(0)

Definition at line 110 of file tr_dump.h.

#define trace_dump_member_array ( _type,
_obj,
_member   ) 

Value:

do { \
      trace_dump_member_begin(#_member); \
      trace_dump_array(_type, (_obj)->_member, sizeof((_obj)->_member)/sizeof((_obj)->_member[0])); \
      trace_dump_member_end(); \
   } while(0)

Definition at line 124 of file tr_dump.h.

#define trace_dump_ret ( _type,
_arg   ) 

Value:

do { \
      trace_dump_ret_begin(); \
      trace_dump_##_type(_arg); \
      trace_dump_ret_end(); \
   } while(0)

Definition at line 79 of file tr_dump.h.

#define trace_dump_struct_array ( _type,
_obj,
_size   ) 

Value:

do { \
      unsigned long idx; \
      trace_dump_array_begin(); \
      for(idx = 0; idx < (_size); ++idx) { \
         trace_dump_elem_begin(); \
         trace_dump_##_type(&(_obj)[idx]); \
         trace_dump_elem_end(); \
      } \
      trace_dump_array_end(); \
   } while(0)

Definition at line 98 of file tr_dump.h.


Function Documentation

void trace_dump_arg_begin ( const char *  name  ) 

Definition at line 294 of file tr_dump.c.

References trace_dump_indent(), and trace_dump_tag_begin1().

00295 {
00296    trace_dump_indent(2);
00297    trace_dump_tag_begin1("arg", "name", name);
00298 }

void trace_dump_arg_end ( void   ) 

Definition at line 300 of file tr_dump.c.

References trace_dump_newline(), and trace_dump_tag_end().

00301 {
00302    trace_dump_tag_end("arg");
00303    trace_dump_newline();
00304 }

void trace_dump_array_begin ( void   ) 

Definition at line 369 of file tr_dump.c.

References trace_dump_writes().

00370 {
00371    trace_dump_writes("<array>");
00372 }

void trace_dump_array_end ( void   ) 

Definition at line 374 of file tr_dump.c.

References trace_dump_writes().

00375 {
00376    trace_dump_writes("</array>");
00377 }

void trace_dump_bool ( int  value  ) 

Definition at line 318 of file tr_dump.c.

References trace_dump_writef().

00319 {
00320    trace_dump_writef("<bool>%c</bool>", value ? '1' : '0');
00321 }

void trace_dump_bytes ( const void *  data,
long unsigned  size 
)

Definition at line 338 of file tr_dump.c.

References trace_dump_write(), and trace_dump_writes().

00340 {
00341    static const char hex_table[16] = "0123456789ABCDEF";
00342    const uint8_t *p = data;
00343    long unsigned i;
00344    trace_dump_writes("<bytes>");
00345    for(i = 0; i < size; ++i) {
00346       uint8_t byte = *p++;
00347       char hex[2];
00348       hex[0] = hex_table[byte >> 4];
00349       hex[1] = hex_table[byte & 0xf];
00350       trace_dump_write(hex, 2);
00351    }
00352    trace_dump_writes("</bytes>");
00353 }

void trace_dump_call_begin ( const char *  klass,
const char *  method 
)

Definition at line 270 of file tr_dump.c.

References call_mutex, call_no, pipe_mutex_lock, trace_dump_escape(), trace_dump_indent(), trace_dump_newline(), trace_dump_writef(), and trace_dump_writes().

00271 {
00272    pipe_mutex_lock(call_mutex);
00273    ++call_no;
00274    trace_dump_indent(1);
00275    trace_dump_writes("<call no=\'");
00276    trace_dump_writef("%lu", call_no);
00277    trace_dump_writes("\' class =\'");
00278    trace_dump_escape(klass);
00279    trace_dump_writes("\' method=\'");
00280    trace_dump_escape(method);
00281    trace_dump_writes("\'>");
00282    trace_dump_newline();
00283 }

void trace_dump_call_end ( void   ) 

Definition at line 285 of file tr_dump.c.

References call_mutex, pipe_mutex_unlock, stream, trace_dump_indent(), trace_dump_newline(), trace_dump_tag_end(), and util_stream_flush().

00286 {
00287    trace_dump_indent(1);
00288    trace_dump_tag_end("call");
00289    trace_dump_newline();
00290    util_stream_flush(stream);
00291    pipe_mutex_unlock(call_mutex);
00292 }

void trace_dump_elem_begin ( void   ) 

Definition at line 379 of file tr_dump.c.

References trace_dump_writes().

00380 {
00381    trace_dump_writes("<elem>");
00382 }

void trace_dump_elem_end ( void   ) 

Definition at line 384 of file tr_dump.c.

References trace_dump_writes().

00385 {
00386    trace_dump_writes("</elem>");
00387 }

boolean trace_dump_enabled ( void   ) 

Definition at line 258 of file tr_dump.c.

References FALSE, stream, and TRUE.

00259 {
00260    return stream ? TRUE : FALSE;
00261 }

void trace_dump_enum ( const char *  value  ) 

Definition at line 362 of file tr_dump.c.

References trace_dump_escape(), and trace_dump_writes().

00363 {
00364    trace_dump_writes("<enum>");
00365    trace_dump_escape(value);
00366    trace_dump_writes("</enum>");
00367 }

void trace_dump_float ( double  value  ) 

Definition at line 333 of file tr_dump.c.

References trace_dump_writef().

00334 {
00335    trace_dump_writef("<float>%g</float>", value);
00336 }

void trace_dump_int ( long long int  value  ) 

Definition at line 323 of file tr_dump.c.

References trace_dump_writef().

00324 {
00325    trace_dump_writef("<int>%lli</int>", value);
00326 }

void trace_dump_member_begin ( const char *  name  ) 

Definition at line 399 of file tr_dump.c.

References trace_dump_writef().

00400 {
00401    trace_dump_writef("<member name='%s'>", name);
00402 }

void trace_dump_member_end ( void   ) 

Definition at line 404 of file tr_dump.c.

References trace_dump_writes().

00405 {
00406    trace_dump_writes("</member>");
00407 }

void trace_dump_null ( void   ) 

Definition at line 409 of file tr_dump.c.

References trace_dump_writes().

00410 {
00411    trace_dump_writes("<null/>");
00412 }

void trace_dump_ptr ( const void *  value  ) 

Definition at line 414 of file tr_dump.c.

References trace_dump_null(), and trace_dump_writef().

00415 {
00416    if(value)
00417       trace_dump_writef("<ptr>0x%08lx</ptr>", (unsigned long)(uintptr_t)value);
00418    else
00419       trace_dump_null();
00420 }

void trace_dump_ret_begin ( void   ) 

Definition at line 306 of file tr_dump.c.

References trace_dump_indent(), and trace_dump_tag_begin().

00307 {
00308    trace_dump_indent(2);
00309    trace_dump_tag_begin("ret");
00310 }

void trace_dump_ret_end ( void   ) 

Definition at line 312 of file tr_dump.c.

References trace_dump_newline(), and trace_dump_tag_end().

00313 {
00314    trace_dump_tag_end("ret");
00315    trace_dump_newline();
00316 }

void trace_dump_string ( const char *  str  ) 

Definition at line 355 of file tr_dump.c.

References trace_dump_escape(), and trace_dump_writes().

00356 {
00357    trace_dump_writes("<string>");
00358    trace_dump_escape(str);
00359    trace_dump_writes("</string>");
00360 }

void trace_dump_struct_begin ( const char *  name  ) 

Definition at line 389 of file tr_dump.c.

References trace_dump_writef().

00390 {
00391    trace_dump_writef("<struct name='%s'>", name);
00392 }

void trace_dump_struct_end ( void   ) 

Definition at line 394 of file tr_dump.c.

References trace_dump_writes().

00395 {
00396    trace_dump_writes("</struct>");
00397 }

boolean trace_dump_trace_begin ( void   ) 

Definition at line 226 of file tr_dump.c.

References call_mutex, debug_get_option(), FALSE, pipe_mutex_init, refcount, stream, trace_dump_trace_close(), trace_dump_writes(), TRUE, and util_stream_create().

00227 {
00228    const char *filename;
00229    
00230    filename = debug_get_option("GALLIUM_TRACE", NULL);
00231    if(!filename)
00232       return FALSE;
00233    
00234    if(!stream) {
00235    
00236       stream = util_stream_create(filename, 0);
00237       if(!stream)
00238          return FALSE;
00239       
00240       pipe_mutex_init(call_mutex);
00241 
00242       trace_dump_writes("<?xml version='1.0' encoding='UTF-8'?>\n");
00243       trace_dump_writes("<?xml-stylesheet type='text/xsl' href='trace.xsl'?>\n");
00244       trace_dump_writes("<trace version='0.1'>\n");
00245       
00246 #if defined(PIPE_OS_LINUX)
00247       /* Linux applications rarely cleanup GL / Gallium resources so catch 
00248        * application exit here */ 
00249       atexit(trace_dump_trace_close);
00250 #endif
00251    }
00252    
00253    ++refcount;
00254    
00255    return TRUE;
00256 }

void trace_dump_trace_end ( void   ) 

Definition at line 263 of file tr_dump.c.

References refcount, stream, and trace_dump_trace_close().

00264 {
00265    if(stream)
00266       if(!--refcount)
00267          trace_dump_trace_close();
00268 }

void trace_dump_uint ( long long unsigned  value  ) 

Definition at line 328 of file tr_dump.c.

References trace_dump_writef().

00329 {
00330    trace_dump_writef("<uint>%llu</uint>", value);
00331 }


Generated on Tue Sep 29 06:25:42 2009 for Gallium3D by  doxygen 1.5.4