lx_emul: function to generate trace messages

lx_emul_trace_msg() uses Genode::trace() as message function for
lightweight trace points, but also supports Linux format-string
attributes by using vsnprintf().
This commit is contained in:
Christian Helmuth 2024-03-25 09:50:59 +01:00
parent 66286d6f17
commit 38d2b8d46a
3 changed files with 13 additions and 1 deletions

View File

@ -23,6 +23,8 @@ __attribute__((noreturn)) void lx_emul_trace_and_stop(const char * func);
void lx_emul_trace(const char * func);
__attribute__((__format__(printf, 1, 2))) void lx_emul_trace_msg(char const *fmt, ...);
void lx_emul_backtrace(void);
#ifdef __cplusplus

View File

@ -29,7 +29,7 @@ extern "C" void lx_emul_trace_and_stop(const char * func)
}
extern "C" void lx_emul_trace(const char *) {}
extern "C" void lx_emul_trace(const char *s) { trace(s); }
extern "C" void lx_emul_backtrace()

View File

@ -56,3 +56,13 @@ asmlinkage int vprintk_emit(int facility, int level,
return 0;
}
void lx_emul_trace_msg(char const *fmt, ...)
{
va_list args;
va_start(args, fmt);
vsnprintf(print_string, sizeof(print_string), fmt, args);
va_end(args);
lx_emul_trace(print_string);
}