[PATCH 20/21] KGDB: Add ability to unoptimize module compiles anddwarf2 asm

From: Jason Wessel
Date: Mon Oct 15 2007 - 14:44:11 EST


Signed-off-by: Jason Wessel <jason.wessel@xxxxxxxxxxxxx>
asm_debug.patch

From: Jason Wessel <jason.wessel@xxxxxxxxxxxxx>
Subject: [PATCH] Add ability to unoptimize module compiles and dwarf2 asm

This patch adds in the ability to unoptimize a single kernel module to
make source stepping more linear and not optimize out variables that
the developer might like to inspect. It used with adding
COPTIMIZE=-O0 to the build line.

Also when creating a debug kernel add in dwarf2 sections for the
assembled code. This makes source stepping the assembly files
possible as well as having references into the .S files in the back
trace information. The -gdwarf2 was chosen to work around any
problems with the stabs assembly sections.

Signed-off-by: Jason Wessel <jason.wessel@xxxxxxxxxxxxx>
---
Makefile | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)

Index: linux-2.6-kgdb/Makefile
===================================================================
--- linux-2.6-kgdb.orig/Makefile
+++ linux-2.6-kgdb/Makefile
@@ -483,10 +483,14 @@ endif # $(dot-config)
all: vmlinux

ifdef CONFIG_CC_OPTIMIZE_FOR_SIZE
-CFLAGS += -Os
+COPTIMIZE = -Os
else
-CFLAGS += -O2
+COPTIMIZE = -O2
endif
+# COPTIMIZE may be overridden on the make command line with
+# make ... COPTIMIZE=""
+# The resulting object may be easier to debug with KGDB
+CFLAGS += $(COPTIMIZE)

include $(srctree)/arch/$(ARCH)/Makefile

@@ -498,6 +502,7 @@ endif

ifdef CONFIG_DEBUG_INFO
CFLAGS += -g
+AFLAGS += -gdwarf2
endif

# Force gcc to behave correct even for buggy distributions