Minor fixes like imports and edge-case handling

float_support
Anton Lydike 4 years ago
parent f45a37e705
commit 5d484f08cf

@ -12,6 +12,7 @@ from dataclasses import dataclass, field
from typing import Dict, List, Tuple, Union, Optional
from .Exceptions import *
from .helpers import *
from math import log
import typing
@ -215,7 +216,7 @@ class LoadedMemorySection:
print(FMT_MEM + "{}, viewing {} bytes:".format(
self, end - start
) + FMT_NONE)
for i in range(start, end, bytes_per_row):
for i in range(0, end - start, bytes_per_row):
data = self.content[start + i: min(start + i + bytes_per_row, end)]
if start + i <= highlight <= start + i + bytes_per_row:
# do hightlight here!

@ -75,6 +75,7 @@ class ExecutableParser:
:param token: the symbol token
"""
ASSERT_NOT_IN(token.name, self.symbols)
ASSERT_NOT_NULL(self.active_section)
sec_pos = self._curr_sec().size
self.symbols[token.name] = (self.active_section, sec_pos)

@ -141,6 +141,10 @@ class MMU:
:return: The Instruction
"""
sec = self.get_sec_containing(addr)
if sec is None:
print(FMT_MEM + "[MMU] Trying to read instruction form invalid region! "
"Have you forgotten an exit syscall or ret statement?" + FMT_NONE)
raise RuntimeError("No next instruction available!")
return sec.read_instruction(addr - sec.base)
def read(self, addr: int, size: int) -> bytearray:
@ -175,6 +179,7 @@ class MMU:
"""
sec = self.get_sec_containing(addr)
if sec is None:
print(FMT_MEM + "[MMU] No section containing addr 0x{:08X}".format(addr) + FMT_NONE)
return
sec.dump(addr, *args, **kwargs)

@ -13,7 +13,7 @@ from .Exceptions import RiscemuBaseException, LaunchDebuggerException, InvalidSy
from .Tokenizer import RiscVInput, RiscVTokenizer
from .Executable import Executable, LoadedExecutable
from .Executable import Executable, LoadedExecutable, LoadedMemorySection
from .ExecutableParser import ExecutableParser

@ -96,5 +96,4 @@ def format_bytes(byte_arr: bytearray, fmt: str, group: int = 1, highlight: int =
return highlight_in_list([('{:0' + spc + 'd}').format(int_from_bytes(ch, unsigned=True)) for ch in chunks],
highlight)
if fmt == 'ascii':
print("printing ascii", "".join(chr(b) for b in byte_arr))
return "".join(repr(chr(b))[1:-1] for b in byte_arr)

Loading…
Cancel
Save