mirror of
https://github.com/justinian/jsix.git
synced 2025-12-10 00:14:32 -08:00
[kernel] Add fake preludes to isr handler to trick GDB
By adding more debug information to the symbols and adding function frame preludes to the isr handler assembly functions, GDB sees them as valid locations for stack frames, and can display backtraces through interrupts.
This commit is contained in:
@@ -1,8 +1,14 @@
|
|||||||
%include "push_all.inc"
|
%include "push_all.inc"
|
||||||
|
|
||||||
|
section .text
|
||||||
|
|
||||||
extern isr_handler
|
extern isr_handler
|
||||||
global isr_handler_prelude
|
global isr_handler_prelude:function (isr_handler_prelude.end - isr_handler_prelude)
|
||||||
isr_handler_prelude:
|
isr_handler_prelude:
|
||||||
|
push rbp ; Never executed, fake function prelude
|
||||||
|
mov rbp, rsp ; to calm down gdb
|
||||||
|
|
||||||
|
.real:
|
||||||
push_all
|
push_all
|
||||||
check_swap_gs
|
check_swap_gs
|
||||||
|
|
||||||
@@ -10,10 +16,15 @@ isr_handler_prelude:
|
|||||||
mov rsi, rsp
|
mov rsi, rsp
|
||||||
call isr_handler
|
call isr_handler
|
||||||
jmp isr_handler_return
|
jmp isr_handler_return
|
||||||
|
.end:
|
||||||
|
|
||||||
extern irq_handler
|
extern irq_handler
|
||||||
global irq_handler_prelude
|
global irq_handler_prelude:function (irq_handler_prelude.end - irq_handler_prelude)
|
||||||
irq_handler_prelude:
|
irq_handler_prelude:
|
||||||
|
push rbp ; Never executed, fake function prelude
|
||||||
|
mov rbp, rsp ; to calm down gdb
|
||||||
|
|
||||||
|
.real:
|
||||||
push_all
|
push_all
|
||||||
check_swap_gs
|
check_swap_gs
|
||||||
|
|
||||||
@@ -21,36 +32,41 @@ irq_handler_prelude:
|
|||||||
mov rsi, rsp
|
mov rsi, rsp
|
||||||
call irq_handler
|
call irq_handler
|
||||||
; fall through to isr_handler_return
|
; fall through to isr_handler_return
|
||||||
|
.end:
|
||||||
|
|
||||||
global isr_handler_return
|
global isr_handler_return:function (isr_handler_return.end - isr_handler_return)
|
||||||
isr_handler_return:
|
isr_handler_return:
|
||||||
check_swap_gs
|
check_swap_gs
|
||||||
pop_all
|
pop_all
|
||||||
|
|
||||||
add rsp, 16 ; because the ISRs added err/num
|
add rsp, 16 ; because the ISRs added err/num
|
||||||
iretq
|
iretq
|
||||||
|
.end:
|
||||||
|
|
||||||
%macro EMIT_ISR 2
|
%macro EMIT_ISR 2
|
||||||
global %1
|
global %1:function (%1.end - %1)
|
||||||
%1:
|
%1:
|
||||||
push 0
|
push 0
|
||||||
push %2
|
push %2
|
||||||
jmp isr_handler_prelude
|
jmp isr_handler_prelude.real
|
||||||
|
.end:
|
||||||
%endmacro
|
%endmacro
|
||||||
|
|
||||||
%macro EMIT_EISR 2
|
%macro EMIT_EISR 2
|
||||||
global %1
|
global %1:function (%1.end - %1)
|
||||||
%1:
|
%1:
|
||||||
push %2
|
push %2
|
||||||
jmp isr_handler_prelude
|
jmp isr_handler_prelude.real
|
||||||
|
.end:
|
||||||
%endmacro
|
%endmacro
|
||||||
|
|
||||||
%macro EMIT_IRQ 2
|
%macro EMIT_IRQ 2
|
||||||
global %1
|
global %1:function (%1.end - %1)
|
||||||
%1:
|
%1:
|
||||||
push 0
|
push 0
|
||||||
push %2
|
push %2
|
||||||
jmp irq_handler_prelude
|
jmp irq_handler_prelude.real
|
||||||
|
.end:
|
||||||
%endmacro
|
%endmacro
|
||||||
|
|
||||||
%define EISR(i, s, name) EMIT_EISR name, i ; ISR with error code
|
%define EISR(i, s, name) EMIT_EISR name, i ; ISR with error code
|
||||||
|
|||||||
Reference in New Issue
Block a user