-
Notifications
You must be signed in to change notification settings - Fork 5
/
.gdbinit
102 lines (86 loc) · 1.5 KB
/
.gdbinit
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
set $CS_BASE = 0x30000
set $DS_BASE = 0x30000
set $SS_BASE = 0x30000
# config
set architecture i386:x86-64
set pagination off
set prompt \033[32mgdb$ \033[0m
# layout
define cb
b *($CS_BASE+$arg0)
end
define cprintstr
x/s $DS_BASE+$arg0
end
define cprintdata
x/4w $DS_BASE+$arg0
end
define casm
x/10i ($CS_BASE+$pc)
end
define ccode
list *$pc
end
define cstack
info register esp ebp
x/24w $SS_BASE+$esp
end
define creg
# Not needed for now: cr0 cr2 cr3 cr4 cr8 gs_base
info register eax ebx ecx edx esi edi eflags cs ss ds es fs gs fs_base
end
define _clayout_title
echo \033[33m---[ $arg0 ]---------------\033[0m\n
end
define clayout
# clear screen
echo \033c
_clayout_title ASM
casm
_clayout_title Code
ccode
_clayout_title Register
creg
_clayout_title Stack
cstack
_clayout_title Command
end
define cc
# shorthand for cresetscreen
clayout
end
# mode
define view_realmode
set $CS_BASE = 0x0000
set $DS_BASE = 0x0000
set $SS_BASE = 0x0000
symbol-file build/bootloader/stage2.elf
clayout
end
define view_kernelmode
set $CS_BASE = 0x0C000
set $DS_BASE = 0x0C000
set $SS_BASE = 0x0C000
symbol-file build/kernel/core.elf
clayout
end
define view_usermode
set $CS_BASE = 0x30000
set $DS_BASE = 0x30000
set $SS_BASE = 0x30000
symbol-file
clayout
end
# override existing shorthand
define si
stepi
cc
end
define ni
nexti
cc
end
define c
continue
cc
end