Skip to content

Commit

Permalink
lx_emul: function to generate trace messages
Browse files Browse the repository at this point in the history
lx_emul_trace_msg() uses Genode::trace() as message function for
lightweight trace points, but also supports Linux format-string
attributes by using vsnprintf().
  • Loading branch information
chelmuth committed Mar 25, 2024
1 parent cc88552 commit ac5ed43
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
2 changes: 2 additions & 0 deletions repos/dde_linux/src/include/lx_emul/debug.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion repos/dde_linux/src/lib/lx_emul/debug.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
10 changes: 10 additions & 0 deletions repos/dde_linux/src/lib/lx_emul/shadow/kernel/printk/printk.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

0 comments on commit ac5ed43

Please sign in to comment.