set prompt \033[31m(gdb) \033[0m set disassembly-flavor intel target remote emul:1234 define q monitor quit quit end define reset monitor system_reset end define mmap monitor info mem end python import os gdb.execute('file ' + os.environ['BUILDROOT'] + '/sysroot/kernel') 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