All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] All Symbols in /proc/kallsyms
@ 2004-05-10  5:28 Rusty Russell
  2004-05-10  6:05 ` Keith Owens
  2004-05-10 23:13 ` Tom Rini
  0 siblings, 2 replies; 3+ messages in thread
From: Rusty Russell @ 2004-05-10  5:28 UTC (permalink / raw)
  To: Paul Mackerras, Andrew Morton; +Cc: lkml - Kernel Mailing List, Sam Ravnborg

Debuggers (ie. xmon) can use kallsyms, but they want all symbols, not
just functions.  Fair enough.

Name: Debugging Option to Put text symbols in kallsyms
Status: Tested on 2.6.6-rc3-bk11

kallsyms contains only function names, but some debuggers (eg. xmon on
PPC/PPC64) use it to lookup symbols: it'd be much nicer if it included
data symbols too.


diff -urpN --exclude TAGS -X /home/rusty/devel/kernel/kernel-patches/current-dontdiff --minimal .5274-linux-2.6.6-rc2-bk4/Makefile .5274-linux-2.6.6-rc2-bk4.updated/Makefile
diff -urpN --exclude TAGS -X /home/rusty/devel/kernel/kernel-patches/current-dontdiff --minimal .21129-linux-2.6.6-rc2-bk4/Makefile .21129-linux-2.6.6-rc2-bk4.updated/Makefile
diff -urpN --exclude TAGS -X /home/rusty/devel/kernel/kernel-patches/current-dontdiff --minimal .21201-linux-2.6.6-rc3-bk11/Makefile .21201-linux-2.6.6-rc3-bk11.updated/Makefile
--- .21201-linux-2.6.6-rc3-bk11/Makefile	2004-05-10 09:01:11.000000000 +1000
+++ .21201-linux-2.6.6-rc3-bk11.updated/Makefile	2004-05-10 15:09:44.000000000 +1000
@@ -567,7 +567,7 @@ ifdef CONFIG_KALLSYMS
 kallsyms.o := .tmp_kallsyms2.o
 
 quiet_cmd_kallsyms = KSYM    $@
-cmd_kallsyms = $(NM) -n $< | $(KALLSYMS) > $@
+cmd_kallsyms = $(NM) -n $< | $(KALLSYMS) $(foreach x,$(CONFIG_KALLSYMS_ALL),--all-symbols) > $@
 
 .tmp_kallsyms1.o .tmp_kallsyms2.o: %.o: %.S scripts FORCE
 	$(call if_changed_dep,as_o_S)
diff -urpN --exclude TAGS -X /home/rusty/devel/kernel/kernel-patches/current-dontdiff --minimal .21201-linux-2.6.6-rc3-bk11/init/Kconfig .21201-linux-2.6.6-rc3-bk11.updated/init/Kconfig
--- .21201-linux-2.6.6-rc3-bk11/init/Kconfig	2004-04-29 17:30:12.000000000 +1000
+++ .21201-linux-2.6.6-rc3-bk11.updated/init/Kconfig	2004-05-10 15:09:44.000000000 +1000
@@ -235,6 +235,17 @@ config KALLSYMS
 	   symbolic stack backtraces. This increases the size of the kernel
 	   somewhat, as all symbols have to be loaded into the kernel image.
 
+config KALLSYMS_ALL
+	bool "Include all symbols in kallsyms"
+	depends on DEBUG_KERNEL && KALLSYMS
+	help
+	   Normally kallsyms only contains the symbols of functions, for nicer
+	   OOPS messages.  Some debuggers can use kallsyms for other
+	   symbols too: say Y here to include all symbols, and you
+	   don't care about adding 300k to the size of your kernel.
+
+	   Say N.
+
 config FUTEX
 	bool "Enable futex support" if EMBEDDED
 	default y
diff -urpN --exclude TAGS -X /home/rusty/devel/kernel/kernel-patches/current-dontdiff --minimal .21201-linux-2.6.6-rc3-bk11/kernel/kallsyms.c .21201-linux-2.6.6-rc3-bk11.updated/kernel/kallsyms.c
--- .21201-linux-2.6.6-rc3-bk11/kernel/kallsyms.c	2004-03-12 07:57:28.000000000 +1100
+++ .21201-linux-2.6.6-rc3-bk11.updated/kernel/kallsyms.c	2004-05-10 15:10:59.000000000 +1000
@@ -183,7 +183,10 @@ static void get_ksymbol_core(struct kall
 	iter->nameoff += strlen(kallsyms_names + iter->nameoff) + 1;
 	iter->owner = NULL;
 	iter->value = kallsyms_addresses[iter->pos];
-	iter->type = 't';
+	if (is_kernel_text(iter->value) || is_kernel_inittext(iter->value))
+		iter->type = 't';
+	else
+		iter->type = 'd';
 
 	upcase_if_global(iter);
 }
diff -urpN --exclude TAGS -X /home/rusty/devel/kernel/kernel-patches/current-dontdiff --minimal .21201-linux-2.6.6-rc3-bk11/scripts/kallsyms.c .21201-linux-2.6.6-rc3-bk11.updated/scripts/kallsyms.c
--- .21201-linux-2.6.6-rc3-bk11/scripts/kallsyms.c	2003-09-22 10:07:21.000000000 +1000
+++ .21201-linux-2.6.6-rc3-bk11.updated/scripts/kallsyms.c	2004-05-10 15:09:44.000000000 +1000
@@ -5,7 +5,7 @@
  * This software may be used and distributed according to the terms
  * of the GNU General Public License, incorporated herein by reference.
  *
- * Usage: nm -n vmlinux | scripts/kallsyms > symbols.S
+ * Usage: nm -n vmlinux | scripts/kallsyms [--all-symbols] > symbols.S
  */
 
 #include <stdio.h>
@@ -22,11 +22,12 @@ struct sym_entry {
 static struct sym_entry *table;
 static int size, cnt;
 static unsigned long long _stext, _etext, _sinittext, _einittext;
+static int all_symbols = 0;
 
 static void
 usage(void)
 {
-	fprintf(stderr, "Usage: kallsyms < in.map > out.S\n");
+	fprintf(stderr, "Usage: kallsyms [--all-symbols] < in.map > out.S\n");
 	exit(1);
 }
 
@@ -51,9 +52,11 @@ read_symbol(FILE *in, struct sym_entry *
 static int
 symbol_valid(struct sym_entry *s)
 {
-	if ((s->addr < _stext || s->addr > _etext)
-	    && (s->addr < _sinittext || s->addr > _einittext))
-		return 0;
+	if (!all_symbols) {
+		if ((s->addr < _stext || s->addr > _etext)
+		    && (s->addr < _sinittext || s->addr > _einittext))
+			return 0;
+	}
 
 	if (strstr(s->sym, "_compiled."))
 		return 0;
@@ -156,7 +159,9 @@ write_src(void)
 int
 main(int argc, char **argv)
 {
-	if (argc != 1)
+	if (argc == 2 && strcmp(argv[1], "--all-symbols") == 0)
+		all_symbols = 1;
+	else if (argc != 1)
 		usage();
 
 	read_map(stdin);

-- 
Anyone who quotes me in their signature is an idiot -- Rusty Russell


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] All Symbols in /proc/kallsyms
  2004-05-10  5:28 [PATCH] All Symbols in /proc/kallsyms Rusty Russell
@ 2004-05-10  6:05 ` Keith Owens
  2004-05-10 23:13 ` Tom Rini
  1 sibling, 0 replies; 3+ messages in thread
From: Keith Owens @ 2004-05-10  6:05 UTC (permalink / raw)
  To: Rusty Russell
  Cc: Paul Mackerras, Andrew Morton, lkml - Kernel Mailing List,
	Sam Ravnborg

On Mon, 10 May 2004 15:28:37 +1000, 
Rusty Russell <rusty@rustcorp.com.au> wrote:
>Debuggers (ie. xmon) can use kallsyms, but they want all symbols, not
>just functions.  Fair enough.
>
>Name: Debugging Option to Put text symbols in kallsyms
>Status: Tested on 2.6.6-rc3-bk11
>
>kallsyms contains only function names, but some debuggers (eg. xmon on
>PPC/PPC64) use it to lookup symbols: it'd be much nicer if it included
>data symbols too.

The patch needs some more work.  You are including absolute symbols
that are outside the kernel text and data space, which can be very
misleading.  For debugging, you want all symbols, even if they have the
same address as the previous symbol.

The kdb 2.6.6 patch for scripts/kallsyms follows.  I cannot remember
why I excluded kallsyms_addresses, kallsyms_num_syms and
kallsyms_names, there must have been a good reason at the time.

Index: linux/scripts/kallsyms.c
--- linux.orig/scripts/kallsyms.c	Mon May 10 12:33:21 2004
+++ linux/scripts/kallsyms.c	Mon May 10 14:07:41 2004
@@ -6,6 +6,7 @@
  * of the GNU General Public License, incorporated herein by reference.
  *
  * Usage: nm -n vmlinux | scripts/kallsyms > symbols.S
+ * If CONFIG_KDB is defined, generate all symbols for kdb.
  */
 
 #include <stdio.h>
@@ -21,7 +22,12 @@ struct sym_entry {
 
 static struct sym_entry *table;
 static int size, cnt;
-static unsigned long long _stext, _etext, _sinittext, _einittext;
+static unsigned long long _stext, _etext, _sinittext, _einittext, _end;
+#ifdef CONFIG_KDB
+#define kdb 1
+#else
+#define kdb 0
+#endif
 
 static void
 usage(void)
@@ -51,12 +57,18 @@ read_symbol(FILE *in, struct sym_entry *
 static int
 symbol_valid(struct sym_entry *s)
 {
-	if ((s->addr < _stext || s->addr > _etext)
+	if ((s->addr < _stext || (kdb && s->addr > _end) || (!kdb && s->addr > _etext))
 	    && (s->addr < _sinittext || s->addr > _einittext))
 		return 0;
 
 	if (strstr(s->sym, "_compiled."))
 		return 0;
+	if (kdb) {
+		if (strcmp(s->sym, "kallsyms_addresses") == 0 ||
+		    strcmp(s->sym, "kallsyms_num_syms") == 0 ||
+		    strcmp(s->sym, "kallsyms_names") == 0)
+		return 0;
+	}
 
 	return 1;
 }
@@ -87,6 +99,8 @@ read_map(FILE *in)
 			_sinittext = table[i].addr;
 		if (strcmp(table[i].sym, "_einittext") == 0)
 			_einittext = table[i].addr;
+		if (kdb && strcmp(table[i].sym, "_end") == 0)
+			_end = table[i].addr;
 	}
 }
 
@@ -115,7 +129,7 @@ write_src(void)
 		if (!symbol_valid(&table[i]))
 			continue;
 		
-		if (table[i].addr == last_addr)
+		if (table[i].addr == last_addr && !kdb)
 			continue;
 
 		printf("\tPTR\t%#llx\n", table[i].addr);
@@ -140,7 +154,7 @@ write_src(void)
 		if (!symbol_valid(&table[i]))
 			continue;
 		
-		if (table[i].addr == last_addr)
+		if (table[i].addr == last_addr && !kdb)
 			continue;
 
 		for (k = 0; table[i].sym[k] && table[i].sym[k] == prev[k]; ++k)


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] All Symbols in /proc/kallsyms
  2004-05-10  5:28 [PATCH] All Symbols in /proc/kallsyms Rusty Russell
  2004-05-10  6:05 ` Keith Owens
@ 2004-05-10 23:13 ` Tom Rini
  1 sibling, 0 replies; 3+ messages in thread
From: Tom Rini @ 2004-05-10 23:13 UTC (permalink / raw)
  To: Rusty Russell
  Cc: Paul Mackerras, Andrew Morton, lkml - Kernel Mailing List,
	Sam Ravnborg

On Mon, May 10, 2004 at 03:28:37PM +1000, Rusty Russell wrote:

> Debuggers (ie. xmon) can use kallsyms, but they want all symbols, not
> just functions.  Fair enough.
> 
> Name: Debugging Option to Put text symbols in kallsyms
> Status: Tested on 2.6.6-rc3-bk11
> 
> kallsyms contains only function names, but some debuggers (eg. xmon on
> PPC/PPC64) use it to lookup symbols: it'd be much nicer if it included
> data symbols too.

Shouldn't you make xmon depend on both of these, on ppc64? 
(iirc, it won't compile w/o KALLSYMS, so select/suggest, or whatever,
and ppc32 hasn't yet had the kallsyms stuff backported).

-- 
Tom Rini
http://gate.crashing.org/~trini/

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2004-05-10 23:17 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-05-10  5:28 [PATCH] All Symbols in /proc/kallsyms Rusty Russell
2004-05-10  6:05 ` Keith Owens
2004-05-10 23:13 ` Tom Rini

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.