xen: some debug trace enhancements
v2 cover xen: some debug trace enhancements
While doing some scheduler work I used debug trace for diagnosis of problems during dom0 boot. This small series is the result of adapting debug trace to my needs.
Juergen Gross (2):
xen/debug: make debugtrace configurable via Kconfig xen/debug: make debugtrace more clever regarding repeating entries
xen/Kconfig.debug | 7 +++++++ xen/drivers/char/console.c | 44 ++++++++++++++++++++++++++++++++------------ xen/include/xen/lib.h | 3 +-- 3 files changed, 40 insertions(+), 14 deletions(-)
Signature · 7 lines
2.16.4 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
PATCH v2 1/2 xen/debug: make debugtrace configurable via Kconfig
Instead of having to edit include/xen/lib.h for making debugtrace available make it configurable via Kconfig.
Default is off, it is available only in expert mode or in debug builds.
--- xen/Kconfig.debug | 7 +++++++ xen/drivers/char/console.c | 2 +- xen/include/xen/lib.h | 3 +-- 3 files changed, 9 insertions(+), 3 deletions(-)
xen/Kconfig.debug +7 -0
@@ -98,6 +98,13 @@ config UBSAN If unsure, say N here. +config DEBUG_TRACE + bool "Debug trace support" + ---help--- + Debug trace enables to record debug trace messages which are printed + either directly to the console or are printed to console in case of + a system crash. + endif # DEBUG || EXPERT endmenu
xen/drivers/char/console.c +1 -1
@@ -1157,7 +1157,7 @@ int printk_ratelimit(void)* ************************************************************** */ -#ifdef DEBUG_TRACE_DUMP +#ifdef CONFIG_DEBUG_TRACE /* Send output direct to console, or buffer it? */ static volatile int debugtrace_send_to_console;
xen/include/xen/lib.h +1 -2
@@ -86,8 +86,7 @@ int parse_boolean(const char *name, const char *s, const char *e);*/ int cmdline_strcmp (const char *frag,const char *name); -/*#define DEBUG_TRACE_DUMP*/ -#ifdef DEBUG_TRACE_DUMP +#ifdef CONFIG_DEBUG_TRACE extern void debugtrace_dump (void );extern void debugtrace_printk (const char *fmt, ...) __attribute__ ((format (printf,1 ,2 )));
Signature · 7 lines
2.16.4 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
PATCH v2 2/2 xen/debug: make debugtrace more clever regarding repeating entries
In reply to Juergen GrossIn case debugtrace is writing to memory and the last entry is repeated don't fill up the trace buffer, but modify the count prefix to "x-y " style instead.
--- xen/drivers/char/console.c | 42 +++++++++++++++++++++++++++++++----------- 1 file changed, 31 insertions(+), 11 deletions(-)
xen/drivers/char/console.c +31 -11
@@ -1225,13 +1225,26 @@ void debugtrace_dump(void)watchdog_enable (); } +static void debugtrace_add_to_buf (char *buf) +{ +char *p; + +for ( p = buf; *p !='\0' ; p++ ) + { + debugtrace_buf[debugtrace_prd++] = *p; +/* Always leave a nul byte at the end of the buffer. */ +if ( debugtrace_prd == (debugtrace_bytes -1 ) ) + debugtrace_prd =0 ; + } +} +void debugtrace_printk (const char *fmt, ...) { -static char buf[1024 ]; -static u32 count; +static char buf[1024 ], last_buf[1024 ]; +static unsigned int count, last_count, last_prd; +char cntbuf[24 ];va_list args; -char *p;unsigned long flags;if ( debugtrace_bytes ==0 )
@@ -1243,25 +1256,32 @@ void debugtrace_printk(const char *fmt, ...)ASSERT (debugtrace_buf[debugtrace_bytes -1 ] ==0 ); -snprintf (buf,sizeof (buf),"%u " , ++count); -va_start (args, fmt); - (void )vsnprintf (buf +strlen (buf),sizeof (buf) -strlen (buf), fmt, args); +vsnprintf (buf,sizeof (buf), fmt, args);va_end (args);if ( debugtrace_send_to_console ) { +snprintf (cntbuf,sizeof (cntbuf),"%u " , ++count); +serial_puts (sercon_handle, cntbuf);serial_puts (sercon_handle, buf); }else { -for ( p = buf; *p !='\0' ; p++ ) +if (strcmp (buf, last_buf) ) + { + last_prd = debugtrace_prd; + last_count = ++count; +safe_strcpy (last_buf, buf); +snprintf (cntbuf,sizeof (cntbuf),"%u " , count); + } +else { - debugtrace_buf[debugtrace_prd++] = *p; -/* Always leave a nul byte at the end of the buffer. */ -if ( debugtrace_prd == (debugtrace_bytes -1 ) ) - debugtrace_prd =0 ; + debugtrace_prd = last_prd; +snprintf (cntbuf,sizeof (cntbuf),"%u-%u " , last_count, ++count); } +debugtrace_add_to_buf (cntbuf); +debugtrace_add_to_buf (buf); }spin_unlock_irqrestore (&debugtrace_lock, flags);
Signature · 7 lines
2.16.4 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [PATCH v2 2/2] xen/debug: make debugtrace more clever regarding repeating entries
Quoted 5 lines · Juergen Gross
In case debugtrace is writing to memory and the last entry is repeated don't fill up the trace buffer, but modify the count prefix to "x-y " style instead.
Signed-off-by Juergen Gross <[email protected]>
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel