add supports for dump analyzer

This commit is contained in:
NAKAMURA Gou
2015-02-17 11:23:25 +09:00
parent 63669b7f71
commit a0d909af75
6 changed files with 64 additions and 6 deletions

View File

@ -112,6 +112,7 @@ void reload_idt(void)
} }
static struct list_head handlers[256 - 32]; static struct list_head handlers[256 - 32];
extern char nmi[];
extern char page_fault[], general_protection_exception[]; extern char page_fault[], general_protection_exception[];
extern char debug_exception[], int3_exception[]; extern char debug_exception[], int3_exception[];
@ -131,6 +132,7 @@ static void init_idt(void)
set_idt_entry(i, generic_common_handlers[i]); set_idt_entry(i, generic_common_handlers[i]);
} }
set_idt_entry(2, (uintptr_t)nmi);
set_idt_entry(13, (unsigned long)general_protection_exception); set_idt_entry(13, (unsigned long)general_protection_exception);
set_idt_entry(14, (unsigned long)page_fault); set_idt_entry(14, (unsigned long)page_fault);

View File

@ -42,7 +42,10 @@ struct x86_cpu_local_variables {
uint64_t gdt[10]; uint64_t gdt[10];
/* 128 */ /* 128 */
struct tss64 tss; struct tss64 tss;
/* 232 */
unsigned long paniced;
uint64_t panic_regs[21];
/* 408 */
} __attribute__((packed)); } __attribute__((packed));
struct x86_cpu_local_variables *get_x86_cpu_local_variable(int id); struct x86_cpu_local_variables *get_x86_cpu_local_variable(int id);

View File

@ -130,6 +130,49 @@ general_protection_exception:
addq $8, %rsp addq $8, %rsp
iretq iretq
.globl nmi
nmi:
#define PANICED 232
#define PANIC_REGS 240
movq %rax,%gs:PANIC_REGS+0x00
movq %rbx,%gs:PANIC_REGS+0x08
movq %rcx,%gs:PANIC_REGS+0x10
movq %rdx,%gs:PANIC_REGS+0x18
movq %rsi,%gs:PANIC_REGS+0x20
movq %rdi,%gs:PANIC_REGS+0x28
movq %rbp,%gs:PANIC_REGS+0x30
movq 0x18(%rsp),%rax /* rsp */
movq %rax,%gs:PANIC_REGS+0x38
movq %r8, %gs:PANIC_REGS+0x40
movq %r9, %gs:PANIC_REGS+0x48
movq %r10,%gs:PANIC_REGS+0x50
movq %r11,%gs:PANIC_REGS+0x58
movq %r12,%gs:PANIC_REGS+0x60
movq %r13,%gs:PANIC_REGS+0x68
movq %r14,%gs:PANIC_REGS+0x70
movq %r15,%gs:PANIC_REGS+0x78
movq 0x00(%rsp),%rax /* rip */
movq %rax,%gs:PANIC_REGS+0x80
movq 0x10(%rsp),%rax /* rflags */
movl %eax,%gs:PANIC_REGS+0x88
movq 0x08(%rsp),%rax /* cs */
movl %eax,%gs:PANIC_REGS+0x8C
movq 0x20(%rsp),%rax /* ss */
movl %eax,%gs:PANIC_REGS+0x90
xorq %rax,%rax
movw %ds,%ax
movl %eax,%gs:PANIC_REGS+0x94
movw %es,%ax
movl %eax,%gs:PANIC_REGS+0x98
movw %fs,%ax
movl %eax,%gs:PANIC_REGS+0x9C
movw %gs,%ax
movl %eax,%gs:PANIC_REGS+0xA0
movq $1,%gs:PANICED
1:
hlt
jmp 1b
.globl x86_syscall .globl x86_syscall
x86_syscall: x86_syscall:
cld cld

View File

@ -40,6 +40,20 @@ extern void save_fp_regs(struct process *proc);
#define dkprintf(...) do { if (0) kprintf(__VA_ARGS__); } while (0) #define dkprintf(...) do { if (0) kprintf(__VA_ARGS__); } while (0)
#endif #endif
uintptr_t debug_constants[] = {
sizeof(struct cpu_local_var),
offsetof(struct cpu_local_var, current),
offsetof(struct cpu_local_var, runq),
offsetof(struct cpu_local_var, status),
offsetof(struct process, ctx),
offsetof(struct process, sched_list),
offsetof(struct process, ftn),
offsetof(struct fork_tree_node, status),
offsetof(struct fork_tree_node, pid),
offsetof(struct fork_tree_node, tid),
-1,
};
/* /*
See dkprintf("BSP HW ID = %d, ", bsp_hw_id); (in ./mcos/kernel/ap.c) See dkprintf("BSP HW ID = %d, ", bsp_hw_id); (in ./mcos/kernel/ap.c)

View File

@ -6,7 +6,7 @@ OBJS += process.o copy.o waitq.o futex.o timer.o plist.o fileobj.o shmobj.o
OBJS += zeroobj.o procfs.o devobj.o OBJS += zeroobj.o procfs.o devobj.o
DEPSRCS=$(wildcard $(SRC)/*.c) DEPSRCS=$(wildcard $(SRC)/*.c)
CFLAGS += -I$(SRC)/include -mcmodel=kernel -D__KERNEL__ CFLAGS += -I$(SRC)/include -mcmodel=kernel -D__KERNEL__ -g
LDFLAGS += -e arch_start LDFLAGS += -e arch_start
IHKOBJ = ihk/ihk.o IHKOBJ = ihk/ihk.o

View File

@ -42,8 +42,4 @@ SECTIONS
. = ALIGN(4096); . = ALIGN(4096);
_end = .; _end = .;
/DISCARD/ : {
*(.eh_frame)
*(.note.gnu.build-id)
}
} }