Logging: Changed verbosity levels at which things are logged for the CPU

float_support
Anton Lydike 3 years ago
parent 8dea2036c5
commit bb770ab43c

@ -12,7 +12,7 @@ from typing import List, Type
import riscemu
from .config import RunConfig
from .MMU import MMU
from .colors import FMT_CPU, FMT_NONE
from .colors import FMT_CPU, FMT_NONE, FMT_ERROR
from .debug import launch_debug_session
from .types.exceptions import RiscemuBaseException, LaunchDebuggerException
from .syscall import SyscallInterface, get_syscall_symbols
@ -87,6 +87,7 @@ class UserModeCPU(CPU):
while not self.halted:
self.step(verbose)
if self.conf.verbosity > 0:
print(FMT_CPU + "[CPU] Program exited with code {}".format(self.exit_code) + FMT_NONE)
def setup_stack(self, stack_size=1024 * 4) -> bool:
@ -104,9 +105,16 @@ class UserModeCPU(CPU):
)
if not self.mmu.load_section(stack_sec, fixed_position=False):
print(FMT_ERROR + "[CPU] Could not insert stack section!" + FMT_NONE)
return False
self.regs.set('sp', Int32(stack_sec.base + stack_sec.size))
if self.conf.verbosity > 1:
print(FMT_CPU + "[CPU] Created stack of size {} at 0x{:x}".format(
stack_size, stack_sec.base
) + FMT_NONE)
return True
@classmethod

@ -4,7 +4,7 @@ from typing import List, Type, Callable, Set, Dict
from ..registers import Registers
from ..config import RunConfig
from ..colors import FMT_RED, FMT_NONE
from ..colors import FMT_RED, FMT_NONE, FMT_ERROR, FMT_CPU
from . import T_AbsoluteAddress, Instruction, Program, ProgramLoader
@ -84,9 +84,13 @@ class CPU(ABC):
def launch(self, program: Program, verbose: bool = False):
if program not in self.mmu.programs:
print(FMT_RED + '[CPU] Cannot launch program that\'s not loaded!' + FMT_NONE)
print(FMT_ERROR + '[CPU] Cannot launch program that\'s not loaded!' + FMT_NONE)
return
if self.conf.verbosity > 0:
print(FMT_CPU + "[CPU] Started running from {}".format(
self.mmu.translate_address(program.entrypoint)
) + FMT_NONE)
print(program)
self.pc = program.entrypoint
self.run(verbose)

Loading…
Cancel
Save