Skip to content

Highlight watched Expressions that have changed. #195

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .gdbinit
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,8 @@ def run(command):

def ansi(string, style):
if R.ansi:
# clean up existing style before applying the new
string = re.sub('\x1b\[[0-9;:]+m', '', str(string))
return '\x1b[{}m{}\x1b[0m'.format(style, string)
else:
return string
Expand Down Expand Up @@ -2056,6 +2058,7 @@ class Expressions(Dashboard.Module):

def __init__(self):
self.table = set()
self.previous_values = {}

def label(self):
return 'Expressions'
Expand All @@ -2074,6 +2077,10 @@ class Expressions(Dashboard.Module):
radix, expression = match.groups()
run('set output-radix {}'.format(radix))
value = format_value(gdb.parse_and_eval(expression))
changed = self.previous_values.get(expression, '') != value
self.previous_values[expression] = value
if changed:
value = ansi(value, R.style_selected_1)
except gdb.error as e:
value = ansi(e, R.style_error)
finally:
Expand Down Expand Up @@ -2114,20 +2121,23 @@ class Expressions(Dashboard.Module):
def watch(self, arg):
if arg:
self.table.add(arg)
self.previous_values[arg] = ''
else:
raise Exception('Specify an expression')

def unwatch(self, arg):
if arg:
try:
self.table.remove(arg)
self.previous_values.pop(arg, None)
except:
raise Exception('Expression not watched')
else:
raise Exception('Specify an expression')

def clear(self, arg):
self.table.clear()
self.previous_values.clear()

@staticmethod
def get_default_radix():
Expand Down