]> git.itanic.dy.fi Git - sdl-planets/commitdiff
quadtree.c: Print line number when trap is caught
authorTimo Kokkonen <kaapeli@itanic.dy.fi>
Tue, 7 Dec 2010 19:57:00 +0000 (21:57 +0200)
committerTimo Kokkonen <kaapeli@itanic.dy.fi>
Tue, 7 Dec 2010 19:57:00 +0000 (21:57 +0200)
This helps debugging

Signed-off-by: Timo Kokkonen <kaapeli@itanic.dy.fi>
quadtree.c

index 80b285a6f6ba74584abc67bac63dd4c729753d5d..79039c64833c221480b49c6c1050ebe8d9d3593b 100644 (file)
@@ -9,12 +9,18 @@
 #define debug 0
 #endif
 
-static void trap(void)
+static void _trap(int line)
 {
-       if (debug)
+       if (debug) {
+               printf("Trapped from line %d, use debugger to get backtrace\n",
+                       line);
+               fflush(stdout);
                exit(1);
+       }
 }
 
+#define trap() _trap(__LINE__)
+
 static int quadtree_compare_coord(const struct vector *a,
                                const struct vector *b)
 {