diff --git a/src/README.md b/src/README.md new file mode 100644 index 0000000..27f069e --- /dev/null +++ b/src/README.md @@ -0,0 +1,3 @@ +# почему так грязно? + +Потому что я заколебался воевать с модульностью питона, чтобы сделать это красиво diff --git a/src/debugger/__init__.py b/src/__init__.py similarity index 100% rename from src/debugger/__init__.py rename to src/__init__.py diff --git a/src/dbg_main.py b/src/dbg_main.py new file mode 100644 index 0000000..0fa300c --- /dev/null +++ b/src/dbg_main.py @@ -0,0 +1,33 @@ +from dpdebugger import Debugger, DbgDict +from argparse import ArgumentParser +import json + +def parse_dbg(dbg_json_dict: dict) -> DbgDict: + instr = dbg_json_dict["instructions"] + print(instr) + + +if __name__ == "__main__": + parser = ArgumentParser( + prog="dp32dbg", + description="Bad debugger for DP32 processor" + ) + parser.add_argument( + "-m", + "--memory", + required=True, + help="Initial memory for virtual machine" + ) + parser.add_argument( + "-d", + "--debug-file", + required=True, + help="JSON with debug information. by default named dbg.json" + ) + + args = parser.parse_args() + + with open(args.memory, "rb") as f: + mem = bytearray(f.read()) + with open(args.debug_file, 'r') as f: + dbg_dict: DbgDict = parse_dbg(json.load(f)) diff --git a/src/debugger/main.py b/src/debugger/main.py deleted file mode 100644 index 1358978..0000000 --- a/src/debugger/main.py +++ /dev/null @@ -1,5 +0,0 @@ -def main(): - print("Hello world!") - -if __name__ == "__main__": - main() diff --git a/src/debugger/debugger.py b/src/dpdebugger.py similarity index 99% rename from src/debugger/debugger.py rename to src/dpdebugger.py index 188e14c..4c2a958 100644 --- a/src/debugger/debugger.py +++ b/src/dpdebugger.py @@ -2,6 +2,7 @@ Отладчик принимает на вход довольно много всего и пытается вам хоть как-то помочь """ + from emulator.vm import VM, VMException, Breakpoint, Condition, WORD_SIZE from dataclasses import dataclass @@ -59,6 +60,7 @@ class Debugger: self._vm = VM(mem) self._dbg_dict = dbg_dict self._breakpoints = set() + self.__init_callbacks__() def __init_callbacks__(self): self._callbacks_table = { diff --git a/src/emulator/__init__.py b/src/emulator/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/src/emulator/main.py b/src/main.py similarity index 100% rename from src/emulator/main.py rename to src/main.py diff --git a/src/emulator/optable.py b/src/optable.py similarity index 100% rename from src/emulator/optable.py rename to src/optable.py diff --git a/src/emulator/vm.py b/src/vm.py similarity index 100% rename from src/emulator/vm.py rename to src/vm.py