Last active
June 8, 2017 15:04
-
-
Save yannayl/d3f98898d67b656b5090b5b930fbb6c6 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import hexdump | |
import gdb | |
class HexdumpCmd(gdb.Command): | |
"""Hexdump memory: hd [addr [size]] | |
Exaples: | |
hd 0x409130 0x20 | |
hd &main_arena | |
hd $5 | |
""" | |
def __init__(self): | |
super(HexdumpCmd, self).__init__("hd", gdb.COMMAND_DATA, gdb.COMPLETE_SYMBOL) | |
self._ptr = None | |
self._size = 256 | |
def invoke(self, argument, from_tty): | |
args = list(map(gdb.parse_and_eval, gdb.string_to_argv(argument))) | |
args = list(map(int, args)) | |
if not args: | |
args.append(self._ptr) | |
if len(args) < 2: | |
args.append(256) | |
self._ptr = args[0] | |
self._size = args[1] | |
hexdump.hexdump(gdb.selected_inferior().read_memory(self._ptr, self._size)) | |
self._ptr += self._size | |
HexdumpCmd() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment