gdb helpers
This commit is contained in:
parent
aca48a1ed0
commit
0f28d5ae84
@ -8,15 +8,50 @@ monitor quit
|
|||||||
quit
|
quit
|
||||||
end
|
end
|
||||||
|
|
||||||
define reg
|
|
||||||
monitor info registers
|
|
||||||
end
|
|
||||||
|
|
||||||
define reset
|
define reset
|
||||||
monitor system_reset
|
monitor system_reset
|
||||||
end
|
end
|
||||||
|
|
||||||
|
define mmap
|
||||||
|
monitor info mem
|
||||||
|
end
|
||||||
|
|
||||||
python
|
python
|
||||||
import os
|
import os
|
||||||
gdb.execute('file ' + os.environ['BUILDROOT'] + '/sysroot/kernel')
|
gdb.execute('file ' + os.environ['BUILDROOT'] + '/sysroot/kernel')
|
||||||
end
|
end
|
||||||
|
|
||||||
|
python
|
||||||
|
|
||||||
|
import re
|
||||||
|
|
||||||
|
class Reg(gdb.Command):
|
||||||
|
|
||||||
|
def __init__(self):
|
||||||
|
super(Reg, self).__init__("reg", gdb.COMMAND_USER)
|
||||||
|
|
||||||
|
def invoke(self, arg, from_tty):
|
||||||
|
regs = gdb.execute('monitor info registers', False, True)
|
||||||
|
|
||||||
|
if not arg:
|
||||||
|
print(regs)
|
||||||
|
return
|
||||||
|
|
||||||
|
if arg.upper() in ['CS', 'DS', 'ES', 'FS', 'GS', 'SS']:
|
||||||
|
for l in regs.splitlines():
|
||||||
|
if l.startswith(arg.upper()):
|
||||||
|
print(l)
|
||||||
|
elif arg.upper() in ['EFL', 'RFL']:
|
||||||
|
for l in regs.splitlines():
|
||||||
|
if arg.upper() in l:
|
||||||
|
print(' '.join(l.split()[1:]))
|
||||||
|
else:
|
||||||
|
regex = f"\\b{arg.upper()}\\s?=[a-zA-Z0-9]*\\b"
|
||||||
|
matches = re.findall(regex, regs)
|
||||||
|
if matches:
|
||||||
|
print(matches[0])
|
||||||
|
else:
|
||||||
|
print(f"Register {arg.upper()} unknown")
|
||||||
|
|
||||||
|
Reg()
|
||||||
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user