-
Notifications
You must be signed in to change notification settings - Fork 1
/
.gdbinit.tmpl
48 lines (43 loc) · 1.13 KB
/
.gdbinit.tmpl
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
set $lastcs = -1
set $amd64 = -1
define hook-stop
# There doesn't seem to be a good way to detect if we're in 16- or
# 32-bit mode, but we always run with CS == 8 in 32-bit mode.
if $amd64 == -1
if $cs == 8 || $cs == 27
if $lastcs != 8 && $lastcs != 27 && $cs==8
set architecture i386
end
x/i $pc
else
if $lastcs == -1 || $lastcs == 8 || $lastcs == 27 || $cs==0
set architecture i8086
end
# Translate the segment:offset into a physical address
printf "[%4x:%4x] ", $cs, $eip
x/i $cs*16+$eip
end
set $lastcs = $cs
end
end
#initially set architecture to x86_64
echo + target remote localhost:1234\n
target remote localhost:1234
# If this fails, it's probably because your GDB doesn't support ELF.
# Look at the tools page at
# http://pdos.csail.mit.edu/6.828/2009/tools.html
# for instructions on building GDB with ELF support.
echo + symbol-file obj/kern/kernel\n
symbol-file obj/kern/kernel
break jumpto_longmode
commands
set $amd64 = 1
tbreak *0x0
commands
set architecture i386:x86-64
set $lastcs = $cs
set $amd64 = 0
continue
end
si
end