From: Matthias Kruk Date: Sun, 27 Oct 2019 15:58:17 +0000 (+0900) Subject: Make debug output in IPC code depend on CONFIG_DEBUG_IPC X-Git-Url: https://git.corax.cc/?a=commitdiff_plain;h=7d24a71bb8ea77074b6b97cbbd232eb3a0cf4c54;p=corax Make debug output in IPC code depend on CONFIG_DEBUG_IPC --- diff --git a/config.h b/config.h index c79fe91..694a1ee 100644 --- a/config.h +++ b/config.h @@ -40,6 +40,7 @@ #define CONFIG_DEBUG 0 #define CONFIG_DEBUG_SCHED 0 #define CONFIG_DEBUG_NET 1 +#define CONFIG_DEBUG_IPC 1 #define CONFIG_SOCKET_MAX 1024 #define CONFIG_NET_MBUF_SIZE 2048 diff --git a/kernel/core/cxipc.c b/kernel/core/cxipc.c index a93ba26..fc082c3 100644 --- a/kernel/core/cxipc.c +++ b/kernel/core/cxipc.c @@ -4,6 +4,7 @@ #include #include #include +#include #include int sys_cxsend(pid_t to, struct cxmsg *msg) @@ -16,6 +17,13 @@ int sys_cxsend(pid_t to, struct cxmsg *msg) sproc = process_get_current(); dproc = process_lookup(to); +#if FEATURE(DEBUG_IPC) + dbg_printf("sys_cxsend(0x%08x, %p)\n", to, msg); + dbg_printf("msg %p [pid %u] -> %p [pid %u]\n", + sproc, sproc ? process_get_id(sproc) : 0, + dproc, dproc ? process_get_id(dproc) : 0); +#endif /* FEATURE(DEBUG_IPC) */ + if(sproc && dproc) { struct cxmsg *kmsg; @@ -48,7 +56,15 @@ int sys_cxsend(pid_t to, struct cxmsg *msg) } else { /* wait for destination process to pick up the message */ +#if FEATURE(DEBUG_IPC) + dbg_printf("[%u] waiting for pid %u\n", process_get_id(sproc), to); +#endif /* FEATURE(DEBUG_IPC) */ + process_wait(to); + +#if FEATURE(DEBUG_IPC) + dbg_printf("[%u] returned from process_wait()\n", process_get_id(sproc)); +#endif /* FEATURE(DEBUG_IPC) */ } } } @@ -61,15 +77,27 @@ int sys_cxrecv(pid_t from, struct cxmsg *msg) process_t *cproc; int ret_val; +#if FEATURE(DEBUG_IPC) + dbg_printf("sys_cxrecv(0x%08x, %p)\n", from, msg); +#endif /* FEATURE(DEBUG_IPC) */ + ret_val = -EFAULT; cproc = process_get_current(); if(cproc) { struct cxmsg *kmsg; +#if FEATURE(DEBUG_IPC) + dbg_printf("[%u] waiting for message\n", process_get_id(cproc)); +#endif /* FEATURE(DEBUG_IPC) */ + /* process_inbox_get() always returns a valid message (or waits forever) */ kmsg = process_inbox_get(from); +#if FEATURE(DEBUG_IPC) + dbg_printf("[%u] got a message\n", process_get_id(cproc)); +#endif /* FEATURE(DEBUG_IPC) */ + process_memcpy_ktop(cproc, msg, kmsg, sizeof(*msg)); /* signal source that their message was picked up */