]> xenbits.xensource.com Git - unikraft/unikraft.git/commitdiff
lib/ukdebug: Use lib/uklibid for library names
authorSimon Kuenzer <simon@unikraft.io>
Wed, 31 May 2023 15:44:18 +0000 (17:44 +0200)
committerUnikraft <monkey@unikraft.io>
Wed, 9 Aug 2023 10:27:40 +0000 (10:27 +0000)
Every invocation of any of the provided print function macros by
`lib/ukdebug` (`uk_printk()`, `uk_printd()`), caused placing a C-string
containing the library name in the sources. This commit replaces this
C-string with a library identifier which is just an unsigned integer. The
ID is only resolved into a name in the actual print format function
(`_vprint()`). The resolution is done by `uk_libname()` that is using the
ID for a table lookup (O(1)).

Signed-off-by: Simon Kuenzer <simon@unikraft.io>
Reviewed-by: Michalis Pappas <michalis@unikraft.io>
Reviewed-by: Robert Kuban <robert.kuban@opensynergy.com>
Approved-by: Razvan Deaconescu <razvand@unikraft.io>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #938

14 files changed:
lib/syscall_shim/include/uk/syscall.h
lib/syscall_shim/uk_syscall_binary.c
lib/ukdebug/Config.uk
lib/ukdebug/asmdump.c
lib/ukdebug/hexdump.c
lib/ukdebug/include/uk/asmdump.h
lib/ukdebug/include/uk/hexdump.h
lib/ukdebug/include/uk/print.h
lib/ukdebug/outf.c
lib/ukdebug/outf.h
lib/ukdebug/print.c
lib/uklibid/Config.uk
lib/uktest/include/uk/test.h
lib/uktest/test.c

index 279c31ffdfd74843dfa5575ad7c38751bdeb929c..0cedc135eeb9439362bc52de2fee6d3ca055e660 100644 (file)
@@ -208,7 +208,7 @@ typedef long uk_syscall_arg_t;
 #define UK_S_ARG_FMT_LONGX(type, arg)  "(" STRINGIFY(type) ") 0x%lx"
 
 #define __UK_SYSCALL_PRINTD(x, rtype, fname, ...)                      \
-       _uk_printd(__STR_LIBNAME__, __STR_BASENAME__, __LINE__,         \
+       _uk_printd(uk_libid_self(), __STR_BASENAME__, __LINE__,         \
                   "(" STRINGIFY(rtype) ") " STRINGIFY(fname)           \
                   "(" UK_ARG_FMT_MAPx(x, UK_S_ARG_FMT_LONGX, __VA_ARGS__) ")\n" \
                   UK_ARG_EMAPx(x, UK_S_ARG_CAST_LONG, __VA_ARGS__) )
index 0c81e1e6cee226b94e4211f29f1d61e7f64c3c5b..f257e88907a64c98fca6ec5dfac0639305e0391c 100644 (file)
@@ -86,7 +86,7 @@ void ukplat_syscall_handler(struct __regs *r)
        _uk_syscall_return_addr = r->rip;
 
 #if CONFIG_LIBSYSCALL_SHIM_DEBUG_HANDLER
-       _uk_printd(__STR_LIBNAME__, __STR_BASENAME__, __LINE__,
+       _uk_printd(uk_libid_self(), __STR_BASENAME__, __LINE__,
                        "Binary system call request \"%s\" (%lu) at ip:%p (arg0=0x%lx, arg1=0x%lx, ...)\n",
                    uk_syscall_name(r->rsyscall), r->rsyscall,
                    (void *) r->rip, r->rarg0, r->rarg1);
index 5fad9db4d73f12ce4843351346a4c8b4dbecb8b6..072927a6bd78cb88369905ff058e97219ccd0940 100644 (file)
@@ -1,6 +1,7 @@
 menuconfig LIBUKDEBUG
        bool "ukdebug: Debugging and tracing"
        depends on (HAVE_LIBC || LIBNOLIBC)
+       select LIBUKLIBID
        default y
 
 if LIBUKDEBUG
index 18bc17907926cb9e82668c041097b71a5b155a3c..105dd80e7ae2bc88f971ba8c75d7693b8a4b437a 100644 (file)
@@ -151,44 +151,44 @@ static int _asmndump(struct out_dev *o,
 #error No supported disassembler backend available.
 #endif /* CONFIG_LIBZYDIS */
 
-void _uk_asmdumpd(const char *libname, const char *srcname,
+void _uk_asmdumpd(__u16 libid, const char *srcname,
                  unsigned int srcline, const void *instr,
                  unsigned int instr_count)
 {
        struct out_dev o;
 
-       out_dev_init_debug(&o, libname, srcname, srcline);
+       out_dev_init_debug(&o, libid, srcname, srcline);
        _asmdump(&o, instr, instr_count);
 }
 
-void _uk_asmndumpd(const char *libname, const char *srcname,
+void _uk_asmndumpd(__u16 libid, const char *srcname,
                   unsigned int srcline, const void *instr,
                   size_t len)
 {
        struct out_dev o;
 
-       out_dev_init_debug(&o, libname, srcname, srcline);
+       out_dev_init_debug(&o, libid, srcname, srcline);
        _asmndump(&o, instr, len);
 }
 
 #if CONFIG_LIBUKDEBUG_PRINTK
-void _uk_asmdumpk(int lvl, const char *libname,
+void _uk_asmdumpk(int lvl, __u16 libid,
                  const char *srcname, unsigned int srcline,
                  const void *instr, unsigned int instr_count)
 {
        struct out_dev o;
 
-       out_dev_init_kern(&o, lvl, libname, srcname, srcline);
+       out_dev_init_kern(&o, lvl, libid, srcname, srcline);
        _asmdump(&o, instr, instr_count);
 }
 
-void _uk_asmndumpk(int lvl, const char *libname,
+void _uk_asmndumpk(int lvl, __u16 libid,
                   const char *srcname, unsigned int srcline,
                   const void *instr, size_t len)
 {
        struct out_dev o;
 
-       out_dev_init_kern(&o, lvl, libname, srcname, srcline);
+       out_dev_init_kern(&o, lvl, libid, srcname, srcline);
        _asmndump(&o, instr, len);
 }
 #endif /* CONFIG_LIBUKDEBUG_PRINTK */
index 696db69482eb83a26735c233eef57d38005ec938..21a588529cabb3aa858c6c93d5a2e917c3445d0a 100644 (file)
@@ -241,26 +241,26 @@ int uk_hexdumpf(FILE *fp, const void *data, size_t len, size_t addr0, int flags,
        return _hxd(&o, data, len, addr0, flags, grps_per_line, line_prefix);
 }
 
-void _uk_hexdumpd(const char *libname, const char *srcname,
+void _uk_hexdumpd(__u16 libid, const char *srcname,
                  unsigned int srcline, const void *data, size_t len,
                  size_t addr0, int flags, unsigned int grps_per_line,
                  const char *line_prefix)
 {
        struct out_dev o;
 
-       out_dev_init_debug(&o, libname, srcname, srcline);
+       out_dev_init_debug(&o, libid, srcname, srcline);
        _hxd(&o, data, len, addr0, flags, grps_per_line, line_prefix);
 }
 
 #if CONFIG_LIBUKDEBUG_PRINTK
-void _uk_hexdumpk(int lvl, const char *libname, const char *srcname,
+void _uk_hexdumpk(int lvl, __u16 libid, const char *srcname,
                  unsigned int srcline, const void *data, size_t len,
                  size_t addr0, int flags, unsigned int grps_per_line,
                  const char *line_prefix)
 {
        struct out_dev o;
 
-       out_dev_init_kern(&o, lvl, libname, srcname, srcline);
+       out_dev_init_kern(&o, lvl, libid, srcname, srcline);
        _hxd(&o, data, len, addr0, flags, grps_per_line, line_prefix);
 }
 #endif
index 4161b20644604c1daf8e76dce990b311b4339abe..323308b5b715f82f6214d405579542057c949f56 100644 (file)
@@ -45,6 +45,7 @@
  */
 
 #include <stdio.h>
+#include <uk/arch/types.h>
 #include <uk/print.h>
 
 #ifdef __cplusplus
@@ -74,20 +75,20 @@ extern "C" {
 
 #if (defined UK_DEBUG) || CONFIG_LIBUKDEBUG_PRINTD
 /* Please use uk_asmdumpd() instead */
-void _uk_asmdumpd(const char *libname, const char *srcname,
+void _uk_asmdumpd(__u16 libid, const char *srcname,
                  unsigned int srcline, const void *instr,
                  unsigned int instr_count);
 
 #define uk_asmdumpd(instr, instr_count)                                        \
-       _uk_asmdumpd(__STR_LIBNAME__, __STR_BASENAME__,                 \
+       _uk_asmdumpd(uk_libid_self(), __STR_BASENAME__,                 \
                     __LINE__, (instr), (instr_count))
 
-void _uk_asmndumpd(const char *libname, const char *srcname,
+void _uk_asmndumpd(__u16 libid, const char *srcname,
                   unsigned int srcline, const void *instr,
                   size_t len);
 
 #define uk_asmndumpd(instr, len)                                       \
-       _uk_asmndumpd(__STR_LIBNAME__, __STR_BASENAME__,                \
+       _uk_asmndumpd(uk_libid_self(), __STR_BASENAME__,                \
                      __LINE__, (instr), (len))
 #else /* (defined UK_DEBUG) || CONFIG_LIBUKDEBUG_PRINTD */
 static inline void uk_asmdumpd(const void *instr __unused,
@@ -101,25 +102,25 @@ static inline void uk_asmndumpd(const void *instr __unused,
 
 #if CONFIG_LIBUKDEBUG_PRINTK
 /* Please use uk_asmdumpk() instead */
-void _uk_asmdumpk(int lvl, const char *libname, const char *srcname,
+void _uk_asmdumpk(int lvl, __u16 libid, const char *srcname,
                 unsigned int srcline, const void *instr,
                 unsigned int instr_count);
 
 #define uk_asmdumpk(lvl, instr, instr_count)                           \
        do {                                                            \
                if ((lvl) <= KLVL_MAX)                                  \
-                       _uk_asmdumpk((lvl), __STR_LIBNAME__, __STR_BASENAME__, \
+                       _uk_asmdumpk((lvl), uk_libid_self(), __STR_BASENAME__, \
                                     __LINE__, (instr), (instr_count)); \
        } while (0)
 
-void _uk_asmndumpk(int lvl, const char *libname, const char *srcname,
+void _uk_asmndumpk(int lvl, __u16 libid, const char *srcname,
                   unsigned int srcline, const void *instr,
                   size_t len);
 
 #define uk_asmndumpk(lvl, instr, len)                                  \
        do {                                                            \
                if ((lvl) <= KLVL_MAX)                                  \
-                       _uk_asmdumpk((lvl), __STR_LIBNAME__, __STR_BASENAME__, \
+                       _uk_asmdumpk((lvl), uk_libid_self(), __STR_BASENAME__, \
                                     __LINE__, (instr), (len));         \
        } while (0)
 #else /* CONFIG_LIBUKDEBUG_PRINTK */
index 676ae8da7c15b304fb73fee8ef5eb06d2048e700..07add7923664f55cae5412b2a7e1faa81f6cc03e 100644 (file)
@@ -37,6 +37,7 @@
 #define __UKDEBUG_HEXDUMP_H__
 
 #include <stdio.h>
+#include <uk/arch/types.h>
 #include <uk/print.h>
 
 #ifdef __cplusplus
@@ -71,7 +72,7 @@ extern "C" {
 
 #if (defined UK_DEBUG) || CONFIG_LIBUKDEBUG_PRINTD
 /* Please use uk_hexdumpd() instead */
-void _uk_hexdumpd(const char *libname, const char *srcname,
+void _uk_hexdumpd(__u16 libid, const char *srcname,
                  unsigned int srcline, const void *data, size_t len,
                  size_t addr0, int flags, unsigned int grps_per_line,
                  const char *line_prefix);
@@ -89,7 +90,7 @@ void _uk_hexdumpd(const char *libname, const char *srcname,
  * @return Returns the number of printed characters to output fp
  */
 #define uk_hexdumpd(data, len, flags, grps_per_line)                   \
-       _uk_hexdumpd(__STR_LIBNAME__, __STR_BASENAME__,                 \
+       _uk_hexdumpd(uk_libid_self(), __STR_BASENAME__,                 \
                     __LINE__, (data), (len),                           \
                     ((size_t)(data)), (flags),                         \
                     (grps_per_line), STRINGIFY(data) ": ")
@@ -102,7 +103,7 @@ static inline void uk_hexdumpd(const void *data __unused, size_t len __unused,
 
 #if CONFIG_LIBUKDEBUG_PRINTK
 /* Please use uk_hexdumpk() instead */
-void _uk_hexdumpk(int lvl, const char *libname, const char *srcname,
+void _uk_hexdumpk(int lvl, __u16 libid, const char *srcname,
                  unsigned int srcline, const void *data, size_t len,
                  size_t addr0, int flags, unsigned int grps_per_line,
                  const char *line_prefix);
@@ -122,7 +123,7 @@ void _uk_hexdumpk(int lvl, const char *libname, const char *srcname,
 #define uk_hexdumpk(lvl, data, len, flags, grps_per_line)                      \
        do {                                                                   \
                if ((lvl) <= KLVL_MAX)                                         \
-                       _uk_hexdumpk((lvl), __STR_LIBNAME__, __STR_BASENAME__, \
+                       _uk_hexdumpk((lvl), uk_libid_self(), __STR_BASENAME__, \
                                     __LINE__, (data), (len),                  \
                                     ((size_t)(data)), (flags),                \
                                     (grps_per_line), STRINGIFY(data) ": ");   \
index d04b2cfd12b9ef498131dae5109ddd235d4f7bfb..72978cc355bfa9ea0f7c848042114f136ba9cdf8 100644 (file)
@@ -37,6 +37,7 @@
 #define __UKDEBUG_PRINT_H__
 
 #include <stdarg.h>
+#include <uk/libid.h>
 #include <uk/arch/lcpu.h>
 #include <uk/essentials.h>
 #include <uk/config.h>
 extern "C" {
 #endif
 
-#ifdef __LIBNAME__
-#define __STR_LIBNAME__ STRINGIFY(__LIBNAME__)
-#else
-#define __STR_LIBNAME__ (NULL)
-#endif
-
 #ifdef __BASENAME__
 #define __STR_BASENAME__ STRINGIFY(__BASENAME__)
 #else
@@ -64,9 +59,9 @@ extern "C" {
  * by other libraries with an own debug print switch
  * (e.g., hexdump, syscall_shim)
  */
-void _uk_vprintd(const char *libname, const char *srcname,
+void _uk_vprintd(__u16 libid, const char *srcname,
                 unsigned int srcline, const char *fmt, va_list ap);
-void _uk_printd(const char *libname, const char *srcname,
+void _uk_printd(__u16 libid, const char *srcname,
                unsigned int srcline, const char *fmt, ...) __printf(4, 5);
 
 #ifdef __IN_LIBUKDEBUG__
@@ -84,7 +79,7 @@ void _uk_printd(const char *libname, const char *srcname,
 #if defined UK_DEBUG || CONFIG_LIBUKDEBUG_PRINTD
 #define uk_vprintd(fmt, ap)                                            \
        do {                                                            \
-               _uk_vprintd(__STR_LIBNAME__, __STR_BASENAME__,          \
+               _uk_vprintd(uk_libid_self(), __STR_BASENAME__,          \
                            __LINE__, (fmt), ap);                       \
        } while (0)
 
@@ -92,7 +87,7 @@ void _uk_printd(const char *libname, const char *srcname,
        do {                                                            \
                static int __x;                                         \
                if (unlikely(!__x)) {                                   \
-                       _uk_vprintd(__STR_LIBNAME__, __STR_BASENAME__,  \
+                       _uk_vprintd(uk_libid_self(), __STR_BASENAME__,  \
                                    __LINE__, (fmt), ap);               \
                        __x = 1;                                        \
                }                                                       \
@@ -100,7 +95,7 @@ void _uk_printd(const char *libname, const char *srcname,
 
 #define uk_printd(fmt, ...)                                            \
        do {                                                            \
-               _uk_printd(__STR_LIBNAME__, __STR_BASENAME__,           \
+               _uk_printd(uk_libid_self(), __STR_BASENAME__,           \
                           __LINE__, (fmt), ##__VA_ARGS__);             \
        } while (0)
 
@@ -108,7 +103,7 @@ void _uk_printd(const char *libname, const char *srcname,
        do {                                                            \
                static int __x;                                         \
                if (unlikely(!__x)) {                                   \
-                       _uk_printd(__STR_LIBNAME__, __STR_BASENAME__,   \
+                       _uk_printd(uk_libid_self(), __STR_BASENAME__,   \
                                   __LINE__, (fmt), ##__VA_ARGS__);     \
                        __x = 1;                                        \
                }                                                       \
@@ -155,15 +150,15 @@ static inline void uk_printd_once(const char *fmt __unused, ...)
  * they compile in the function calls only if the configured
  * debug level requires it
  */
-void _uk_vprintk(int lvl, const char *libname, const char *srcname,
+void _uk_vprintk(int lvl, __u16 libid, const char *srcname,
                 unsigned int srcline, const char *fmt, va_list ap);
-void _uk_printk(int lvl, const char *libname, const char *srcname,
+void _uk_printk(int lvl, __u16 libid, const char *srcname,
                unsigned int srcline, const char *fmt, ...) __printf(5, 6);
 
 #define uk_vprintk(lvl, fmt, ap)                                               \
        do {                                                                   \
                if ((lvl) <= KLVL_MAX)                                         \
-                       _uk_vprintk((lvl), __STR_LIBNAME__, __STR_BASENAME__,  \
+                       _uk_vprintk((lvl), uk_libid_self(), __STR_BASENAME__,  \
                                    __LINE__, (fmt), ap);                      \
        } while (0)
 
@@ -172,7 +167,7 @@ void _uk_printk(int lvl, const char *libname, const char *srcname,
                if ((lvl) <= KLVL_MAX) {                                       \
                        static int __x;                                        \
                        if (unlikely(!__x)) {                                  \
-                               _uk_vprintk((lvl), __STR_LIBNAME__,            \
+                               _uk_vprintk((lvl), uk_libid_self(),            \
                                            __STR_BASENAME__,                  \
                                            __LINE__, (fmt), ap);              \
                                __x = 1;                                       \
@@ -183,7 +178,7 @@ void _uk_printk(int lvl, const char *libname, const char *srcname,
 #define uk_printk(lvl, fmt, ...)                                               \
        do {                                                                   \
                if ((lvl) <= KLVL_MAX)                                         \
-                       _uk_printk((lvl), __STR_LIBNAME__, __STR_BASENAME__,   \
+                       _uk_printk((lvl), uk_libid_self(), __STR_BASENAME__,   \
                                   __LINE__, (fmt), ##__VA_ARGS__);            \
        } while (0)
 
@@ -192,7 +187,7 @@ void _uk_printk(int lvl, const char *libname, const char *srcname,
                if ((lvl) <= KLVL_MAX) {                                       \
                        static int __x;                                        \
                        if (unlikely(!__x)) {                                  \
-                               _uk_printk((lvl), __STR_LIBNAME__,             \
+                               _uk_printk((lvl), uk_libid_self(),             \
                                           __STR_BASENAME__,                   \
                                           __LINE__, (fmt), ##__VA_ARGS__);    \
                                __x = 1;                                       \
index c825fc2c7db65a38659ed5be851ebaf745a49dfc..d882d81adfdc03178e4706d58398bbbdd498419e 100644 (file)
@@ -64,13 +64,13 @@ int outf(struct out_dev *dev, const char *fmt, ...)
                }
                break;
        case OUTDEV_DEBUG:
-               _uk_vprintd(dev->uk_pr.libname,
+               _uk_vprintd(dev->uk_pr.libid,
                            dev->uk_pr.srcname, dev->uk_pr.srcline,
                            fmt, ap);
                break;
 #if CONFIG_LIBUKDEBUG_PRINTK
        case OUTDEV_KERN:
-               _uk_vprintk(dev->uk_pr.lvl, dev->uk_pr.libname,
+               _uk_vprintk(dev->uk_pr.lvl, dev->uk_pr.libid,
                            dev->uk_pr.srcname, dev->uk_pr.srcline,
                            fmt, ap);
                break;
index c4cd470d7f27e151aea8dbe8a945c85a26f85b1d..32da204a6ebf612d34585f3233bd74b692f2af55 100644 (file)
@@ -39,6 +39,7 @@
 #include <uk/config.h>
 #include <inttypes.h>
 #include <stdio.h>
+#include <uk/libid.h>
 
 enum out_dev_type {
        OUTDEV_FILE = 0,
@@ -56,7 +57,7 @@ struct out_dev {
                /* OUTDEV_KERN, OUTDEV_DEBUG */
                struct {
                        int lvl; /* OUTDEV_KERN only */
-                       const char *libname;
+                       __u16 libid;
                        const char *srcname;
                        unsigned int srcline;
                } uk_pr;
@@ -93,20 +94,20 @@ int outf(struct out_dev *dev, const char *fmt, ...);
        } while (0)
 
 #if CONFIG_LIBUKDEBUG_PRINTK
-#define out_dev_init_kern(dev, lvl, libname, srcname, srcline) \
+#define out_dev_init_kern(dev, lvl, libid, srcname, srcline)   \
        do {                                                    \
                (dev)->type          = OUTDEV_KERN;             \
                (dev)->uk_pr.lvl     = (lvl);                   \
-               (dev)->uk_pr.libname = (libname);               \
+               (dev)->uk_pr.libid   = (libid);                 \
                (dev)->uk_pr.srcname = (srcname);               \
                (dev)->uk_pr.srcline = (srcline);               \
        } while (0)
 #endif
 
-#define out_dev_init_debug(dev, libname, srcname, srcline)     \
+#define out_dev_init_debug(dev, libid, srcname, srcline)       \
        do {                                                    \
                (dev)->type          = OUTDEV_DEBUG;            \
-               (dev)->uk_pr.libname = (libname);               \
+               (dev)->uk_pr.libid   = (libid);                 \
                (dev)->uk_pr.srcname = (srcname);               \
                (dev)->uk_pr.srcline = (srcline);               \
        } while (0)
index 38cb60b83b8617ab3e82f8a03de93bf7a4a3534c..482f168ef8ca746a24d080dbca20263f4e940a67 100644 (file)
@@ -168,7 +168,7 @@ static void _print_caller(struct _vprint_console *cons, __uptr ra, __uptr fa)
 #endif /* CONFIG_LIBUKDEBUG_PRINT_CALLER */
 
 static void _vprint(struct _vprint_console *cons,
-                   int lvl, const char *libname,
+                   int lvl, __u16 libid,
 #if CONFIG_LIBUKDEBUG_PRINT_SRCNAME
                    const char *srcname,
                    unsigned int srcline,
@@ -184,6 +184,7 @@ static void _vprint(struct _vprint_console *cons,
        const char *msghdr = NULL;
        const char *lptr = NULL;
        const char *nlptr = NULL;
+       const char *libname = uk_libname(libid);
 
        /*
         * Note: We reset the console colors earlier in order to exclude
@@ -311,37 +312,37 @@ static void _vprint(struct _vprint_console *cons,
 #define _VPRINT_ARGS_CALLER()
 #endif /* CONFIG_LIBUKDEBUG_PRINT_CALLER */
 
-void _uk_vprintd(const char *libname, const char *srcname __maybe_unused,
+void _uk_vprintd(__u16 libid, const char *srcname __maybe_unused,
                 unsigned int srcline __maybe_unused, const char *fmt,
                 va_list ap)
 {
 
 #if CONFIG_LIBUKDEBUG_REDIR_PRINTD
-       _vprint(&kern,  KLVL_DEBUG, libname,
+       _vprint(&kern,  KLVL_DEBUG, libid,
                _VPRINT_ARGS_SRCNAME(srcname, srcline)
                _VPRINT_ARGS_CALLER()
                fmt, ap);
 #else
-       _vprint(&debug, KLVL_DEBUG, libname,
+       _vprint(&debug, KLVL_DEBUG, libid,
                _VPRINT_ARGS_SRCNAME(srcname, srcline)
                _VPRINT_ARGS_CALLER()
                fmt, ap);
 #endif /* !CONFIG_LIBUKDEBUG_REDIR_PRINTD */
 }
 
-void _uk_printd(const char *libname, const char *srcname __maybe_unused,
+void _uk_printd(__u16 libid, const char *srcname __maybe_unused,
                unsigned int srcline __maybe_unused, const char *fmt, ...)
 {
        va_list ap;
 
        va_start(ap, fmt);
 #if CONFIG_LIBUKDEBUG_REDIR_PRINTD
-       _vprint(&kern,  KLVL_DEBUG, libname,
+       _vprint(&kern,  KLVL_DEBUG, libid,
                _VPRINT_ARGS_SRCNAME(srcname, srcline)
                _VPRINT_ARGS_CALLER()
                fmt, ap);
 #else
-       _vprint(&debug, KLVL_DEBUG, libname,
+       _vprint(&debug, KLVL_DEBUG, libid,
                _VPRINT_ARGS_SRCNAME(srcname, srcline)
                _VPRINT_ARGS_CALLER()
                fmt, ap);
@@ -356,25 +357,25 @@ void _uk_printd(const char *libname, const char *srcname __maybe_unused,
  *  enabled.
  */
 #if CONFIG_LIBUKDEBUG_PRINTK
-void _uk_vprintk(int lvl, const char *libname,
+void _uk_vprintk(int lvl, __u16 libid,
                 const char *srcname __maybe_unused,
                 unsigned int srcline __maybe_unused,
                 const char *fmt, va_list ap)
 {
 #if CONFIG_LIBUKDEBUG_REDIR_PRINTK
-       _vprint(&debug, lvl, libname,
+       _vprint(&debug, lvl, libid,
                _VPRINT_ARGS_SRCNAME(srcname, srcline)
                _VPRINT_ARGS_CALLER()
                fmt, ap);
 #else
-       _vprint(&kern,  lvl, libname,
+       _vprint(&kern,  lvl, libid,
                _VPRINT_ARGS_SRCNAME(srcname, srcline)
                _VPRINT_ARGS_CALLER()
                fmt, ap);
 #endif /* !CONFIG_LIBUKDEBUG_REDIR_PRINTK */
 }
 
-void _uk_printk(int lvl, const char *libname,
+void _uk_printk(int lvl, __u16 libid,
                const char *srcname __maybe_unused,
                unsigned int srcline __maybe_unused,
                const char *fmt, ...)
@@ -383,12 +384,12 @@ void _uk_printk(int lvl, const char *libname,
 
        va_start(ap, fmt);
 #if CONFIG_LIBUKDEBUG_REDIR_PRINTK
-       _vprint(&debug, lvl, libname,
+       _vprint(&debug, lvl, libid,
                _VPRINT_ARGS_SRCNAME(srcname, srcline)
                _VPRINT_ARGS_CALLER()
                fmt, ap);
 #else
-       _vprint(&kern,  lvl, libname,
+       _vprint(&kern,  lvl, libid,
                _VPRINT_ARGS_SRCNAME(srcname, srcline)
                _VPRINT_ARGS_CALLER()
                fmt, ap);
index 7100ef68411eb5dfafc26de4b73b4c1a7fed0406..059757d6fbfe62a990fb2ec14cdb46bcb65b4fa8 100644 (file)
@@ -1,4 +1,10 @@
 config LIBUKLIBID
        bool "uklibid: Library identifier"
        default n
-       select LIBUKDEBUG
+       # FIXME: We actually depend on <uk/assert.h> but lib/ukdebug also
+       #        depends on us. If we specify the dependency here, it creates a
+       #        circular dependency that KConfig doesn't like. However, we
+       #        can currently assume that lib/ukdebug is always part of a
+       #        build, so we comment out the dependency here. Of course, this
+       #        is not accurate.
+       #select LIBUKDEBUG
index aad957111da0651b62e1df3975231dce184f9585..5bbdfc91d4c34f4fb5eca5340b523e549ce93eb5 100644 (file)
 
 /* Custom print method. */
 #define uk_test_printf(fmt, ...)                                       \
-       _uk_printk(KLVL_INFO, __NULL, __NULL, 0x0,                      \
+       _uk_printk(KLVL_INFO, UKLIBID_NONE, __NULL, 0x0,                \
        "\t" fmt, ##__VA_ARGS__)
 
 
index e6415c067ece90310d2390d6bc2eb91dea211063..9f1e1e2bbab47f99b003ae3bdced1bb498be8f8d 100644 (file)
@@ -178,14 +178,14 @@ uk_testsuite_run(struct uk_testsuite *suite)
 #endif /* CONFIG_LIBUKTEST_LOG_STATS */
 
 #ifdef CONFIG_LIBUKTEST_LOG_TESTS
-               _uk_printk(KLVL_INFO, __NULL, __NULL, 0x0,
-                       (LVLC_TESTNAME "test:" UK_ANSI_MOD_RESET
-                       " %s->%s"), suite->name, esac->name);
+               _uk_printk(KLVL_INFO, UKLIBID_NONE, __NULL, 0x0,
+                          (LVLC_TESTNAME "test:" UK_ANSI_MOD_RESET
+                          " %s->%s"), suite->name, esac->name);
                if (esac->desc != NULL)
-                       _uk_printk(KLVL_INFO, __NULL, __NULL, 0x0, ": %s\n",
-                       esac->desc);
+                       _uk_printk(KLVL_INFO, UKLIBID_NONE, __NULL, 0x0,
+                                  ": %s\n", esac->desc);
                else
-                       _uk_printk(KLVL_INFO, __NULL, __NULL, 0x0, "\n");
+                       _uk_printk(KLVL_INFO, UKLIBID_NONE, __NULL, 0x0, "\n");
 #endif /* CONFIG_LIBUKTEST_LOG_TESTS */
 
                esac->func(esac);