[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Minios-devel] [UNIKRAFT PATCH 2/2] lib/ukdebug: Add time and thread info to debugs
1. Add timestamp - the number of seconds since boot, to the debug messages. 2. Add the name of the thread to the debug messages. If the thread's name is NULL, print the pointer to it's struct. If it has no name (the boot process for example) then the thread info is not printed. Both timestamp and thread name can be enabled/disabled. Signed-off-by: Dafna Hirschfeld <dafna3@xxxxxxxxx> --- lib/ukdebug/Config.uk | 10 ++++++++++ lib/ukdebug/print.c | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 60 insertions(+) diff --git a/lib/ukdebug/Config.uk b/lib/ukdebug/Config.uk index d2bc02b..2a1ea7e 100644 --- a/lib/ukdebug/Config.uk +++ b/lib/ukdebug/Config.uk @@ -39,6 +39,16 @@ config LIBUKDEBUG_PRINTD_CRIT bool "Show critical messages only" endchoice +config LIBUKDEBUG_PRINTD_TIME + bool "Show timestamp in debug messages" + default y + depends on LIBUKDEBUG_PRINTD + +config LIBUKDEBUG_PRINTD_THREAD + bool "Show name of thread in debug messages" + default y + depends on LIBUKDEBUG_PRINTD && LIBUKSCHED + choice prompt "Message redirection" default LIBUKDEBUG_NOREDIR diff --git a/lib/ukdebug/print.c b/lib/ukdebug/print.c index 175baaf..1bf2825 100644 --- a/lib/ukdebug/print.c +++ b/lib/ukdebug/print.c @@ -42,8 +42,13 @@ #include <stdarg.h> #include <uk/plat/console.h> +#include <uk/plat/time.h> #include <uk/print.h> +#if LIBUKSCHED +#include <uk/thread.h> +#endif #include <uk/arch/lcpu.h> +#include <uk/errptr.h> /* * Note: Console redirection is implemented in this file. All pre-compiled code @@ -75,6 +80,44 @@ static inline void _vprintk(const char *fmt, va_list ap) #define _ukplat_coutd(lbuf, len) ukplat_coutd((lbuf), (len)) #endif +#if LIBUKDEBUG_PRINTD_TIME +static void _printd_timestamp(void) +{ + char buf[BUFLEN]; + int len; + __nsec nansec = ukplat_monotonic_clock(); + __nsec sec = ukarch_time_nsec_to_sec(nansec); + __nsec rem_usec = ukarch_time_subseconds(nansec); + + rem_usec = ukarch_time_nsec_to_usec(rem_usec); + len = snprintf(buf, BUFLEN, "[%5lu.%06lu] ", sec, rem_usec); + _ukplat_coutd((char *)buf, len); +} +#endif + +#if LIBUKDEBUG_PRINTD_THREAD +static void _printd_thread(void) +{ + struct uk_thread *thread; + + thread = uk_thread_current(); + if (!PTRISERR(thread)) { + if (thread->name) { + _ukplat_coutd("<", 1); + _ukplat_coutd((char *)thread->name, + strlen(thread->name)); + _ukplat_coutd("> ", 2); + } else { + char buf[BUFLEN]; + int len; + + len = snprintf(buf, BUFLEN, "<%p> ", thread); + _ukplat_coutd((char *)buf, len); + } + } +} +#endif + static inline void _vprintd(int lvl, const char *libname, const char *srcname, unsigned int srcline, const char *fmt, va_list ap) { @@ -129,7 +172,14 @@ static inline void _vprintd(int lvl, const char *libname, const char *srcname, lptr = lbuf; while (len > 0) { if (newline) { +#if LIBUKDEBUG_PRINTD_TIME + _printd_timestamp(); +#endif _ukplat_coutd(DECONST(char *, msghdr), 6); +#if LIBUKDEBUG_PRINTD_THREAD + _printd_thread(); +#endif + if (libname) { _ukplat_coutd("[", 1); _ukplat_coutd(DECONST(char *, libname), -- 2.7.4 _______________________________________________ Minios-devel mailing list Minios-devel@xxxxxxxxxxxxxxxxxxxx https://lists.xenproject.org/mailman/listinfo/minios-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |