tools/Rules.mk: Don't optimize debug builds; add macro debugging information
authorEuan Harris <euan.harris@citrix.com>
Mon, 1 Dec 2014 14:21:05 +0000 (14:21 +0000)
committerIan Campbell <ian.campbell@citrix.com>
Mon, 12 Jan 2015 16:10:51 +0000 (16:10 +0000)
Tools debug builds are built with optimization level -O1, inherited from
the CFLAGS definition in StdGNU.mk.   Optimizations confuse the debugger,
and the comment justifying -O1 in StdGNU.mk should not apply for a
userspace library.   Disable optimization by appending -O0 to CFLAGS,
which overrides the -O1 flag specified earlier.

Also specify -g3, to add macro debugging information which allows
gdb to expand macro invocations.   This is useful as libxl uses many
non-trivial macros.

Signed-off-by: Euan Harris <euan.harris@citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
[ ijc -- inserted a clarifying "enable" into comment ]

tools/Rules.mk

index 87a56dc9cce9143acf5e57e31ace40d3b7e2441a..962a743bbebca200054a5939de6cbfc345a877ce 100644 (file)
@@ -54,6 +54,11 @@ CFLAGS_libxenvchan = -I$(XEN_LIBVCHAN)
 LDLIBS_libxenvchan = $(SHLIB_libxenctrl) $(SHLIB_libxenstore) -L$(XEN_LIBVCHAN) -lxenvchan
 SHLIB_libxenvchan  = -Wl,-rpath-link=$(XEN_LIBVCHAN)
 
+ifeq ($(debug),y)
+# Disable optimizations and enable debugging information for macros
+CFLAGS += -O0 -g3
+endif
+
 LIBXL_BLKTAP ?= $(CONFIG_BLKTAP2)
 
 ifeq ($(LIBXL_BLKTAP),y)