Skip to content

Commit

Permalink
better format register values
Browse files Browse the repository at this point in the history
  • Loading branch information
JensDll committed Aug 2, 2023
1 parent b39b04b commit b4263e8
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 12 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -158,3 +158,4 @@ cython_debug/
# Other stuff
.gdb_history
dev.gdb
gdbdash.json
4 changes: 2 additions & 2 deletions unix/.config/gdbdash/gdbdash/commands/dump.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def __init__(

def invoke(self, arg, from_tty):
argv = gdb.string_to_argv(arg)
path = argv[0] if len(argv) > 0 else "gdbdash.config.json"
path = argv[0] if len(argv) > 0 else "gdbdash.json"
self.dumpable.dump(path)


Expand All @@ -68,5 +68,5 @@ def __init__(

def invoke(self, arg, from_tty):
argv = gdb.string_to_argv(arg)
path = argv[0] if len(argv) > 0 else "gdbdash.config.json"
path = argv[0] if len(argv) > 0 else "gdbdash.json"
self.dumpable.load(path)
2 changes: 1 addition & 1 deletion unix/.config/gdbdash/gdbdash/dashboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def __init__(self):
command_prefix=True,
)

self.config_path = pathlib.Path.cwd() / "gdbdash.config.json"
self.config_path = pathlib.Path.cwd() / "gdbdash.json"
self.config_modified_time = 0

self.module_types = [
Expand Down
19 changes: 10 additions & 9 deletions unix/.config/gdbdash/gdbdash/modules/registers.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def __init__(self, /, **kwargs):

def render(self, width, height, write):
frame = gdb.selected_frame()
self.write_general_purpose_registers(width // 22, frame, write)
self.write_general_purpose_registers(width // 24, frame, write)
self.write_eflags(width, frame, write)
self.write_segment_registers(width // 16, frame, write)

Expand All @@ -54,16 +54,17 @@ def write_general_purpose_registers(
return

register = self.general_purpose[i]
value = int(frame.read_register(register))
register_value = frame.read_register(register)
formatted = register_value.format_string(format="z")

if value == getattr(self, register.name, value):
if register_value == getattr(self, register.name, register_value):
color = self.o["text-secondary"].value
else:
color = self.o["text-highlight"].value

write(f"{color}{register.name:>3}{RESET_COLOR} {value:#016x} ")
write(f"{color}{register.name:>3}{RESET_COLOR} {formatted} ")

setattr(self, register.name, value)
setattr(self, register.name, register_value)

i += 1

Expand All @@ -81,16 +82,16 @@ def write_segment_registers(
return

register = self.segment[i]
value = int(frame.read_register(register))
register_value = int(frame.read_register(register))

if value == getattr(self, register.name, value):
if register_value == getattr(self, register.name, register_value):
color = self.o["text-secondary"].value
else:
color = self.o["text-highlight"].value

write(f"{color}{register.name:>2}{RESET_COLOR} {value:#04x} ")
write(f"{color}{register.name:>2}{RESET_COLOR} {register_value:#06x} ")

setattr(self, register.name, value)
setattr(self, register.name, register_value)

i += 1

Expand Down

0 comments on commit b4263e8

Please sign in to comment.