]> git.corax.cc Git - corax/commitdiff
Make debug output in IPC code depend on CONFIG_DEBUG_IPC
authorMatthias Kruk <m@m10k.eu>
Sun, 27 Oct 2019 15:58:17 +0000 (00:58 +0900)
committerMatthias Kruk <m@m10k.eu>
Sun, 27 Oct 2019 15:58:17 +0000 (00:58 +0900)
config.h
kernel/core/cxipc.c

index c79fe91c60517c21e87f7c3fb037c105cecb5b74..694a1ee427b20b049e647051376d0e0e2901681a 100644 (file)
--- 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
index a93ba26bab1278d4a071eb01746219813ff866f3..fc082c349c1baabccb8aba4b1121ef71010a16e4 100644 (file)
@@ -4,6 +4,7 @@
 #include <corax/syscall.h>
 #include <corax/ipc.h>
 #include <corax/heap.h>
+#include <debug.h>
 #include <process.h>
 
 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 */