Skip to content

Commit

Permalink
adds experimental register highlighting (disabled for now...)
Browse files Browse the repository at this point in the history
  • Loading branch information
gaasedelen committed Aug 21, 2021
1 parent 2e8d360 commit 0ef96db
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 16 deletions.
36 changes: 34 additions & 2 deletions plugins/tenet/registers.py
Original file line number Diff line number Diff line change
Expand Up @@ -266,16 +266,48 @@ def __init__(self, arch):
self._registers_changed_callbacks = []

def reset(self):

# the current timestamp in the trace
self.idx = -1
self.delta = []

# the { reg_name: reg_value } dict of current register values
self.registers = {}

#
# the names of the registers that have changed since the previous
# chronological timestamp in the trace.
#
# for example if you singlestep forward, any registers that changed as
# a result of 'normal execution' may be highlighted (e.g. red)
#

self.delta_trace = []

#
# the names of registers that have changed since the last navigation
# event (eg, skipping between breakpoints, memory accesses).
#
# this is used to highlight registers that may not have changed as a
# result of the previous chronological trace event, but by means of
# user navigation within tenet.
#

self.delta_navigation = []

self.focused_reg_name = None
self.focused_reg_value = None

def set_registers(self, registers, delta=None):

# compute which registers changed as a result of navigation
unchanged = dict(set(self.registers.items()) & set(registers.items()))
self.delta_navigation = set([k for k in registers if k not in unchanged])

# save the register delta that changed since the previous trace timestamp
self.delta_trace = delta if delta else []
self.registers = registers
self.delta = delta if delta else []

# notify the UI / listeners of the model that an update occurred
self._notify_registers_changed()

#----------------------------------------------------------------------
Expand Down
4 changes: 2 additions & 2 deletions plugins/tenet/ui/palette.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def __init__(self):
# initialize the user theme directory
self._populate_user_theme_dir()

# load a placeholder theme (unhinted) for inital Lighthoue bring-up
# load a placeholder theme (unhinted) for inital Tenet bring-up
self._load_preferred_theme(True)
self._initialized = False

Expand Down Expand Up @@ -349,7 +349,7 @@ def _load_preferred_theme(self, fallback=False):
# themes that have been copied into the user theme directory
#

if fallback:
if fallback or is_plugin_dev():
theme_path = os.path.join(self.get_plugin_theme_dir(), theme_name)
else:
theme_path = os.path.join(self.get_user_theme_dir(), theme_name)
Expand Down
12 changes: 10 additions & 2 deletions plugins/tenet/ui/reg_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -389,8 +389,16 @@ def paintEvent(self, event):
else:
rendered_value = f'%0{reg_nibbles}X' % reg_value

if reg_name in self.model.delta:
painter.setPen(self.pctx.palette.reg_changed_fg)
# color register if its value changed as a result of T-1 (previous instr)
if reg_name in self.model.delta_trace:
painter.setPen(self.pctx.palette.reg_changed_trace_fg)

# color register if its value changed as a result of navigation
# TODO: disabled for now, because it seemed more confusing than helpful...
elif reg_name in self.model.delta_navigation and False:
painter.setPen(self.pctx.palette.reg_changed_navigation_fg)

# no special highlighting, default register value color text
else:
painter.setPen(self.pctx.palette.reg_value_fg)

Expand Down
15 changes: 9 additions & 6 deletions plugins/tenet/ui/resources/themes/horizon.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@
"light_red": [170, 57, 57],
"red": [118, 0, 0],
"dark_red": [ 85, 0, 0],


"orange": [255, 165, 0],

"true_yellow": [255, 255, 0],
"yellow": [255, 193, 7],

Expand Down Expand Up @@ -44,11 +46,12 @@
"standard_selection_fg": "white",
"standard_selection_faded_fg": "lightest_gray",

"reg_bg": "white",
"reg_name_fg": "black",
"reg_value_fg": "black",
"reg_changed_fg": "true_red",
"reg_selected_bg": "light_blue",
"reg_bg": "white",

"reg_name_fg": "black",
"reg_value_fg": "black",
"reg_changed_trace_fg": "true_red",
"reg_changed_navigation_fg": "orange",

"hex_text_fg": "black",
"hex_text_faded_fg": "light_gray",
Expand Down
12 changes: 8 additions & 4 deletions plugins/tenet/ui/resources/themes/synth.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
"red": [118, 0, 0],
"dark_red": [ 85, 0, 0],

"orange": [255, 165, 0],

"true_yellow": [255, 255, 0],
"yellow": [212, 194, 106],

Expand All @@ -41,10 +43,12 @@
"standard_selection_fg": "black",
"standard_selection_faded_fg": "lightest_gray",

"reg_bg": "darkest_gray",
"reg_name_fg": "lightest_gray",
"reg_value_fg": "lightest_gray",
"reg_changed_fg": "true_red",
"reg_bg": "darkest_gray",

"reg_name_fg": "lightest_gray",
"reg_value_fg": "lightest_gray",
"reg_changed_trace_fg": "true_red",
"reg_changed_navigation_fg": "orange",

"hex_text_fg": "lightest_gray",
"hex_text_faded_fg": "gray",
Expand Down

0 comments on commit 0ef96db

Please sign in to comment.