Changed display of interrupt information in the debug command shell.
Now a new interrupt is shown only the cycle it occurs (while stepping).
The full interrupt stack is shown in the reg $all view.
PiperOrigin-RevId: 707251125
Change-Id: I44261d5f4cf2c956bcef6139bcaacb9b40880ce0
diff --git a/cheriot/debug_command_shell.cc b/cheriot/debug_command_shell.cc
index 7e4c236..cd2f0d4 100644
--- a/cheriot/debug_command_shell.cc
+++ b/cheriot/debug_command_shell.cc
@@ -195,6 +195,7 @@
exec NAME - load commands from file 'NAME' and execute
each line as a command. Lines starting with
a '#' are treated as comments.
+ status - display current status.
help - display this message.
Special names:
@@ -260,6 +261,7 @@
current_core_ = 0;
absl::string_view line_view;
bool halt_reason = false;
+ int last_info_list_size = 0;
while (true) {
// Prompt and read in the next command.
auto pcc_result =
@@ -330,14 +332,14 @@
auto cheriot_state =
static_cast<CheriotState *>(core_access_[current_core_].state);
auto &info_list = cheriot_state->interrupt_info_list();
- int count = 0;
- for (auto iter = info_list.rbegin(); iter != info_list.rend(); ++iter) {
- auto const &info = *iter;
- absl::StrAppend(&prompt, "[", count++, "] ",
- info.is_interrupt ? "interrupt" : "exception", " ",
+ // Check if there is a new interrupt, if so print the info.
+ if (info_list.size() > last_info_list_size) {
+ auto const &info = *info_list.rbegin();
+ absl::StrAppend(&prompt, info.is_interrupt ? "interrupt " : "exception ",
info.is_interrupt ? GetInterruptDescription(info)
: GetExceptionDescription(info));
}
+ last_info_list_size = info_list.size();
absl::StrAppend(&prompt, "[", current_core_, "] > ");
while (!command_streams_.empty()) {
auto ¤t_is = *command_streams_.back();
@@ -1643,6 +1645,23 @@
std::string DebugCommandShell::FormatAllRegisters(int core) const {
std::string output;
+ // Interrupt stack.
+ auto cheriot_state =
+ static_cast<CheriotState *>(core_access_[current_core_].state);
+ auto &info_list = cheriot_state->interrupt_info_list();
+ int count = 0;
+ if (!info_list.empty()) {
+ absl::StrAppend(&output, "Interrupt stack:\n");
+ for (auto iter = info_list.rbegin(); iter != info_list.rend(); ++iter) {
+ auto const &info = *iter;
+ absl::StrAppend(&output, "[", count++, "] ",
+ info.is_interrupt ? "interrupt" : "exception", " ",
+ info.is_interrupt ? GetInterruptDescription(info)
+ : GetExceptionDescription(info));
+ }
+ absl::StrAppend(&output, "\n");
+ }
+ // Registers.
for (auto const ®_name : reg_vector_) {
absl::StrAppend(&output, FormatRegister(current_core_, reg_name), "\n");
}
@@ -1766,7 +1785,7 @@
}
std::string DebugCommandShell::GetInterruptDescription(
- const InterruptInfo &info) {
+ const InterruptInfo &info) const {
std::string output;
if (!info.is_interrupt) return output;
switch (info.cause & 0x7fff'ffff) {
@@ -1806,7 +1825,7 @@
}
std::string DebugCommandShell::GetExceptionDescription(
- const InterruptInfo &info) {
+ const InterruptInfo &info) const {
std::string output;
if (info.is_interrupt) return output;
absl::StrAppend(&output, " Exception taken at ", absl::Hex(info.epc), ": ");
diff --git a/cheriot/debug_command_shell.h b/cheriot/debug_command_shell.h
index b58b1fe..b32545f 100644
--- a/cheriot/debug_command_shell.h
+++ b/cheriot/debug_command_shell.h
@@ -134,8 +134,8 @@
};
// Helper method to get the interrupt description.
- std::string GetInterruptDescription(const InterruptInfo &info);
- std::string GetExceptionDescription(const InterruptInfo &info);
+ std::string GetInterruptDescription(const InterruptInfo &info) const;
+ std::string GetExceptionDescription(const InterruptInfo &info) const;
// Helper method for formatting single data buffer value.
std::string FormatSingleDbValue(generic::DataBuffer *db,