linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Kai Germaschewski <kai-germaschewski@uiowa.edu>
To: Linus Torvalds <torvalds@transmeta.com>
Cc: Ingo Molnar <mingo@elte.hu>, <linux-kernel@vger.kernel.org>,
	Rusty Russell <rusty@rustcorp.com.au>,
	Arjan van de Ven <arjanv@redhat.com>
Subject: Re: [ANNOUNCE] [patch] kksymoops, in-kernel symbolic oopser, 2.5.38-B0
Date: Wed, 25 Sep 2002 14:23:14 -0500 (CDT)	[thread overview]
Message-ID: <Pine.LNX.4.44.0209251415500.28659-100000@chaos.physics.uiowa.edu> (raw)
In-Reply-To: <Pine.LNX.4.33.0209251113530.1817-100000@penguin.transmeta.com>

On Wed, 25 Sep 2002, Linus Torvalds wrote:

> On Wed, 25 Sep 2002, Ingo Molnar wrote:
> >
> > EIP is at sys_gettimeofday [kernel] 0x84
> > Call Trace: [<c0112a40>] do_page_fault [kernel] 0x0
> > [<c0107973>] syscall_call [kernel] 0x7
> 
> At a minimum, fix this to:
> 
>  - not print out that stupid "kernel" thing. Of _course_ it is the kernel. 
>    Modules can put their module name to clarify, but the core kernel 
>    certainly doesn't "clarify" anything by putting "kernel" there.
> 
>  - print out offset/length like the user-space ksymoops does. Without the 
>    offset the thing is useless, since you still need the real address to 
>    actually look up which instruction faulted.

Alright, I did these modifications (however, even the current version 
prints the offset, just not the length, which does not have too much 
meaning anyway)

So this patch converts the output to the more familiar

	sys_gettimeofday+0x84/0x108 [module-name]

format, where module-name is "" for the kernel. 

Ingo, could you test the modifications again, please? Also, I worked 
against my latest version, if you did additional changes after the last 
version I sent you, they need to be merged back in.

--Kai


Pull from http://linux-isdn.bkbits.net/linux-2.5.kallsyms

(Merging changesets omitted for clarity)

-----------------------------------------------------------------------------
ChangeSet@1.609, 2002-09-25 14:11:06-05:00, kai@tp1.ruhr-uni-bochum.de
  kksymoops: cosmetics
  
  Don't print "kernel" when a symbol is in the kernel.
  
  Change the output format to
  sys_gettimeofday+0x84/0x108 [module].

 ----------------------------------------------------------------------------
 module.c |   75 ++++++++++++++++++++++++++++++++++++---------------------------
 1 files changed, 44 insertions(+), 31 deletions(-)





=============================================================================
unified diffs follow for reference
=============================================================================


-----------------------------------------------------------------------------
ChangeSet@1.609, 2002-09-25 14:11:06-05:00, kai@tp1.ruhr-uni-bochum.de
  kksymoops: cosmetics
  
  Don't print "kernel" when a symbol is in the kernel.
  
  Change the output format to
  sys_gettimeofday+0x84/0x108 [module].

  ---------------------------------------------------------------------------

diff -Nru a/kernel/module.c b/kernel/module.c
--- a/kernel/module.c	Wed Sep 25 14:18:41 2002
+++ b/kernel/module.c	Wed Sep 25 14:18:41 2002
@@ -52,7 +52,7 @@
 struct module kernel_module =
 {
 	.size_of_struct		= sizeof(struct module),
-	.name 			= "kernel",
+	.name 			= "",
 	.uc	 		= {ATOMIC_INIT(1)},
 	.flags			= MOD_RUNNING,
 	.syms			= __start___ksymtab,
@@ -1307,48 +1307,61 @@
 
 #define MAX_SYMBOL_SIZE 512
 
-int print_symbol(const char *fmt, unsigned long address)
+static void
+address_to_exported_symbol(unsigned long address, const char **mod_name, 
+			   const char **sym_name, unsigned long *sym_start,
+			   unsigned long *sym_end)
 {
 	struct module *this_mod;
-	unsigned long bestsofar;
+	int i;
+
+	for (this_mod = module_list; this_mod; this_mod = this_mod->next) {
+		/* walk the symbol list of this module. Only symbols
+		   who's address is smaller than the searched for address
+		   are relevant; and only if it's better than the best so far */
+		for (i = 0; i < this_mod->nsyms; i++)
+			if ((this_mod->syms[i].value <= address) &&
+			    (*sym_start < this_mod->syms[i].value)) {
+				*sym_start = this_mod->syms[i].value;
+				*sym_name  = this_mod->syms[i].name;
+				*mod_name  = this_mod->name;
+				if (i + 1 < this_mod->nsyms)
+					*sym_end = this_mod->syms[i+1].value;
+				else
+					*sym_end = (unsigned long) this_mod + this_mod->size;
+			}
+	}
+}
+
+int
+print_symbol(const char *fmt, unsigned long address)
+{
 	/* static to not take up stackspace; if we race here too bad */
 	static char buffer[MAX_SYMBOL_SIZE];
 
 	const char *mod_name = NULL, *sec_name = NULL, *sym_name = NULL;
 	unsigned long mod_start, mod_end, sec_start, sec_end,
-							sym_start, sym_end;
+		sym_start, sym_end;
+	char *tag = "";
 	
 	memset(buffer, 0, MAX_SYMBOL_SIZE);
 
-	if (!kallsyms_address_to_symbol(address,&mod_name,&mod_start,&mod_end,&sec_name, &sec_start, &sec_end, &sym_name, &sym_start, &sym_end)) {
-		/* kallsyms doesn't have a clue; lets try our list 
-		 * of exported symbols */
-		bestsofar = 0;
-		sprintf(buffer, "[unresolved]");
-		
-		for (this_mod = module_list; this_mod; this_mod = this_mod->next) {
-			int i;
-			/* walk the symbol list of this module. Only symbols
-			   who's address is smaller than the searched for address
-			   are relevant; and only if it's better than the best so far */
-			for (i = 0; i < this_mod->nsyms; i++)
-				if ((this_mod->syms[i].value <= address) &&
-				    (bestsofar < this_mod->syms[i].value)) {
-					snprintf(buffer, MAX_SYMBOL_SIZE - 1,
-						 "%s [%s] 0x%x",
-						this_mod->syms[i].name,
-						this_mod->name,
-						(unsigned int)(address - this_mod->syms[i].value));
-					bestsofar = this_mod->syms[i].value;
-				}
-		}
+	sym_start = 0;
+	if (!kallsyms_address_to_symbol(address, &mod_name, &mod_start, &mod_end, &sec_name, &sec_start, &sec_end, &sym_name, &sym_start, &sym_end)) {
+		tag = "E ";
+		address_to_exported_symbol(address, &mod_name, &sym_name, &sym_start, &sym_end);
+	}
 
-	} else { /* kallsyms success */
-		snprintf(buffer,MAX_SYMBOL_SIZE - 1, "%s [%s] 0x%x",
-			 sym_name, mod_name,
-			 (unsigned int)(address - sym_start));
+	if (sym_start) {
+		snprintf(buffer, MAX_SYMBOL_SIZE - 1, "%s%s+%#x/%#x [%s]",
+			 tag, sym_name,
+			 (unsigned int)(address - sym_start),
+			 (unsigned int)(sym_end - sym_start),
+			 mod_name);
+		printk(fmt, buffer);
+	} else {
+		printk(fmt, "[unresolved]");
 	}
-	printk(fmt, buffer);
 	return 0;
 }
 





  reply	other threads:[~2002-09-25 19:18 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-09-25  9:02 [ANNOUNCE] [patch] kksymoops, in-kernel symbolic oopser, 2.5.38-B0 Ingo Molnar
2002-09-25  9:32 ` [re-ANNOUNCE] " Ingo Molnar
2002-09-25  9:51   ` Arnaldo Carvalho de Melo
2002-09-25 18:16 ` [ANNOUNCE] " Linus Torvalds
2002-09-25 19:23   ` Kai Germaschewski [this message]
2002-09-25 19:42     ` Ingo Molnar
2002-09-25 19:41       ` Kai Germaschewski
2002-09-25 19:46       ` Linus Torvalds
2002-09-25 19:54         ` Ingo Molnar
2002-09-25 19:52           ` Linus Torvalds
2002-09-25 20:04             ` Ingo Molnar
2002-09-25 20:31             ` Jeff Garzik
2002-09-25 19:55           ` Kai Germaschewski
2002-09-25 19:45     ` Linus Torvalds
2002-09-25 19:53       ` Ingo Molnar
2002-09-25 19:04         ` Cort Dougan
2002-09-25 20:14           ` Ingo Molnar
2002-09-25 19:56       ` Ingo Molnar
2002-09-25 22:04         ` J.A. Magallon
2002-09-27 20:48           ` Bill Davidsen
2002-09-27 21:13             ` Ingo Molnar
2002-09-27 23:58               ` J.A. Magallon
2002-09-26 17:16         ` Ruth Ivimey-Cook

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Pine.LNX.4.44.0209251415500.28659-100000@chaos.physics.uiowa.edu \
    --to=kai-germaschewski@uiowa.edu \
    --cc=arjanv@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=rusty@rustcorp.com.au \
    --cc=torvalds@transmeta.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).