Minor adjustments to ASCII painter
This commit is contained in:
parent
0fc2338919
commit
4837fd238a
|
@ -42,7 +42,6 @@ class AsciiPainter:
|
|||
state.append({ 'state': reg_state, 'val': emu.getVal(reg_name) })
|
||||
# Write stack to state
|
||||
stack_base_pointer = emu.getVal('%rbp')
|
||||
print(emu.last_sp, emu.getVal('%rsp'))
|
||||
base_sp = emu.getVal('%rsp')
|
||||
assert(isinstance(emu.getVal('%rsp'), (int, long)))
|
||||
state.append({'state':'none', 'val': ''})
|
||||
|
@ -52,7 +51,6 @@ class AsciiPainter:
|
|||
state.append({'state': 'none', 'val': ''})
|
||||
for index in range(0, self.max_stack_size):
|
||||
stack_i = base_sp + index
|
||||
print(index, stack_i)
|
||||
if stack_i < emu.max_stack_size:
|
||||
state.append({ 'state': emu.regState("m"+str(stack_i)), 'val': emu.stack[stack_i] })
|
||||
if stack_base_pointer == index:
|
||||
|
@ -61,6 +59,21 @@ class AsciiPainter:
|
|||
else:
|
||||
state.append({'state':'none', 'val': ''})
|
||||
|
||||
def getWidthOfColumns(self, number_states, number_states_pr_block, number_state_vars):
|
||||
widths = [0 for i in range(0, number_states_pr_block)]
|
||||
for base_state in range(0, number_states, number_states_pr_block):
|
||||
for var_i in range(0, number_state_vars):
|
||||
for state_i in range(0, min(number_states_pr_block, number_states - base_state)):
|
||||
width = len(str(self.states[base_state+state_i][var_i]['val']))
|
||||
widths[state_i] = max(widths[state_i], width)
|
||||
return widths
|
||||
|
||||
def getWidthOfNameColumn (self, number_state_vars):
|
||||
widest = 0
|
||||
for var_i in range(0, number_state_vars):
|
||||
widest = max(widest, len(self.nameOfVar(var_i-4)))
|
||||
return widest
|
||||
|
||||
def to_string (self, emu):
|
||||
number_states = len(self.states)
|
||||
number_state_vars = len(self.states[0])
|
||||
|
@ -70,13 +83,16 @@ class AsciiPainter:
|
|||
separator = '-' * term_width
|
||||
l = []
|
||||
|
||||
name_fmt = '{}{:'+str(self.getWidthOfNameColumn(number_state_vars))+'} '
|
||||
column_fmt = map(lambda width: '{}{:>'+str(width)+'} ', self.getWidthOfColumns(number_states, number_states_pr_block, number_state_vars))
|
||||
|
||||
for base_state in range(0, number_states, number_states_pr_block):
|
||||
l.append(separator)
|
||||
for var_i in range(0, number_state_vars):
|
||||
l.append('{:10}'.format(self.nameOfVar(var_i-4)))
|
||||
l.append(name_fmt.format(NORMAL_COLOR, self.nameOfVar(var_i-4)))
|
||||
for state_i in range(0, min(number_states_pr_block, number_states - base_state)):
|
||||
var = self.states[base_state+state_i][var_i]
|
||||
l.append('{}{:>10}{} '.format(REG_STATUS_TO_COLOR[var['state']], var['val'], NORMAL_COLOR))
|
||||
l.append(column_fmt[state_i].format(REG_STATUS_TO_COLOR[var['state']], var['val'], NORMAL_COLOR))
|
||||
l.append('\n')
|
||||
l.append(separator)
|
||||
|
||||
|
|
4
Junk.py
4
Junk.py
|
@ -1,7 +1,8 @@
|
|||
|
||||
class JunkComparisonException (BaseException):
|
||||
|
||||
pass
|
||||
def __str__ (self):
|
||||
return "Attempting to perform calculations involving junk values."
|
||||
|
||||
class Junk:
|
||||
|
||||
|
@ -28,3 +29,4 @@ class Junk:
|
|||
|
||||
def __rsub__ (self, other):
|
||||
return self
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user