]> www.infradead.org Git - mtd-utils.git/commitdiff
fs-tests: integck: add debug compilation target
authorArtem Bityutskiy <Artem.Bityutskiy@nokia.com>
Fri, 22 Apr 2011 14:40:52 +0000 (17:40 +0300)
committerArtem Bityutskiy <Artem.Bityutskiy@nokia.com>
Sun, 24 Apr 2011 16:12:30 +0000 (19:12 +0300)
I often need to use gdb to debug integck, or sometimes even attach
already running integck. But when it is compiled with optimizations, it
is nearly impossible to use gdb. Introduce 'debug' target to compile
integck without optimizations.

Additionally, to make the stack backtraces work, add a dirty hack to
integck.c to remove all the static keywords - this turns static
functions to non-static and makes them appear in stack backtraces.

Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
tests/fs-tests/integrity/Makefile
tests/fs-tests/integrity/integck.c

index 976c3ce2af371b205f22a7a69bcadca31b84964f..2cdd4702e0705cfb70c93e4c43ee0dfc76e932ab 100644 (file)
@@ -13,5 +13,10 @@ TARGETS = integck
 
 all: $(TARGETS)
 
+# Disable optimizations to make it possible to use gdb comfortably
+# Use -rdynamic to have stack backtraces
+debug:
+       gcc $(CFLAGS) -O0 -D INTEGCK_DEBUG -rdynamic integck.c -o integck
+
 clean:
        rm -f *.o $(TARGETS)
index f09cfaf420f08c513bbfd8bffa6497cffd08c4ef..fbd6cc5c656aa6bd65fd364232d293374db0c044 100644 (file)
 #define PROGRAM_NAME "integck"
 #include "common.h"
 
+/*
+ * WARNING! This is a dirty hack! The symbols for static functions are not
+ * printed in the stack backtrace. So we remove ths 'static' keyword using the
+ * pre-processor. This is really error-prone because this won't work if, e.g.,
+ * local static variables were used.
+ */
+#ifdef INTEGCK_DEBUG
+#define static
+#endif
+
 #define MAX_RANDOM_SEED 10000000
 
 /* The pattern for the top directory where we run the test */