Updated debug interface to allow for halting with a 'cause'. PiperOrigin-RevId: 667625877 Change-Id: Ief9bd58a2c31516ade3cfedf2aa47024f09797a2
diff --git a/mpact/sim/generic/BUILD b/mpact/sim/generic/BUILD index 83e17fa..fce7e43 100644 --- a/mpact/sim/generic/BUILD +++ b/mpact/sim/generic/BUILD
@@ -110,6 +110,7 @@ "debug_command_shell_interface.h", ], deps = [ + ":arch_state", ":core_debug_interface", "//mpact/sim/util/program_loader:elf_loader", "@com_google_absl//absl/container:btree",
diff --git a/mpact/sim/generic/core_debug_interface.h b/mpact/sim/generic/core_debug_interface.h index 871b043..75fd5f6 100644 --- a/mpact/sim/generic/core_debug_interface.h +++ b/mpact/sim/generic/core_debug_interface.h
@@ -74,6 +74,8 @@ // Request that core stop running. virtual absl::Status Halt() = 0; + virtual absl::Status Halt(HaltReason halt_reason) = 0; + virtual absl::Status Halt(HaltReasonValueType halt_reason) = 0; // Step the core by num instructions. virtual absl::StatusOr<int> Step(int num) = 0; // Allow the core to free-run. The loop to run the instructions should be
diff --git a/mpact/sim/generic/debug_command_shell_interface.h b/mpact/sim/generic/debug_command_shell_interface.h index 31e37ae..46689c0 100644 --- a/mpact/sim/generic/debug_command_shell_interface.h +++ b/mpact/sim/generic/debug_command_shell_interface.h
@@ -11,6 +11,7 @@ #include "absl/container/btree_map.h" #include "absl/functional/any_invocable.h" #include "absl/strings/string_view.h" +#include "mpact/sim/generic/arch_state.h" #include "mpact/sim/generic/core_debug_interface.h" #include "mpact/sim/util/program_loader/elf_program_loader.h" @@ -29,8 +30,9 @@ // Each core must provide the debug interface and the elf loader. struct CoreAccess { - CoreDebugInterface *debug_interface; + CoreDebugInterface *debug_interface = nullptr; std::function<util::ElfProgramLoader *()> loader_getter; + ArchState *state = nullptr; absl::btree_map<int, uint64_t> breakpoint_map; int breakpoint_index = 0; absl::btree_map<int, WatchpointInfo> watchpoint_map;
diff --git a/mpact/sim/util/renode/renode_cli_top.cc b/mpact/sim/util/renode/renode_cli_top.cc index a56a715..2c0947e 100644 --- a/mpact/sim/util/renode/renode_cli_top.cc +++ b/mpact/sim/util/renode/renode_cli_top.cc
@@ -310,7 +310,12 @@ void RenodeCLITop::CLIRequestHalt(HaltReason halt_reason, const Instruction *inst) { - (void)top_->Halt(); + (void)top_->Halt(halt_reason); +} + +void RenodeCLITop::CLIRequestHalt(HaltReasonValueType halt_reason, + const Instruction *inst) { + (void)top_->Halt(halt_reason); } } // namespace renode
diff --git a/mpact/sim/util/renode/renode_cli_top.h b/mpact/sim/util/renode/renode_cli_top.h index 8e9e4bf..5945565 100644 --- a/mpact/sim/util/renode/renode_cli_top.h +++ b/mpact/sim/util/renode/renode_cli_top.h
@@ -79,6 +79,9 @@ // Wait for free run to complete. virtual absl::Status CLIWait(); virtual absl::StatusOr<RunStatus> CLIGetRunStatus(); + virtual void CLIRequestHalt(HaltReason halt_reason, const Instruction *inst); + virtual void CLIRequestHalt(HaltReasonValueType halt_reason, + const Instruction *inst); virtual absl::StatusOr<HaltReasonValueType> CLIGetLastHaltReason(); // Register access by register name. virtual absl::StatusOr<uint64_t> CLIReadRegister(const std::string &name); @@ -99,8 +102,6 @@ virtual absl::Status CLIClearAllSwBreakpoints(); virtual absl::StatusOr<Instruction *> CLIGetInstruction(uint64_t address); virtual absl::StatusOr<std::string> CLIGetDisassembly(uint64_t address); - // Called when a halt is requested. - virtual void CLIRequestHalt(HaltReason halt_reason, const Instruction *inst); protected: // Perform the action after having obtained the lock that depends on the CLI
diff --git a/mpact/sim/util/renode/renode_debug_interface.h b/mpact/sim/util/renode/renode_debug_interface.h index b7cfa69..401da5b 100644 --- a/mpact/sim/util/renode/renode_debug_interface.h +++ b/mpact/sim/util/renode/renode_debug_interface.h
@@ -74,6 +74,12 @@ absl::Status Halt() final { return absl::InternalError("Halt: Not implemented"); } + absl::Status Halt(HaltReason) final { + return absl::InternalError("Halt: Not implemented"); + } + absl::Status Halt(HaltReasonValueType) { + return absl::InternalError("Halt: Not implemented"); + } absl::Status Wait() final { return absl::InternalError("Wait: Not implemented"); }