mirror of
https://github.com/genodelabs/genode.git
synced 2024-12-23 23:42:32 +00:00
dde_linux: fully enable printk format specifiers
The new Lx_kit::Console::print_string() method skips leading log-level markers in strings if detected. Issue #4542
This commit is contained in:
parent
7d2f019681
commit
ea8df22dbb
@ -1,6 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* \brief Lx_emul support to log messages from the kernel code
|
* \brief Lx_emul support to log messages from the kernel code
|
||||||
* \author Stefan Kalkowski
|
* \author Stefan Kalkowski
|
||||||
|
* \author Christian Helmuth
|
||||||
* \date 2021-03-24
|
* \date 2021-03-24
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -19,6 +20,7 @@ extern "C" {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
void lx_emul_vprintf(char const *, va_list);
|
void lx_emul_vprintf(char const *, va_list);
|
||||||
|
void lx_emul_print_string(char const *);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
* \brief Lx_kit format string backend
|
* \brief Lx_kit format string backend
|
||||||
* \author Stefan Kalkowski
|
* \author Stefan Kalkowski
|
||||||
* \author Sebastian Sumpf
|
* \author Sebastian Sumpf
|
||||||
|
* \author Christian Helmuth
|
||||||
* \date 2021-03-17
|
* \date 2021-03-17
|
||||||
*
|
*
|
||||||
* Greatly inspired by the former DDE Linux Lx_kit implementation.
|
* Greatly inspired by the former DDE Linux Lx_kit implementation.
|
||||||
@ -127,6 +128,7 @@ class Lx_kit::Console
|
|||||||
public:
|
public:
|
||||||
|
|
||||||
void vprintf(const char *format, va_list list);
|
void vprintf(const char *format, va_list list);
|
||||||
|
void print_string(const char *str);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* _LX_KIT__CONSOLE_H_ */
|
#endif /* _LX_KIT__CONSOLE_H_ */
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* \brief Linux Kernel log messages
|
* \brief Linux Kernel log messages
|
||||||
* \author Stefan Kalkowski
|
* \author Stefan Kalkowski
|
||||||
|
* \author Christian Helmuth
|
||||||
* \date 2021-03-22
|
* \date 2021-03-22
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -16,3 +17,6 @@
|
|||||||
|
|
||||||
extern "C" void lx_emul_vprintf(char const *fmt, va_list va) {
|
extern "C" void lx_emul_vprintf(char const *fmt, va_list va) {
|
||||||
Lx_kit::env().console.vprintf(fmt, va); }
|
Lx_kit::env().console.vprintf(fmt, va); }
|
||||||
|
|
||||||
|
extern "C" void lx_emul_print_string(char const *str) {
|
||||||
|
Lx_kit::env().console.print_string(str); }
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* \brief Replaces kernel/printk/printk.c
|
* \brief Replaces kernel/printk/printk.c
|
||||||
* \author Stefan Kalkowski
|
* \author Stefan Kalkowski
|
||||||
|
* \author Christian Helmuth
|
||||||
* \date 2021-03-16
|
* \date 2021-03-16
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -12,22 +13,29 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <linux/printk.h>
|
#include <linux/printk.h>
|
||||||
|
#include <linux/kernel.h>
|
||||||
#include <lx_emul/log.h>
|
#include <lx_emul/log.h>
|
||||||
#include <lx_emul/debug.h>
|
#include <lx_emul/debug.h>
|
||||||
|
|
||||||
|
|
||||||
|
static char print_string[2048];
|
||||||
|
|
||||||
asmlinkage __visible int printk(const char * fmt,...)
|
asmlinkage __visible int printk(const char * fmt,...)
|
||||||
{
|
{
|
||||||
va_list args;
|
va_list args;
|
||||||
va_start(args, fmt);
|
va_start(args, fmt);
|
||||||
lx_emul_vprintf(fmt, args);
|
vsnprintf(print_string, sizeof(print_string), fmt, args);
|
||||||
va_end(args);
|
va_end(args);
|
||||||
|
|
||||||
|
lx_emul_print_string(print_string);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
asmlinkage int vprintk(const char * fmt, va_list args)
|
asmlinkage int vprintk(const char * fmt, va_list args)
|
||||||
{
|
{
|
||||||
lx_emul_vprintf(fmt, args);
|
vsnprintf(print_string, sizeof(print_string), fmt, args);
|
||||||
|
lx_emul_print_string(print_string);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -36,7 +44,8 @@ asmlinkage int vprintk_emit(int facility, int level,
|
|||||||
const struct dev_printk_info *dev_info,
|
const struct dev_printk_info *dev_info,
|
||||||
const char * fmt, va_list args)
|
const char * fmt, va_list args)
|
||||||
{
|
{
|
||||||
lx_emul_vprintf(fmt, args);
|
vsnprintf(print_string, sizeof(print_string), fmt, args);
|
||||||
|
lx_emul_print_string(print_string);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
* \brief Lx_kit format string backend
|
* \brief Lx_kit format string backend
|
||||||
* \author Stefan Kalkowski
|
* \author Stefan Kalkowski
|
||||||
* \author Sebastian Sumpf
|
* \author Sebastian Sumpf
|
||||||
|
* \author Christian Helmuth
|
||||||
* \date 2021-03-17
|
* \date 2021-03-17
|
||||||
*
|
*
|
||||||
* Greatly inspired by the former DDE Linux Lx_kit implementation.
|
* Greatly inspired by the former DDE Linux Lx_kit implementation.
|
||||||
@ -208,6 +209,21 @@ void Lx_kit::Console::_out_string(const char *str)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Lx_kit::Console::print_string(const char *str)
|
||||||
|
{
|
||||||
|
if (!str) {
|
||||||
|
_out_string("<null string>");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* strip potential control characters for log level */
|
||||||
|
if (*str == 1)
|
||||||
|
str += 2;
|
||||||
|
|
||||||
|
_out_string(str);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void Lx_kit::Console::vprintf(const char *format, va_list list)
|
void Lx_kit::Console::vprintf(const char *format, va_list list)
|
||||||
{
|
{
|
||||||
while (*format) {
|
while (*format) {
|
||||||
|
Loading…
Reference in New Issue
Block a user