Skip to contentSkip to conversation

KGDB: Add ability to unoptimize module compiles and dwarf2 asm

PATCH In review Jason Wessel 1 participant 1 message Oct 15, 2007 Kbuild

lore
Share & tools
lore
#0 lore raw

PATCH 20/21 KGDB: Add ability to unoptimize module compiles and dwarf2 asm

asm_debug.patch

From: Jason Wessel <[email protected]>
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.

---
 Makefile |    9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
Makefile +7 -2
Index: 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