mirror of
https://github.com/clearlinux/kvmtool.git
synced 2026-09-04 20:51:28 +00:00
kvm: Dump state on SIGQUIT
This patch adds state dumping to SIGQUIT signal handler to make debugging infinite loops easier. If a kernel gets stuck under KVM, you can press Ctrl-4 and then use 'addr2line' to figure out the exact location where it's stuck from the reported 'rip': ^\[ 0.000000] Calibrating delay loop... Registers: rip: ffffffff816a0c83 rsp: ffffffff81c01eb8 flags: 0000000000000246 rax: 00000000ffff8ad0 rbx: ffffffff81d541a0 rcx: 00000000ffffffff rdx: 00000000ffff8ad0 rsi: 0000000000000046 rdi: 0000000000002000 rbp: ffffffff81c01f28 r8: 00000000000003fd r9: 0000000000000000 r10: 0000000000000000 r11: 000000000000000d r12: ffffffff81d56d20 r13: 0000000000000000 r14: ffffffffffffffff r15: 0000000000013690 cr0: 000000008005003b cr2: 0000000000000000 cr3: 0000000001c08000 cr4: 00000000000006b0 cr8: 0000000000000000 Segment registers: register selector base limit type p dpl db s l g avl cs 0010 0000000000000000 ffffffff 0b 1 0 0 1 1 1 0 ss 0000 0000000000000000 ffffffff 00 0 0 0 0 0 0 0 ds 0000 0000000000000000 ffffffff 00 0 0 0 0 0 0 0 es 0000 0000000000000000 ffffffff 00 0 0 0 0 0 0 0 fs 0000 0000000000000000 ffffffff 00 0 0 0 0 0 0 0 gs 0000 ffff880002000000 ffffffff 00 0 0 0 0 0 0 0 tr 0040 ffff880002011bc0 00002087 0b 1 0 0 0 0 0 0 ldt 0000 0000000000000000 ffffffff 00 0 0 0 0 0 0 0 gdt ffff880002004000 0000007f idt ffffffff81de9000 00000fff [ efer: 0000000000000d01 apic base: 0000000000000000 nmi: enabled ] Interrupt bitmap: 0000000000000000 0000000000000000 0000000000000000 0000000000000000 Code: Stack: penberg@tiger:~/vm$ addr2line -e vmlinux 0xffffffff816a0c83 /home/penberg/linux/init/calibrate.c:149 Signed-off-by: Pekka Enberg <penberg@cs.helsinki.fi>
This commit is contained in:
committed by
Will Deacon
parent
44069a9d01
commit
0290405d2b
@@ -4,6 +4,7 @@
|
||||
#include "kvm/util.h"
|
||||
|
||||
#include <inttypes.h>
|
||||
#include <signal.h>
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
@@ -16,15 +17,29 @@ static void usage(char *argv[])
|
||||
exit(1);
|
||||
}
|
||||
|
||||
static struct kvm *kvm;
|
||||
|
||||
static void handle_sigquit(int sig)
|
||||
{
|
||||
kvm__show_registers(kvm);
|
||||
kvm__show_code(kvm);
|
||||
kvm__show_page_tables(kvm);
|
||||
|
||||
kvm__delete(kvm);
|
||||
|
||||
exit(1);
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
const char *kernel_filename = NULL;
|
||||
const char *kernel_cmdline = NULL;
|
||||
bool single_step = false;
|
||||
char real_cmdline[128];
|
||||
struct kvm *kvm;
|
||||
int i;
|
||||
|
||||
signal(SIGQUIT, handle_sigquit);
|
||||
|
||||
for (i = 1; i < argc; i++) {
|
||||
if (!strncmp("--kernel=", argv[i], 9)) {
|
||||
kernel_filename = &argv[i][9];
|
||||
|
||||
Reference in New Issue
Block a user