-
Notifications
You must be signed in to change notification settings - Fork 1
/
.gdbinit
67 lines (55 loc) · 1.4 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
set history save on
set history filename ~/.gdb-history
set history size 1000
set height 0
set pagination off
set print pretty on
set print elements unlimited
#set auto-load python-scripts on
# LO autoloads helpers for GDB.
set auto-load safe-path /
# print-pointer-cast: prints second arg as a pointer of first arg
define pc
print *($arg0*)$arg1
end
## helpers mostly useful for reverse-engineering
# they assume Linux AMD64 ABI, though watch out for compiler optimizations
# argn functions below accept an optional argument to cast an arg to.
# In the lack of such just prints its hex
define arg1
# print ($argc == 0)? $rdi : *($arg0*)$rdi
if ($argc == 0)
print /x $rdi
else
pc $arg0 $rdi
end
end
define arg2
# print ($argc == 0)? $rsi : *($arg0*)$rsi
if ($argc == 0)
print /x $rsi
else
pc $arg0 $rsi
end
end
define arg3
# print ($argc == 0)? $rdx : *($arg0*)$rdx
if ($argc == 0)
print /x $rdx
else
pc $arg0 $rdx
end
end
# just a python function example that casts an arg to int*
# class AsIntPtr(gdb.Function):
# def __init__(self):
# super ().__init__("_as_int_ptr")
# def invoke(self, arg):
# int_type = gdb.lookup_type('int')
# int_ptr_type = int_type.pointer()
# return arg.cast(int_ptr_type)
# AsIntPtr()
source ~/gdb.py
set environment ASAN_OPTIONS=detect_leaks=0
# fancy prompt
set extended-prompt \[\e[31m\]gdb λ \[\e[0m\]