Add support for Linux-like kallsysms
The kernel stores address<->symbol names in it so things can be decoded at runtime. Do it in U-Boot, and we get nice symbol decoding when crashing.
--- Makefile | 17 +++++++++++--- common/Makefile | 1 + common/kallsyms.c | 44 +++++++++++++++++++++++++++++++++++++ common/system_map.c | 8 ++++++ include/common.h | 3 ++ create mode 100644 common/kallsyms.c create mode 100644 common/system_map.c
Makefile +13 -4
@@ -340,12 +340,19 @@ $(obj)u-boot.sha1: $(obj)u-boot.bin $(obj)u-boot.dis: $(obj)u-boot $(OBJDUMP) -d $< > $@ -$(obj)u-boot: depend $(SUBDIRS) $(OBJS) $(LIBBOARD) $(LIBS) $(LDSCRIPT) +GEN_UBOOT = \ UNDEF_SYM=`$(OBJDUMP) -x $(LIBBOARD) $(LIBS) | \ sed -n -e 's/.*\($(SYM_PREFIX)__u_boot_cmd_.*\)/-u\1/p'|sort|uniq`;\ cd $(LNDIR) && $(LD) $(LDFLAGS) $$UNDEF_SYM $(__OBJS) \ --start-group $(__LIBS) --end-group $(PLATFORM_LIBS) \ -Map u-boot.map -o u-boot +$(obj)u-boot: depend $(SUBDIRS) $(OBJS) $(LIBBOARD) $(LIBS) $(LDSCRIPT) + $(GEN_UBOOT) +ifeq ($(CONFIG_KALLSYMS),y) + smap=`$(call SYSTEM_MAP,u-boot) | awk '$$2 ~ /[tTwW]/ {printf $$1 $$3 "\\0"}'` ; \ + $(CC) $(CFLAGS) -DSYSTEM_MAP="\"$${smap}\"" -c common/system_map.c -o $(obj)common/system_map.o + $(GEN_UBOOT) $(obj)common/system_map.o +endif $(OBJS): depend $(obj)include/autoconf.mk $(MAKE) -C cpu/$(CPU) $(if $(REMOTE_BUILD),$@,$(notdir $@))
@@ -444,10 +451,12 @@ cscope: > cscope.files cscope -b -q -k -$(obj)System.map: $(obj)u-boot - @$(NM) $< | \ +SYSTEM_MAP = \ + $(NM) $1 | \ grep -v '\(compiled\)\|\(\.o$$\)\|\( [aUw] \)\|\(\.\.ng$$\)\|\(LASH[RL]DI\)' | \ - sort > $(obj)System.map + LC_ALL=C sort +$(obj)System.map: $(obj)u-boot + @$(call SYSTEM_MAP,$<) > $(obj)System.map # # Auto-generate the autoconf.mk file (which is included by all makefiles)
common/Makefile +1 -0
@@ -147,6 +147,7 @@ COBJS-$(CONFIG_CMD_DOC) += docecc.o COBJS-$(CONFIG_CONSOLE_MUX) += iomux.o COBJS-y += flash.o COBJS-$(CONFIG_CMD_KGDB) += kgdb.o +COBJS-$(CONFIG_KALLSYMS) += kallsyms.o COBJS-$(CONFIG_LCD) += lcd.o COBJS-$(CONFIG_LYNXKDI) += lynxkdi.o COBJS-$(CONFIG_UPDATE_TFTP) += update.o
common/kallsyms.c new file +44 -0
44 lines not on this page · raw message
common/system_map.c new file +8 -0
@@ -0,0 +1,8 @@ +/* +* The builtin symbol table for use with kallsyms +* +* Copyright (c) 2008-2009 Analog Devices Inc. +* Licensed under the GPL-2 or later. +*/ + +const char const system_map[] =SYSTEM_MAP ;
include/common.h +3 -0
@@ -300,6 +300,9 @@ int misc_init_r (void);/* common/exports.c */ void jumptable_init (void ); +/* common/kallsysm.c */ +const char *symbol_lookup (unsigned long addr,unsigned long *caddr); +/* api/api.c */ void api_init (void );
Signature · 1 line
1.6.3
Dear Mike Frysinger,
Quoted 2 lines · In message <[email protected]> you wrote:
The kernel stores address<->symbol names in it so things can be decoded at runtime. Do it in U-Boot, and we get nice symbol decoding when crashing.
I like the idea as a pretty useful debug help.
If nobody objects I guess we could pull this into "next" ?
Thanks.
Best regards,
Wolfgang Denk
Signature · 5 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de America has been discovered before, but it has always been hushed up. - Oscar Wilde
Quoted 8 lines · On Monday 18 May 2009 04:37:54 Wolfgang Denk wrote:
Quoted 3 lines · In message Mike Frysinger
The kernel stores address<->symbol names in it so things can be decoded at runtime. Do it in U-Boot, and we get nice symbol decoding when crashing.
I like the idea as a pretty useful debug help.
If nobody objects I guess we could pull this into "next" ?
part of this patch moves stuff out of the Blackfin specific code, so if no one objects, i'll repost the "full" version which would be ok for "next". -mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
Url : http://lists.denx.de/pipermail/u-boot/attachments/20090518/073316b1/attachment.pgp
PATCH v2 1/1 Add support for Linux-like kallsysms
The kernel stores address<->symbol names in it so things can be decoded at runtime. Do it in U-Boot, and we get nice symbol decoding when crashing. Some of this code was already in the Blackfin port, so generalize and split it out for everyone to use.
---
v2
- complete patch made against the "next" branch
Makefile | 17 +++++++++++--- common/Makefile | 1 + common/kallsyms.c | 44 +++++++++++++++++++++++++++++++++++++ common/system_map.c | 8 ++++++ cpu/blackfin/system_map.S | 18 --------------- cpu/blackfin/traps.c | 35 ++++------------------------- include/common.h | 3 ++ include/configs/bfin_adi_common.h | 2 +- 8 files changed, 75 insertions(+), 53 deletions(-) create mode 100644 common/kallsyms.c create mode 100644 common/system_map.c delete mode 100644 cpu/blackfin/system_map.S
Makefile +13 -4
@@ -344,12 +344,19 @@ $(obj)u-boot.sha1: $(obj)u-boot.bin $(obj)u-boot.dis: $(obj)u-boot $(OBJDUMP) -d $< > $@ -$(obj)u-boot: depend $(SUBDIRS) $(OBJS) $(LIBBOARD) $(LIBS) $(LDSCRIPT) +GEN_UBOOT = \ UNDEF_SYM=`$(OBJDUMP) -x $(LIBBOARD) $(LIBS) | \ sed -n -e 's/.*\($(SYM_PREFIX)__u_boot_cmd_.*\)/-u\1/p'|sort|uniq`;\ cd $(LNDIR) && $(LD) $(LDFLAGS) $$UNDEF_SYM $(__OBJS) \ --start-group $(__LIBS) --end-group $(PLATFORM_LIBS) \ -Map u-boot.map -o u-boot +$(obj)u-boot: depend $(SUBDIRS) $(OBJS) $(LIBBOARD) $(LIBS) $(LDSCRIPT) + $(GEN_UBOOT) +ifeq ($(CONFIG_KALLSYMS),y) + smap=`$(call SYSTEM_MAP,u-boot) | awk '$$2 ~ /[tTwW]/ {printf $$1 $$3 "\\0"}'` ; \ + $(CC) $(CFLAGS) -DSYSTEM_MAP="\"$${smap}\"" -c common/system_map.c -o $(obj)common/system_map.o + $(GEN_UBOOT) $(obj)common/system_map.o +endif $(OBJS): depend $(MAKE) -C cpu/$(CPU) $(if $(REMOTE_BUILD),$@,$(notdir $@))
@@ -448,10 +455,12 @@ cscope: > cscope.files cscope -b -q -k -$(obj)System.map: $(obj)u-boot - @$(NM) $< | \ +SYSTEM_MAP = \ + $(NM) $1 | \ grep -v '\(compiled\)\|\(\.o$$\)\|\( [aUw] \)\|\(\.\.ng$$\)\|\(LASH[RL]DI\)' | \ - sort > $(obj)System.map + LC_ALL=C sort +$(obj)System.map: $(obj)u-boot + @$(call SYSTEM_MAP,$<) > $(obj)System.map # # Auto-generate the autoconf.mk file (which is included by all makefiles)
common/Makefile +1 -0
@@ -153,6 +153,7 @@ COBJS-$(CONFIG_CMD_DOC) += docecc.o COBJS-$(CONFIG_CONSOLE_MUX) += iomux.o COBJS-y += flash.o COBJS-$(CONFIG_CMD_KGDB) += kgdb.o +COBJS-$(CONFIG_KALLSYMS) += kallsyms.o COBJS-$(CONFIG_LCD) += lcd.o COBJS-$(CONFIG_LYNXKDI) += lynxkdi.o COBJS-$(CONFIG_UPDATE_TFTP) += update.o
common/kallsyms.c new file +44 -0
44 lines not on this page · raw message
common/system_map.c new file +8 -0
@@ -0,0 +1,8 @@ +/* +* The builtin symbol table for use with kallsyms +* +* Copyright (c) 2008-2009 Analog Devices Inc. +* Licensed under the GPL-2 or later. +*/ + +const char const system_map[] =SYSTEM_MAP ;
cpu/blackfin/system_map.S deleted +0 -18
@@ -1,18 +0,0 @@ -/* - * system_map.S - optional symbol lookup for debugging - * - * Copyright (c) 2007 Analog Devices Inc. - * Licensed under the GPL-2 or later. - */ - -#include <config.h> - -#ifdef CONFIG_DEBUG_DUMP_SYMS -.data -.global _system_map -.type _system_map, at object -_system_map: -#include SYM_FILE -.asciz "" -.size _system_map,.-_system_map -#endif
cpu/blackfin/traps.c +5 -30
@@ -171,38 +171,13 @@ void trap_c(struct pt_regs *regs)# define ENABLE_DUMP 0#endif -#ifdef CONFIG_DEBUG_DUMP_SYMS -# define ENABLE_DUMP_SYMS 1 -#else -# define ENABLE_DUMP_SYMS 0 -#endif - -static const char *symbol_lookup (unsigned long addr,unsigned long *caddr) +#ifndef CONFIG_KALLSYMS +const char *symbol_lookup (unsigned long addr,unsigned long *caddr); { -if (!ENABLE_DUMP_SYMS ) -return NULL ; - - extern const char system_map[] __attribute__((__weak__)); -const char *sym, *csym; -char *esym; -unsigned long sym_addr; - - sym = system_map; - csym =NULL ; - *caddr =0 ; - -while (*sym) { - sym_addr =simple_strtoul (sym, &esym,16 ); - sym = esym; -if (sym_addr > addr) -break ; - *caddr = sym_addr; - csym = sym; - sym +=strlen (sym) +1 ; - } - -return csym; + *caddr = addr; +return "N/A" ; } +#endif static void decode_address (char *buf,unsigned long address) {
include/common.h +3 -0
@@ -300,6 +300,9 @@ int misc_init_r (void);/* common/exports.c */ void jumptable_init (void ); +/* common/kallsysm.c */ +const char *symbol_lookup (unsigned long addr,unsigned long *caddr); +/* api/api.c */ void api_init (void );
include/configs/bfin_adi_common.h +1 -1
@@ -91,7 +91,7 @@*/ #define CONFIG_ENV_OVERWRITE 1#define CONFIG_DEBUG_DUMP 1 -#define CONFIG_DEBUG_DUMP_SYMS 1 +#define CONFIG_KALLSYMS 1#define CONFIG_PANIC_HANG 1/*
Signature · 1 line
1.6.3.1
PATCH v3 1/1 Add support for Linux-like kallsysms
The kernel stores address<->symbol names in it so things can be decoded at runtime. Do it in U-Boot, and we get nice symbol decoding when crashing.
---
this one is still against "next" branch
v3
- fix typo in new Blackfin code (spurious semicolon)
Makefile | 17 +++++++++++--- common/Makefile | 1 + common/kallsyms.c | 44 +++++++++++++++++++++++++++++++++++++ common/system_map.c | 8 ++++++ cpu/blackfin/system_map.S | 18 --------------- cpu/blackfin/traps.c | 35 ++++------------------------- include/common.h | 3 ++ include/configs/bfin_adi_common.h | 2 +- 8 files changed, 75 insertions(+), 53 deletions(-) create mode 100644 common/kallsyms.c create mode 100644 common/system_map.c delete mode 100644 cpu/blackfin/system_map.S
Makefile +13 -4
@@ -344,12 +344,19 @@ $(obj)u-boot.sha1: $(obj)u-boot.bin $(obj)u-boot.dis: $(obj)u-boot $(OBJDUMP) -d $< > $@ -$(obj)u-boot: depend $(SUBDIRS) $(OBJS) $(LIBBOARD) $(LIBS) $(LDSCRIPT) +GEN_UBOOT = \ UNDEF_SYM=`$(OBJDUMP) -x $(LIBBOARD) $(LIBS) | \ sed -n -e 's/.*\($(SYM_PREFIX)__u_boot_cmd_.*\)/-u\1/p'|sort|uniq`;\ cd $(LNDIR) && $(LD) $(LDFLAGS) $$UNDEF_SYM $(__OBJS) \ --start-group $(__LIBS) --end-group $(PLATFORM_LIBS) \ -Map u-boot.map -o u-boot +$(obj)u-boot: depend $(SUBDIRS) $(OBJS) $(LIBBOARD) $(LIBS) $(LDSCRIPT) + $(GEN_UBOOT) +ifeq ($(CONFIG_KALLSYMS),y) + smap=`$(call SYSTEM_MAP,u-boot) | awk '$$2 ~ /[tTwW]/ {printf $$1 $$3 "\\0"}'` ; \ + $(CC) $(CFLAGS) -DSYSTEM_MAP="\"$${smap}\"" -c common/system_map.c -o $(obj)common/system_map.o + $(GEN_UBOOT) $(obj)common/system_map.o +endif $(OBJS): depend $(MAKE) -C cpu/$(CPU) $(if $(REMOTE_BUILD),$@,$(notdir $@))
@@ -448,10 +455,12 @@ cscope: > cscope.files cscope -b -q -k -$(obj)System.map: $(obj)u-boot - @$(NM) $< | \ +SYSTEM_MAP = \ + $(NM) $1 | \ grep -v '\(compiled\)\|\(\.o$$\)\|\( [aUw] \)\|\(\.\.ng$$\)\|\(LASH[RL]DI\)' | \ - sort > $(obj)System.map + LC_ALL=C sort +$(obj)System.map: $(obj)u-boot + @$(call SYSTEM_MAP,$<) > $(obj)System.map # # Auto-generate the autoconf.mk file (which is included by all makefiles)
common/Makefile +1 -0
@@ -153,6 +153,7 @@ COBJS-$(CONFIG_CMD_DOC) += docecc.o COBJS-$(CONFIG_CONSOLE_MUX) += iomux.o COBJS-y += flash.o COBJS-$(CONFIG_CMD_KGDB) += kgdb.o +COBJS-$(CONFIG_KALLSYMS) += kallsyms.o COBJS-$(CONFIG_LCD) += lcd.o COBJS-$(CONFIG_LYNXKDI) += lynxkdi.o COBJS-$(CONFIG_UPDATE_TFTP) += update.o
common/kallsyms.c new file +44 -0
44 lines not on this page · raw message
common/system_map.c new file +8 -0
@@ -0,0 +1,8 @@ +/* +* The builtin symbol table for use with kallsyms +* +* Copyright (c) 2008-2009 Analog Devices Inc. +* Licensed under the GPL-2 or later. +*/ + +const char const system_map[] =SYSTEM_MAP ;
cpu/blackfin/system_map.S deleted +0 -18
@@ -1,18 +0,0 @@ -/* - * system_map.S - optional symbol lookup for debugging - * - * Copyright (c) 2007 Analog Devices Inc. - * Licensed under the GPL-2 or later. - */ - -#include <config.h> - -#ifdef CONFIG_DEBUG_DUMP_SYMS -.data -.global _system_map -.type _system_map, at object -_system_map: -#include SYM_FILE -.asciz "" -.size _system_map,.-_system_map -#endif
cpu/blackfin/traps.c +5 -30
@@ -171,38 +171,13 @@ void trap_c(struct pt_regs *regs)# define ENABLE_DUMP 0#endif -#ifdef CONFIG_DEBUG_DUMP_SYMS -# define ENABLE_DUMP_SYMS 1 -#else -# define ENABLE_DUMP_SYMS 0 -#endif - -static const char *symbol_lookup (unsigned long addr,unsigned long *caddr) +#ifndef CONFIG_KALLSYMS +const char *symbol_lookup (unsigned long addr,unsigned long *caddr) { -if (!ENABLE_DUMP_SYMS ) -return NULL ; - - extern const char system_map[] __attribute__((__weak__)); -const char *sym, *csym; -char *esym; -unsigned long sym_addr; - - sym = system_map; - csym =NULL ; - *caddr =0 ; - -while (*sym) { - sym_addr =simple_strtoul (sym, &esym,16 ); - sym = esym; -if (sym_addr > addr) -break ; - *caddr = sym_addr; - csym = sym; - sym +=strlen (sym) +1 ; - } - -return csym; + *caddr = addr; +return "N/A" ; } +#endif static void decode_address (char *buf,unsigned long address) {
include/common.h +3 -0
@@ -300,6 +300,9 @@ int misc_init_r (void);/* common/exports.c */ void jumptable_init (void ); +/* common/kallsysm.c */ +const char *symbol_lookup (unsigned long addr,unsigned long *caddr); +/* api/api.c */ void api_init (void );
include/configs/bfin_adi_common.h +1 -1
@@ -91,7 +91,7 @@*/ #define CONFIG_ENV_OVERWRITE 1#define CONFIG_DEBUG_DUMP 1 -#define CONFIG_DEBUG_DUMP_SYMS 1 +#define CONFIG_KALLSYMS 1#define CONFIG_PANIC_HANG 1/*
Signature · 1 line
1.6.3.1
PATCH v3 1/1 Add support for Linux-like kallsysms
Quoted 9 lines · Mike Frysinger
The kernel stores address<->symbol names in it so things can be decoded at runtime. Do it in U-Boot, and we get nice symbol decoding when crashing.
Signed-off-by Mike Frysinger <[email protected]>---
this one is still against "next" branchv3
- fix typo in new Blackfin code (spurious semicolon)
could you do this in two patch?
Best Regards,
J.
PATCH v3 1/1 Add support for Linux-like kallsysms
Quoted 5 lines · On Wednesday 20 May 2009 12:39:33 Jean-Christophe PLAGNIOL-VILLARD wrote:
Quoted 4 lines · Mike Frysinger
The kernel stores address<->symbol names in it so things can be decoded at runtime. Do it in U-Boot, and we get nice symbol decoding when crashing.
Quoted 8 lines
Quoted 6 lines
Signed-off-by Mike Frysinger <[email protected]>---
this one is still against "next" branchv3
- fix typo in new Blackfin code (spurious semicolon)could you do this in two patch?
i could, but the existing patch is mostly a rename. the symbol_lookup() function which makes up most of the kallsysm.c file already existed in the Blackfin directory as is.
-mike
Wolfgang Denk
AppliedPATCH v3 1/1 Add support for Linux-like kallsysms
In reply to Mike FrysingerDear Mike Frysinger,
Quoted 10 lines · In message <[email protected]> you wrote:
The kernel stores address<->symbol names in it so things can be decoded at runtime. Do it in U-Boot, and we get nice symbol decoding when crashing.
Signed-off-by Mike Frysinger <[email protected]>---
this one is still against "next" branchv3
- fix typo in new Blackfin code (spurious semicolon)
Quoted 12 lines
Makefile | 17 +++++++++++--- common/Makefile | 1 + common/kallsyms.c | 44 +++++++++++++++++++++++++++++++++++++ common/system_map.c | 8 ++++++ cpu/blackfin/system_map.S | 18 --------------- cpu/blackfin/traps.c | 35 ++++------------------------- include/common.h | 3 ++ include/configs/bfin_adi_common.h | 2 +- 8 files changed, 75 insertions(+), 53 deletions(-) create mode 100644 common/kallsyms.c create mode 100644 common/system_map.c delete mode 100644 cpu/blackfin/system_map.S
Applied to next. Thanks.
Best regards,
Wolfgang Denk
Signature · 5 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de I am a computer. I am dumber than any human and smarter than any ad- ministrator.