* [PATCH] x86: print relevant (tail) part of filename for warnings and crashes
@ 2013-10-16 15:25 Jan Beulich
2013-10-16 15:52 ` Keir Fraser
2013-10-16 15:57 ` Andrew Cooper
0 siblings, 2 replies; 3+ messages in thread
From: Jan Beulich @ 2013-10-16 15:25 UTC (permalink / raw)
To: xen-devel; +Cc: Keir Fraser
[-- Attachment #1: Type: text/plain, Size: 2514 bytes --]
In particular when the origin construct is in a header file (and
hence the file name is an absolute path instead of just the file name
portion) the information can otherwise become rather useless when the
build tree isn't sitting relatively close to the file system root.
Signed-off-by: Jan Beulich <jbeulich@suse.com>
--- a/xen/arch/x86/traps.c
+++ b/xen/arch/x86/traps.c
@@ -945,7 +945,7 @@ void do_invalid_op(struct cpu_user_regs
{
const struct bug_frame *bug;
u8 bug_insn[2];
- const char *filename, *predicate, *eip = (char *)regs->eip;
+ const char *prefix = "", *filename, *predicate, *eip = (char *)regs->eip;
unsigned long fixup;
int id, lineno;
static const struct bug_frame *const stop_frames[] = {
@@ -996,21 +996,27 @@ void do_invalid_op(struct cpu_user_regs
filename = bug_ptr(bug);
if ( !is_kernel(filename) )
goto die;
+ fixup = strlen(filename);
+ if ( fixup > 50 )
+ {
+ filename += fixup - 47;
+ prefix = "...";
+ }
lineno = bug_line(bug);
switch ( id )
{
case BUGFRAME_warn:
- printk("Xen WARN at %.50s:%d\n", filename, lineno);
+ printk("Xen WARN at %s%s:%d\n", prefix, filename, lineno);
show_execution_state(regs);
regs->eip = (unsigned long)eip;
return;
case BUGFRAME_bug:
- printk("Xen BUG at %.50s:%d\n", filename, lineno);
+ printk("Xen BUG at %s%s:%d\n", prefix, filename, lineno);
DEBUGGER_trap_fatal(TRAP_invalid_op, regs);
show_execution_state(regs);
- panic("Xen BUG at %.50s:%d\n", filename, lineno);
+ panic("Xen BUG at %s%s:%d\n", prefix, filename, lineno);
case BUGFRAME_assert:
/* ASSERT: decode the predicate string pointer. */
@@ -1018,12 +1024,12 @@ void do_invalid_op(struct cpu_user_regs
if ( !is_kernel(predicate) )
predicate = "<unknown>";
- printk("Assertion '%s' failed at %.50s:%d\n",
- predicate, filename, lineno);
+ printk("Assertion '%s' failed at %s%s:%d\n",
+ predicate, prefix, filename, lineno);
DEBUGGER_trap_fatal(TRAP_invalid_op, regs);
show_execution_state(regs);
- panic("Assertion '%s' failed at %.50s:%d\n",
- predicate, filename, lineno);
+ panic("Assertion '%s' failed at %s%s:%d\n",
+ predicate, prefix, filename, lineno);
}
die:
[-- Attachment #2: x86-trap-filename.patch --]
[-- Type: text/plain, Size: 2580 bytes --]
x86: print relevant (tail) part of filename for warnings and crashes
In particular when the origin construct is in a header file (and
hence the file name is an absolute path instead of just the file name
portion) the information can otherwise become rather useless when the
build tree isn't sitting relatively close to the file system root.
Signed-off-by: Jan Beulich <jbeulich@suse.com>
--- a/xen/arch/x86/traps.c
+++ b/xen/arch/x86/traps.c
@@ -945,7 +945,7 @@ void do_invalid_op(struct cpu_user_regs
{
const struct bug_frame *bug;
u8 bug_insn[2];
- const char *filename, *predicate, *eip = (char *)regs->eip;
+ const char *prefix = "", *filename, *predicate, *eip = (char *)regs->eip;
unsigned long fixup;
int id, lineno;
static const struct bug_frame *const stop_frames[] = {
@@ -996,21 +996,27 @@ void do_invalid_op(struct cpu_user_regs
filename = bug_ptr(bug);
if ( !is_kernel(filename) )
goto die;
+ fixup = strlen(filename);
+ if ( fixup > 50 )
+ {
+ filename += fixup - 47;
+ prefix = "...";
+ }
lineno = bug_line(bug);
switch ( id )
{
case BUGFRAME_warn:
- printk("Xen WARN at %.50s:%d\n", filename, lineno);
+ printk("Xen WARN at %s%s:%d\n", prefix, filename, lineno);
show_execution_state(regs);
regs->eip = (unsigned long)eip;
return;
case BUGFRAME_bug:
- printk("Xen BUG at %.50s:%d\n", filename, lineno);
+ printk("Xen BUG at %s%s:%d\n", prefix, filename, lineno);
DEBUGGER_trap_fatal(TRAP_invalid_op, regs);
show_execution_state(regs);
- panic("Xen BUG at %.50s:%d\n", filename, lineno);
+ panic("Xen BUG at %s%s:%d\n", prefix, filename, lineno);
case BUGFRAME_assert:
/* ASSERT: decode the predicate string pointer. */
@@ -1018,12 +1024,12 @@ void do_invalid_op(struct cpu_user_regs
if ( !is_kernel(predicate) )
predicate = "<unknown>";
- printk("Assertion '%s' failed at %.50s:%d\n",
- predicate, filename, lineno);
+ printk("Assertion '%s' failed at %s%s:%d\n",
+ predicate, prefix, filename, lineno);
DEBUGGER_trap_fatal(TRAP_invalid_op, regs);
show_execution_state(regs);
- panic("Assertion '%s' failed at %.50s:%d\n",
- predicate, filename, lineno);
+ panic("Assertion '%s' failed at %s%s:%d\n",
+ predicate, prefix, filename, lineno);
}
die:
[-- Attachment #3: Type: text/plain, Size: 126 bytes --]
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH] x86: print relevant (tail) part of filename for warnings and crashes
2013-10-16 15:25 [PATCH] x86: print relevant (tail) part of filename for warnings and crashes Jan Beulich
@ 2013-10-16 15:52 ` Keir Fraser
2013-10-16 15:57 ` Andrew Cooper
1 sibling, 0 replies; 3+ messages in thread
From: Keir Fraser @ 2013-10-16 15:52 UTC (permalink / raw)
To: Jan Beulich, xen-devel
On 16/10/2013 16:25, "Jan Beulich" <JBeulich@suse.com> wrote:
> In particular when the origin construct is in a header file (and
> hence the file name is an absolute path instead of just the file name
> portion) the information can otherwise become rather useless when the
> build tree isn't sitting relatively close to the file system root.
>
> Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Keir Fraser <keir@xen.org>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] x86: print relevant (tail) part of filename for warnings and crashes
2013-10-16 15:25 [PATCH] x86: print relevant (tail) part of filename for warnings and crashes Jan Beulich
2013-10-16 15:52 ` Keir Fraser
@ 2013-10-16 15:57 ` Andrew Cooper
1 sibling, 0 replies; 3+ messages in thread
From: Andrew Cooper @ 2013-10-16 15:57 UTC (permalink / raw)
To: Jan Beulich; +Cc: xen-devel, Keir Fraser
[-- Attachment #1.1: Type: text/plain, Size: 3391 bytes --]
On 16/10/13 16:25, Jan Beulich wrote:
> In particular when the origin construct is in a header file (and
> hence the file name is an absolute path instead of just the file name
> portion) the information can otherwise become rather useless when the
> build tree isn't sitting relatively close to the file system root.
>
> Signed-off-by: Jan Beulich <jbeulich@suse.com>
I had encountered similar frustrations in the past and had looked at a
different solution to the problem.
At the moment, __FILE__ is absolute, (and redundant many times in the
image, although I guess it should compress well).
I had investigated running a makefile rune to strip XEN_ROOT off
$(abspath $<) and provide this as a __FILENAME__ macro, but I wasn't
certain I had done it correctly.
This would cause a rather smaller data section and substantially less
printed in each of these cases. The only problem would then come if we
end up with more than 50 characters below XEN_ROOT, which is
substantially less likely
~Andrew
>
> --- a/xen/arch/x86/traps.c
> +++ b/xen/arch/x86/traps.c
> @@ -945,7 +945,7 @@ void do_invalid_op(struct cpu_user_regs
> {
> const struct bug_frame *bug;
> u8 bug_insn[2];
> - const char *filename, *predicate, *eip = (char *)regs->eip;
> + const char *prefix = "", *filename, *predicate, *eip = (char *)regs->eip;
> unsigned long fixup;
> int id, lineno;
> static const struct bug_frame *const stop_frames[] = {
> @@ -996,21 +996,27 @@ void do_invalid_op(struct cpu_user_regs
> filename = bug_ptr(bug);
> if ( !is_kernel(filename) )
> goto die;
> + fixup = strlen(filename);
> + if ( fixup > 50 )
> + {
> + filename += fixup - 47;
> + prefix = "...";
> + }
> lineno = bug_line(bug);
>
> switch ( id )
> {
> case BUGFRAME_warn:
> - printk("Xen WARN at %.50s:%d\n", filename, lineno);
> + printk("Xen WARN at %s%s:%d\n", prefix, filename, lineno);
> show_execution_state(regs);
> regs->eip = (unsigned long)eip;
> return;
>
> case BUGFRAME_bug:
> - printk("Xen BUG at %.50s:%d\n", filename, lineno);
> + printk("Xen BUG at %s%s:%d\n", prefix, filename, lineno);
> DEBUGGER_trap_fatal(TRAP_invalid_op, regs);
> show_execution_state(regs);
> - panic("Xen BUG at %.50s:%d\n", filename, lineno);
> + panic("Xen BUG at %s%s:%d\n", prefix, filename, lineno);
>
> case BUGFRAME_assert:
> /* ASSERT: decode the predicate string pointer. */
> @@ -1018,12 +1024,12 @@ void do_invalid_op(struct cpu_user_regs
> if ( !is_kernel(predicate) )
> predicate = "<unknown>";
>
> - printk("Assertion '%s' failed at %.50s:%d\n",
> - predicate, filename, lineno);
> + printk("Assertion '%s' failed at %s%s:%d\n",
> + predicate, prefix, filename, lineno);
> DEBUGGER_trap_fatal(TRAP_invalid_op, regs);
> show_execution_state(regs);
> - panic("Assertion '%s' failed at %.50s:%d\n",
> - predicate, filename, lineno);
> + panic("Assertion '%s' failed at %s%s:%d\n",
> + predicate, prefix, filename, lineno);
> }
>
> die:
>
>
>
>
>
> _______________________________________________
> Xen-devel mailing list
> Xen-devel@lists.xen.org
> http://lists.xen.org/xen-devel
[-- Attachment #1.2: Type: text/html, Size: 4218 bytes --]
[-- Attachment #2: Type: text/plain, Size: 126 bytes --]
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2013-10-16 15:57 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-10-16 15:25 [PATCH] x86: print relevant (tail) part of filename for warnings and crashes Jan Beulich
2013-10-16 15:52 ` Keir Fraser
2013-10-16 15:57 ` Andrew Cooper
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).