Rename RCU CB context to 'cannot block' context
[akaros.git] / kern / src / kdebug.c
index 9841484..d320144 100644 (file)
@@ -196,18 +196,27 @@ void debug_addr_pid(int pid, unsigned long addr)
        proc_decref(p);
 }
 
+#define BT_FMT "#%02d [<%p>] in %s\n"
+
 void print_backtrace_list(uintptr_t *pcs, size_t nr_pcs,
                                                  void (*pfunc)(void *, const char *), void *opaque)
 {
        char bt_line[128];
 
        for (size_t i = 0; i < nr_pcs; i++) {
-               snprintf(bt_line, sizeof(bt_line), "#%02d [<%p>] in %s\n", i + 1,
-                                pcs[i], get_fn_name(pcs[i]));
+               snprintf(bt_line, sizeof(bt_line), BT_FMT, i + 1, pcs[i],
+                        get_fn_name(pcs[i]));
                pfunc(opaque, bt_line);
        }
 }
 
+void sza_print_backtrace_list(struct sized_alloc *sza, uintptr_t *pcs,
+                              size_t nr_pcs)
+{
+       for (size_t i = 0; i < nr_pcs; i++)
+               sza_printf(sza, BT_FMT, i + 1, pcs[i], get_fn_name(pcs[i]));
+}
+
 static void printk_func(void *opaque, const char *str)
 {
        printk("%s", str);
@@ -221,6 +230,34 @@ void backtrace(void)
        print_unlock();
 }
 
+static void trace_printk_func(void *opaque, const char *str)
+{
+       trace_printk("%s", str);
+}
+
+void backtrace_trace(void)
+{
+       /* Don't need this strictly, but it helps serialize to the trace buf */
+       print_lock();
+       trace_printk("Stack Backtrace on Core %d:\n", core_id());
+       gen_backtrace(&trace_printk_func, NULL);
+       print_unlock();
+}
+
+static void trace_printx_func(void *opaque, const char *str)
+{
+       trace_printx("%s", str);
+}
+
+void backtrace_trace_printx(void)
+{
+       /* Don't need this strictly, but it helps serialize to the trace buf */
+       print_lock();
+       trace_printx("Stack Backtrace on Core %d:\n", core_id());
+       gen_backtrace(&trace_printk_func, NULL);
+       print_unlock();
+}
+
 void backtrace_frame(uintptr_t eip, uintptr_t ebp)
 {
        uintptr_t pcs[MAX_BT_DEPTH];
@@ -279,14 +316,8 @@ void backtrace_current_ctx(void)
                backtrace_user_ctx(current, current_ctx);
 }
 
-static spinlock_t __px_lock = SPINLOCK_INITIALIZER_IRQSAVE;
-void px_lock(void)
-{
-       if (printx_on)
-               spin_lock_irqsave(&__px_lock);
-}
-void px_unlock(void)
+void backtrace_kthread(struct kthread *kth)
 {
-       if (printx_on)
-               spin_unlock_irqsave(&__px_lock);
+       backtrace_frame(jmpbuf_get_pc(&kth->context),
+                       jmpbuf_get_fp(&kth->context));
 }