Skip to content

Commit

Permalink
fix alignment wrong residue class issue
Browse files Browse the repository at this point in the history
  • Loading branch information
JensDll committed Aug 11, 2023
1 parent 36ca977 commit c1e3221
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 19 deletions.
11 changes: 4 additions & 7 deletions unix/.config/gdbdash/gdbdash/modules/alignment.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,13 @@ def render(self, width, height, write):
architecture = frame.architecture()
pc = fetch_pc(frame)

instruction_length = fetch_instructions(architecture, pc)[0]["length"]

residue_class = pc & (per_row - 1)
middle = pc - residue_class
residue_class = pc % per_row

instruction_start = per_row + (pc & (per_row - 1))
instruction_length = fetch_instructions(architecture, pc)[0]["length"]
instruction_start = per_row + residue_class
instruction_end = instruction_start + instruction_length

# read one row of memory before and after the pc
memory = inferior.read_memory(middle - per_row, per_row * 3)
memory = inferior.read_memory(pc - residue_class - per_row, per_row * 3)

color = RESET_COLOR

Expand Down
23 changes: 11 additions & 12 deletions unix/.config/gdbdash/gdbdash/modules/registers.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def write_general_purpose(
while stop > 0:
for col in range(0, stop):
register = self.general_purpose[row * per_row + col]
write(register.get_value_64(frame))
write(register.get_value(frame))

write("\n")

Expand Down Expand Up @@ -199,23 +199,24 @@ def __init__(
):
super().__init__(descriptor, int_type, options)

self.name32 = self.MAP32[descriptor.name]
self.name32 = self.MAP32[self.name]
self.name16 = self.MAP16[self.name32]
self.name8h = self.MAP8H.get(self.name16)
self.name8l = self.MAP8L[self.name16]

self.value64 = None # type: int | None

def get_value_64(self, frame): # type: (gdb.Frame) -> str
def get_value(self, frame): # type: (gdb.Frame) -> str
self.value = frame.read_register(self.descriptor)
int_value = self.value.cast(self.int_type)
value = self.value.cast(self.int_type)

value64 = int(int_value)
value64 = int(value)

if self.value64 is not None and self.value64 != value64:
if getattr(self, "value64", value64) != value64:
self.color = self.options["text-highlight"]
else:
self.color = self.options["text-secondary"]

self.value64 = value64
self.value32 = int(int_value & 0xFFFF_FFFF)
self.value32 = int(value & 0xFFFF_FFFF)

return f"{self.color}{self.name:<4}{RESET_COLOR} {value64:#018x} "

Expand All @@ -237,12 +238,10 @@ def __init__(
):
super().__init__(descriptor, int_type, options)

self.value = None # type: int | None

def get_value(self, frame): # type: (gdb.Frame) -> str
value = int(frame.read_register(self.descriptor))

if self.value is not None and self.value != value:
if getattr(self, "value", value) != value:
color = self.options["text-highlight"]
else:
color = self.options["text-secondary"]
Expand Down

0 comments on commit c1e3221

Please sign in to comment.