-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathqemu.gdb
71 lines (59 loc) · 1.45 KB
/
qemu.gdb
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
define lk
target remote :1234
end
document lk
Attache to remote 127.0.0.1:1234
end
define qr
monitor system_reset
tb *0x0
c
end
document qr
Reset QEMU and stop @0x00000000.
end
define xp
monitor xp $arg0 $arg1
end
document xp
xp /fmt addr -- physical memory dump starting at 'addr'
end
python
import gdb
class VA_to_PA (gdb.Function):
"""get value from phy addr
param: addr, phy addr
"""
def __init__ (self):
super (VA_to_PA, self).__init__ ("va2pa")
def invoke (self, addr):
raw_phy_get = gdb.execute("monitor gva2gpa 0x%x" % (addr),True,True)
#print(raw_phy_get)
pa_info = raw_phy_get.split(":")
if len(pa_info) != 2:
print("ERROR: 0x%lx is not mapped!\n" % addr)
return -1
return int(pa_info[1],16)
VA_to_PA()
class Dump_phy_value (gdb.Function):
"""get value from phy addr
param: addr, phy addr
"""
def __init__ (self):
super (Dump_phy_value, self).__init__ ("dpa")
def invoke (self, addr):
raw_phy_get = gdb.execute("monitor xp /x 0x%x" % (addr),True,True)
#print(raw_phy_get)
value = int(raw_phy_get.split(":")[1],16)
return value
Dump_phy_value()
end
define get_phy_value
set $addr = $arg0
set $_SIMON_QEMU_PHY_ADDR = $addr
py get_phy_value()
end
document get_phy_value
get_phy_value PHY_ADDR ,value will be returned in $_SIMON_QEMU_PHY_VALUE
end
set $SIMON_QEMU_LOADED=1