diff options
author | Jan Beulich <jbeulich@novell.com> | 2006-01-11 16:46:48 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2006-01-11 22:05:03 -0500 |
commit | 5f1d189f8a87930d62c507800a8ac20b9a185e41 (patch) | |
tree | f83f756d8481dafe3b8ddba5b741ec6b5cf33e96 /arch/x86_64/kernel/traps.c | |
parent | 1b2f6304500930ab534a6aa3198bce0c51586206 (diff) |
[PATCH] x86_64: Display meaningful part of filename during BUG()
When building in a separate objtree, file names produced by BUG() & Co. can
get fairly long; printing only the first 50 characters may thus result in
(almost) no useful information. The following change makes it so that rather
the last 50 characters of the filename get printed.
Signed-Off-By: Jan Beulich <jbeulich@novell.com>
Signed-off-by: Andi Kleen <ak@suse.de>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'arch/x86_64/kernel/traps.c')
-rw-r--r-- | arch/x86_64/kernel/traps.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/arch/x86_64/kernel/traps.c b/arch/x86_64/kernel/traps.c index d345c712c6ca..2671fd46ea85 100644 --- a/arch/x86_64/kernel/traps.c +++ b/arch/x86_64/kernel/traps.c | |||
@@ -340,7 +340,8 @@ bad: | |||
340 | void handle_BUG(struct pt_regs *regs) | 340 | void handle_BUG(struct pt_regs *regs) |
341 | { | 341 | { |
342 | struct bug_frame f; | 342 | struct bug_frame f; |
343 | char tmp; | 343 | long len; |
344 | const char *prefix = ""; | ||
344 | 345 | ||
345 | if (user_mode(regs)) | 346 | if (user_mode(regs)) |
346 | return; | 347 | return; |
@@ -350,10 +351,15 @@ void handle_BUG(struct pt_regs *regs) | |||
350 | if (f.filename >= 0 || | 351 | if (f.filename >= 0 || |
351 | f.ud2[0] != 0x0f || f.ud2[1] != 0x0b) | 352 | f.ud2[0] != 0x0f || f.ud2[1] != 0x0b) |
352 | return; | 353 | return; |
353 | if (__get_user(tmp, (char *)(long)f.filename)) | 354 | len = __strnlen_user((char *)(long)f.filename, PATH_MAX) - 1; |
355 | if (len < 0 || len >= PATH_MAX) | ||
354 | f.filename = (int)(long)"unmapped filename"; | 356 | f.filename = (int)(long)"unmapped filename"; |
357 | else if (len > 50) { | ||
358 | f.filename += len - 50; | ||
359 | prefix = "..."; | ||
360 | } | ||
355 | printk("----------- [cut here ] --------- [please bite here ] ---------\n"); | 361 | printk("----------- [cut here ] --------- [please bite here ] ---------\n"); |
356 | printk(KERN_ALERT "Kernel BUG at %.50s:%d\n", (char *)(long)f.filename, f.line); | 362 | printk(KERN_ALERT "Kernel BUG at %s%.50s:%d\n", prefix, (char *)(long)f.filename, f.line); |
357 | } | 363 | } |
358 | 364 | ||
359 | #ifdef CONFIG_BUG | 365 | #ifdef CONFIG_BUG |