Skip to content

Commit

Permalink
__watches__ -> gef.ui.watches
Browse files Browse the repository at this point in the history
  • Loading branch information
hugsy committed Jan 8, 2022
1 parent 4bcf19a commit b0da3f8
Showing 1 changed file with 7 additions and 14 deletions.
21 changes: 7 additions & 14 deletions gef.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,6 @@ def update_gef(argv):
__registered_commands__ = []
__registered_functions__ = []

__watches__ = {}
__gef_convenience_vars_index__ = 0
__context_messages__ = []
__heap_allocated_list__ = []
Expand Down Expand Up @@ -8761,8 +8760,7 @@ def context_additional_information(self):
return

def context_memory(self):
global __watches__
for address, opt in sorted(__watches__.items()):
for address, opt in sorted(gef.ui.watches.items()):
sz, fmt = opt[0:2]
self.context_title("memory:{:#x}".format(address))
if fmt == "pointers":
Expand Down Expand Up @@ -8821,8 +8819,6 @@ def __init__(self):

@only_if_gdb_running
def do_invoke(self, argv):
global __watches__

if len(argv) not in (1, 2, 3):
self.usage()
return
Expand All @@ -8843,7 +8839,7 @@ def do_invoke(self, argv):
elif gef.arch.ptrsize == 8:
group = "qword"

__watches__[address] = (size, group)
gef.ui.watches[address] = (size, group)
ok("Adding memwatch to {:#x}".format(address))
return

Expand All @@ -8861,13 +8857,12 @@ def __init__(self):

@only_if_gdb_running
def do_invoke(self, argv):
global __watches__
if not argv:
self.usage()
return

address = parse_address(argv[0])
res = __watches__.pop(address, None)
res = gef.ui.watches.pop(address, None)
if not res:
warn("You weren't watching {:#x}".format(address))
else:
Expand All @@ -8883,8 +8878,7 @@ class MemoryWatchResetCommand(GenericCommand):

@only_if_gdb_running
def do_invoke(self, argv):
global __watches__
__watches__.clear()
gef.ui.watches.clear()
ok("Memory watches cleared")
return

Expand All @@ -8897,14 +8891,12 @@ class MemoryWatchListCommand(GenericCommand):

@only_if_gdb_running
def do_invoke(self, argv):
global __watches__

if not __watches__:
if not gef.ui.watches:
info("No memory watches")
return

info("Memory watches:")
for address, opt in sorted(__watches__.items()):
for address, opt in sorted(gef.ui.watches.items()):
gef_print("- {:#x} ({}, {})".format(address, opt[0], opt[1]))
return

Expand Down Expand Up @@ -11469,6 +11461,7 @@ def __init__(self):
self.context_hidden = False
self.stream_buffer = None
self.highlight_table = {}
self.watches = {}
return

class Gef:
Expand Down

0 comments on commit b0da3f8

Please sign in to comment.