Skip to content

Commit

Permalink
Fix name-break address parsing (#708)
Browse files Browse the repository at this point in the history
  • Loading branch information
theguy147 committed Sep 5, 2021
1 parent 169e6e6 commit c4a4f58
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
9 changes: 4 additions & 5 deletions gef.py
Original file line number Diff line number Diff line change
Expand Up @@ -4206,10 +4206,10 @@ class NamedBreakpoint(gdb.Breakpoint):
"""Breakpoint which shows a specified name, when hit."""

def __init__(self, location, name):
super().__init__(spec=location, type=gdb.BP_BREAKPOINT, internal=False, temporary=False)
address = "*{}".format(parse_address(location))
super().__init__(spec=address, type=gdb.BP_BREAKPOINT, internal=False, temporary=False)
self.name = name
self.loc = location

return

def stop(self):
Expand Down Expand Up @@ -7755,15 +7755,14 @@ def __init__(self, *args, **kwargs):
return

@parse_arguments({"name": "", "address": "$pc"}, {})
def do_invoke(self, argv, *args, **kwargs):
def do_invoke(self, *args, **kwargs):
args = kwargs["arguments"]
if not args.name:
err("Missing name for breakpoint")
self.usage()
return

location = parse_address(args.address)
NamedBreakpoint(location, args.name)
NamedBreakpoint(args.address, args.name)
return


Expand Down
5 changes: 5 additions & 0 deletions tests/runtests.py
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,11 @@ def test_cmd_memory_reset(self):
res = gdb_start_silent_cmd("memory reset")
self.assertNoException(res)

def test_cmd_name_break(self):
res = gdb_run_cmd("nb foobar *main+10")
self.assertNoException(res)
return

def test_cmd_keystone_assemble(self):
valid_cmds = [
"assemble nop; xor eax, eax; syscall",
Expand Down

0 comments on commit c4a4f58

Please sign in to comment.