tgsi: make the tgsi assembly parser report line/column on error
authorZack Rusin <zackr@vmware.com>
Tue, 15 Dec 2009 14:26:51 +0000 (09:26 -0500)
committerZack Rusin <zackr@vmware.com>
Fri, 25 Dec 2009 10:52:17 +0000 (05:52 -0500)
src/gallium/auxiliary/tgsi/tgsi_text.c

index 84e863b..9673686 100644 (file)
@@ -197,7 +197,20 @@ struct translate_ctx
 
 static void report_error( struct translate_ctx *ctx, const char *msg )
 {
-   debug_printf( "\nError: %s", msg );
+   int line = 1;
+   int column = 1;
+   const char *itr = ctx->text;
+
+   while (itr != ctx->cur) {
+      if (*itr == '\n') {
+         column = 1;
+         ++line;
+      }
+      ++column;
+      ++itr;
+   }
+
+   debug_printf( "\nTGSI asm error: %s [%d : %d] \n", msg, line, column );
 }
 
 /* Parse shader header.