// controlling the kernel and exploring the system interactively.
#include <arch/arch.h>
-#include <stab.h>
#include <smp.h>
#include <arch/console.h>
#include <trap.h>
#include <time.h>
#include <percpu.h>
+#include <kprof.h>
#include <ros/memlayout.h>
#include <ros/event.h>
{ "hd", "Hexdump PID's memory (0 for kernel)", mon_hexdump},
{ "pahexdump", "Hexdump physical memory", mon_pahexdump},
{ "phd", "Hexdump physical memory", mon_pahexdump},
+ { "dmesg", "Dump the dmesg buffer", mon_dmesg},
};
#define NCOMMANDS (sizeof(commands)/sizeof(commands[0]))
}
pc = strtol(argv[1], 0, 16);
fp = strtol(argv[2], 0, 16);
+ print_lock();
printk("Backtrace from instruction %p, with frame pointer %p\n", pc, fp);
backtrace_frame(pc, fp);
+ print_unlock();
return 0;
}
return __showmapping(argc, argv, hw_tf);
}
-static spinlock_t print_info_lock = SPINLOCK_INITIALIZER_IRQSAVE;
-
static void print_info_handler(struct hw_trapframe *hw_tf, void *data)
{
uint64_t tsc = read_tsc();
- spin_lock_irqsave(&print_info_lock);
+ print_lock();
cprintf("----------------------------\n");
cprintf("This is Core %d\n", core_id());
cprintf("Timestamp = %lld\n", tsc);
read_msr(0x20e), read_msr(0x20f));
#endif // CONFIG_X86
cprintf("----------------------------\n");
- spin_unlock_irqsave(&print_info_lock);
+ print_unlock();
}
static bool print_all_info(void)
/* Borrowed with love from http://www.geocities.com/SoHo/7373/zoo.htm
* (http://www.ascii-art.com/). Slightly modified to make it 25 lines tall.
*/
+ print_lock();
printk("\n");
printk(" .-. .-.\n");
printk(" | \\/ |\n");
printk(" \\' .\\#\n");
printk(" jgs \\ ::\\#\n");
printk(" \\ \n");
+ print_unlock();
return 0;
}
static void emit_hwtf_backtrace(struct hw_trapframe *hw_tf)
{
- char *fn_name;
-
if (mon_verbose_trace) {
+ printk("\n");
print_trapframe(hw_tf);
backtrace_hwtf(hw_tf);
}
- fn_name = get_fn_name(get_hwtf_pc(hw_tf));
printk("Core %d is at %p (%s)\n", core_id(), get_hwtf_pc(hw_tf),
- fn_name);
- kfree(fn_name);
+ get_fn_name(get_hwtf_pc(hw_tf)));
}
static void emit_vmtf_backtrace(struct vm_trapframe *vm_tf)
{
- if (mon_verbose_trace)
+ if (mon_verbose_trace) {
+ printk("\n");
print_vmtrapframe(vm_tf);
+ }
printk("Core %d is at %p\n", core_id(), get_vmtf_pc(vm_tf));
}
* doesn't deal in contexts (yet) */
void emit_monitor_backtrace(int type, void *tf)
{
- struct per_cpu_info *pcpui = &per_cpu_info[core_id()];
-
if (!PERCPU_VAR(mon_nmi_trace))
return;
/* To prevent a spew of output during a lot of perf NMIs, we'll turn off the
* monitor output as soon as any NMI hits our core. */
PERCPU_VAR(mon_nmi_trace) = FALSE;
- /* Temporarily disable deadlock detection when we print. We could
- * deadlock if we were printing when we NMIed. */
- pcpui->__lock_checking_enabled--;
+ print_lock();
if (type == ROS_HW_CTX)
emit_hwtf_backtrace((struct hw_trapframe*)tf);
else
emit_vmtf_backtrace((struct vm_trapframe*)tf);
print_kmsgs(core_id());
- pcpui->__lock_checking_enabled++;
+ print_unlock();
}
if (argc < 2) {
printk("Usage: db OPTION\n");
- printk("\tsem [PID]: print all semaphore info\n");
+ printk("\tblk [PID]: print all blocked kthreads\n");
printk("\taddr PID 0xADDR: for PID lookup ADDR's file/vmr info\n");
return 1;
}
- if (!strcmp(argv[1], "sem")) {
+ if (!strcmp(argv[1], "blk") || !strcmp(argv[1], "sem")) {
if (argc > 2)
pid = strtol(argv[2], 0, 0);
- print_all_sem_info(pid);
+ print_db_blk_info(pid);
} else if (!strcmp(argv[1], "addr")) {
if (argc < 4) {
printk("Usage: db addr PID 0xADDR\n");
pahexdump(start, len);
return 0;
}
+
+int mon_dmesg(int argc, char **argv, struct hw_trapframe *hw_tf)
+{
+ kprof_dump_data();
+ return 0;
+}