static INLINE void
trace_dump_tag_end(const char *name)
{
   trace_dump_writes("</");
   trace_dump_writes(name);
   trace_dump_writes(">");
}
boolean trace_dump_trace_begin()
{
   const char *filename;

   filename = debug_get_option("GALLIUM_TRACE", NULL);
   if(!filename)
      return FALSE;

   if(!stream) {

      stream = fopen(filename, "wt");
      if(!stream)
         return FALSE;

      trace_dump_writes("<?xml version='1.0' encoding='UTF-8'?>\n");
      trace_dump_writes("<?xml-stylesheet type='text/xsl' href='trace.xsl'?>\n");
      trace_dump_writes("<trace version='0.1'>\n");

#if defined(PIPE_OS_LINUX) || defined(PIPE_OS_BSD) || defined(PIPE_OS_SOLARIS) || defined(PIPE_OS_APPLE)
      /* Linux applications rarely cleanup GL / Gallium resources so catch
       * application exit here */
      atexit(trace_dump_trace_close);
#endif
   }

   ++refcount;

   return TRUE;
}
示例#3
0
文件: tr_dump.c 项目: Distrotech/Mesa
static inline void
trace_dump_tag(const char *name)
{
   trace_dump_writes("<");
   trace_dump_writes(name);
   trace_dump_writes("/>");
}
static INLINE void
trace_dump_tag_begin(const char *name)
{
   trace_dump_writes("<");
   trace_dump_writes(name);
   trace_dump_writes(">");
}
void trace_dump_string(const char *str)
{
   if (!dumping)
      return;

   trace_dump_writes("<string>");
   trace_dump_escape(str);
   trace_dump_writes("</string>");
}
void trace_dump_enum(const char *value)
{
   if (!dumping)
      return;

   trace_dump_writes("<enum>");
   trace_dump_escape(value);
   trace_dump_writes("</enum>");
}
void trace_dump_elem_end(void)
{
   if (!dumping)
      return;

   trace_dump_writes("</elem>");
}
void trace_dump_struct_end(void)
{
   if (!dumping)
      return;

   trace_dump_writes("</struct>");
}
static INLINE void
trace_dump_indent(unsigned level)
{
   unsigned i;
   for(i = 0; i < level; ++i)
      trace_dump_writes("\t");
}
void trace_dump_member_end(void)
{
   if (!dumping)
      return;

   trace_dump_writes("</member>");
}
void trace_dump_elem_begin(void)
{
   if (!dumping)
      return;

   trace_dump_writes("<elem>");
}
void trace_dump_null(void)
{
   if (!dumping)
      return;

   trace_dump_writes("<null/>");
}
void trace_dump_array_begin(void)
{
   if (!dumping)
      return;

   trace_dump_writes("<array>");
}
void trace_dump_array_end(void)
{
   if (!dumping)
      return;

   trace_dump_writes("</array>");
}
void trace_dump_call_begin_locked(const char *klass, const char *method)
{
   if (!dumping)
      return;

   ++call_no;
   trace_dump_indent(1);
   trace_dump_writes("<call no=\'");
   trace_dump_writef("%lu", call_no);
   trace_dump_writes("\' class=\'");
   trace_dump_escape(klass);
   trace_dump_writes("\' method=\'");
   trace_dump_escape(method);
   trace_dump_writes("\'>");
   trace_dump_newline();
}
static void
trace_dump_trace_close(void)
{
   if(stream) {
      trace_dump_writes("</trace>\n");
      fclose(stream);
      stream = NULL;
      refcount = 0;
      call_no = 0;
   }
}
void trace_dump_bytes(const void *data,
                      size_t size)
{
   static const char hex_table[16] = "0123456789ABCDEF";
   const uint8_t *p = data;
   size_t i;

   if (!dumping)
      return;

   trace_dump_writes("<bytes>");
   for(i = 0; i < size; ++i) {
      uint8_t byte = *p++;
      char hex[2];
      hex[0] = hex_table[byte >> 4];
      hex[1] = hex_table[byte & 0xf];
      trace_dump_write(hex, 2);
   }
   trace_dump_writes("</bytes>");
}
static INLINE void
trace_dump_tag_begin2(const char *name,
                      const char *attr1, const char *value1,
                      const char *attr2, const char *value2)
{
   trace_dump_writes("<");
   trace_dump_writes(name);
   trace_dump_writes(" ");
   trace_dump_writes(attr1);
   trace_dump_writes("=\'");
   trace_dump_escape(value1);
   trace_dump_writes("\' ");
   trace_dump_writes(attr2);
   trace_dump_writes("=\'");
   trace_dump_escape(value2);
   trace_dump_writes("\'>");
}
示例#19
0
文件: tr_dump.c 项目: Distrotech/Mesa
static void
trace_dump_trace_close(void)
{
   if (stream) {
      trace_dump_writes("</trace>\n");
      if (close_stream) {
         fclose(stream);
         close_stream = FALSE;
         stream = NULL;
      }
      call_no = 0;
   }
}
示例#20
0
文件: tr_dump.c 项目: Distrotech/Mesa
boolean
trace_dump_trace_begin(void)
{
   const char *filename;

   filename = debug_get_option("GALLIUM_TRACE", NULL);
   if (!filename)
      return FALSE;

   if (!stream) {

      if (strcmp(filename, "stderr") == 0) {
         close_stream = FALSE;
         stream = stderr;
      }
      else if (strcmp(filename, "stdout") == 0) {
         close_stream = FALSE;
         stream = stdout;
      }
      else {
         close_stream = TRUE;
         stream = fopen(filename, "wt");
         if (!stream)
            return FALSE;
      }

      trace_dump_writes("<?xml version='1.0' encoding='UTF-8'?>\n");
      trace_dump_writes("<?xml-stylesheet type='text/xsl' href='trace.xsl'?>\n");
      trace_dump_writes("<trace version='0.1'>\n");

      /* Many applications don't exit cleanly, others may create and destroy a
       * screen multiple times, so we only write </trace> tag and close at exit
       * time.
       */
      atexit(trace_dump_trace_close);
   }

   return TRUE;
}
static INLINE void
trace_dump_escape(const char *str)
{
   const unsigned char *p = (const unsigned char *)str;
   unsigned char c;
   while((c = *p++) != 0) {
      if(c == '<')
         trace_dump_writes("&lt;");
      else if(c == '>')
         trace_dump_writes("&gt;");
      else if(c == '&')
         trace_dump_writes("&amp;");
      else if(c == '\'')
         trace_dump_writes("&apos;");
      else if(c == '\"')
         trace_dump_writes("&quot;");
      else if(c >= 0x20 && c <= 0x7e)
         trace_dump_writef("%c", c);
      else
         trace_dump_writef("&#%u;", c);
   }
}
示例#22
0
文件: tr_dump.c 项目: Distrotech/Mesa
static inline void
trace_dump_tag_begin1(const char *name,
                      const char *attr1, const char *value1)
{
   trace_dump_writes("<");
   trace_dump_writes(name);
   trace_dump_writes(" ");
   trace_dump_writes(attr1);
   trace_dump_writes("='");
   trace_dump_escape(value1);
   trace_dump_writes("'>");
}
示例#23
0
文件: tr_dump.c 项目: Distrotech/Mesa
static inline void
trace_dump_newline(void)
{
   trace_dump_writes("\n");
}
示例#24
0
文件: tr_dump.c 项目: Distrotech/Mesa
static inline void
trace_dump_tag_begin3(const char *name,
                      const char *attr1, const char *value1,
                      const char *attr2, const char *value2,
                      const char *attr3, const char *value3)
{
   trace_dump_writes("<");
   trace_dump_writes(name);
   trace_dump_writes(" ");
   trace_dump_writes(attr1);
   trace_dump_writes("=\'");
   trace_dump_escape(value1);
   trace_dump_writes("\' ");
   trace_dump_writes(attr2);
   trace_dump_writes("=\'");
   trace_dump_escape(value2);
   trace_dump_writes("\' ");
   trace_dump_writes(attr3);
   trace_dump_writes("=\'");
   trace_dump_escape(value3);
   trace_dump_writes("\'>");
}
static INLINE void
trace_dump_newline(void)
{
   trace_dump_writes("\n");
}