Add a dump function for trace_printk()
authorBarret Rhoden <brho@cs.berkeley.edu>
Wed, 25 Jan 2017 18:59:38 +0000 (13:59 -0500)
committerBarret Rhoden <brho@cs.berkeley.edu>
Wed, 8 Feb 2017 21:36:32 +0000 (16:36 -0500)
trace_printk() fills a buffer that you can normally access from userspace
by reading #kprof/kptrace.  This will do a full printk() of the contents to
the raw console.

You can call this via kfunc from the monitor - perfect for those nasty
debugging sessions!

Signed-off-by: Barret Rhoden <brho@cs.berkeley.edu>
kern/drivers/dev/kprof.c

index f6ea896..9e48de9 100644 (file)
@@ -446,6 +446,17 @@ size_t kprof_tracedata_read(void *data, size_t size, size_t offset)
        return size;
 }
 
+void kprof_dump_data(void)
+{
+       void *buf;
+       size_t len = kprof_tracedata_size();
+
+       buf = kmalloc(len, MEM_WAIT);
+       kprof_tracedata_read(buf, len, 0);
+       printk("%s", buf);
+       kfree(buf);
+}
+
 void kprof_tracedata_write(const char *pretty_buf, size_t len)
 {
        spin_lock_irqsave(&ktrace_lock);