Second pass at GDB monitor help command handler refactor.
Also added help text for the new `lr` and `rr` commands.
This commit is contained in:
@@ -29,41 +29,84 @@ namespace DebugServer::Gdb::CommandPackets
|
|||||||
Logger::info("Handling HelpMonitorInfo packet");
|
Logger::info("Handling HelpMonitorInfo packet");
|
||||||
|
|
||||||
static constexpr auto LEFT_PADDING = std::string::size_type{3};
|
static constexpr auto LEFT_PADDING = std::string::size_type{3};
|
||||||
static constexpr auto RIGHT_PADDING = std::string::size_type{26};
|
|
||||||
|
static constexpr auto CMD_COLOR = StringService::TerminalColor::DARK_YELLOW;
|
||||||
|
static constexpr auto PARAM_COLOR = StringService::TerminalColor::BLUE;
|
||||||
|
|
||||||
static const auto leftPadding = std::string{LEFT_PADDING, ' ', std::string::allocator_type{}};
|
static const auto leftPadding = std::string{LEFT_PADDING, ' ', std::string::allocator_type{}};
|
||||||
static const auto leftRightPadding = std::string{
|
|
||||||
LEFT_PADDING + RIGHT_PADDING,
|
|
||||||
' ',
|
|
||||||
std::string::allocator_type{}
|
|
||||||
};
|
|
||||||
|
|
||||||
auto output = std::string{"\nSupported Bloom commands:\n\n"};
|
auto output = std::string{"\nSupported Bloom commands:\n\n"};
|
||||||
output += leftPadding + StringService::padRight("help", ' ', RIGHT_PADDING);
|
|
||||||
output += "Displays this help text.\n";
|
output += StringService::applyTerminalColor("help", CMD_COLOR) + "\n";
|
||||||
output += leftPadding + StringService::padRight("version", ' ', RIGHT_PADDING);
|
output += leftPadding + "Displays this help text.\n\n";
|
||||||
output += "Outputs Bloom's version information.\n";
|
|
||||||
output += leftPadding + StringService::padRight("version machine", ' ', RIGHT_PADDING);
|
output += StringService::applyTerminalColor("version", CMD_COLOR) + "\n";
|
||||||
output += "Outputs Bloom's version information in JSON format.\n";
|
output += leftPadding + "Outputs Bloom's version information.\n\n";
|
||||||
|
|
||||||
|
output += StringService::applyTerminalColor( "version machine", CMD_COLOR) + "\n";
|
||||||
|
output += leftPadding + "Outputs Bloom's version information in JSON format.\n\n";
|
||||||
|
|
||||||
#ifndef EXCLUDE_INSIGHT
|
#ifndef EXCLUDE_INSIGHT
|
||||||
output += leftPadding + StringService::padRight("insight", ' ', RIGHT_PADDING);
|
output += StringService::applyTerminalColor("insight", CMD_COLOR) + "\n";
|
||||||
output += "Activates the Insight GUI.\n";
|
output += leftPadding + "Activates the Insight GUI.\n\n";
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
output += "\n\n";
|
output += StringService::applyTerminalColor("reset", CMD_COLOR) + "\n";
|
||||||
output += leftPadding + StringService::padRight("reset", ' ', RIGHT_PADDING);
|
output += leftPadding + "Resets the target and holds it in a stopped state.\n\n";
|
||||||
output += "Resets the target and holds it in a stopped state.\n\n";
|
|
||||||
|
output += StringService::applyTerminalColor("lr", CMD_COLOR)
|
||||||
|
+ " [" + StringService::applyTerminalColor("PERIPHERAL_KEY", PARAM_COLOR) + "] ["
|
||||||
|
+ StringService::applyTerminalColor("ABS_REG_GROUP_KEY", PARAM_COLOR) + "]\n";
|
||||||
|
output += leftPadding + "Lists all target registers in the given peripheral and register group.\n";
|
||||||
|
output += leftPadding + "If a peripheral key is not provided, all registers across all peripherals will be listed.\n\n";
|
||||||
|
output += leftPadding + "Examples:\n\n";
|
||||||
|
output += leftPadding + "mon " + StringService::applyTerminalColor("lr", CMD_COLOR) + "\n";
|
||||||
|
output += leftPadding + " To list all target registers across all peripherals.\n\n";
|
||||||
|
output += leftPadding + "mon " + StringService::applyTerminalColor("lr", CMD_COLOR)
|
||||||
|
+ " " + StringService::applyTerminalColor("tca0", PARAM_COLOR) + "\n";
|
||||||
|
output += leftPadding + " To list all target registers in the `tca0` peripheral.\n\n";
|
||||||
|
output += leftPadding + "mon " + StringService::applyTerminalColor("lr", CMD_COLOR)
|
||||||
|
+ " " + StringService::applyTerminalColor("tca0", PARAM_COLOR) + " "
|
||||||
|
+ StringService::applyTerminalColor("tca.single", PARAM_COLOR) + "\n";
|
||||||
|
output += leftPadding + " To list all target registers in the `tca.single` register group, in the `tca0` peripheral.\n\n";
|
||||||
|
|
||||||
|
output += StringService::applyTerminalColor("rr", CMD_COLOR)
|
||||||
|
+ " [" + StringService::applyTerminalColor("PERIPHERAL_KEY", PARAM_COLOR) + "] ["
|
||||||
|
+ StringService::applyTerminalColor("ABS_REG_GROUP_KEY", PARAM_COLOR) + "] ["
|
||||||
|
+ StringService::applyTerminalColor("REG_KEY", PARAM_COLOR) + "]\n";
|
||||||
|
output += leftPadding + "Reads the value of the given register.\n";
|
||||||
|
output += leftPadding + "If a register key is not provided, all registers in the given peripheral and register group will be read.\n";
|
||||||
|
output += leftPadding + "The register group key can be omitted if the peripheral contains a single register group,\n";
|
||||||
|
output += leftPadding + "and the register resides directly within that group (not in any subgroup).\n\n";
|
||||||
|
output += leftPadding + "Examples:\n\n";
|
||||||
|
output += leftPadding + "mon " + StringService::applyTerminalColor("rr", CMD_COLOR)
|
||||||
|
+ " " + StringService::applyTerminalColor("porta", PARAM_COLOR) + " "
|
||||||
|
+ StringService::applyTerminalColor("port", PARAM_COLOR) + " "
|
||||||
|
+ StringService::applyTerminalColor("dir", PARAM_COLOR) + "\n";
|
||||||
|
output += leftPadding + " To read the `dir` register in the `port` register group, in the `porta` peripheral.\n\n";
|
||||||
|
output += leftPadding + "mon " + StringService::applyTerminalColor("rr", CMD_COLOR)
|
||||||
|
+ " " + StringService::applyTerminalColor("porta", PARAM_COLOR) + " "
|
||||||
|
+ StringService::applyTerminalColor("dir", PARAM_COLOR) + "\n";
|
||||||
|
output += leftPadding + " Same as above, excluding the register group key.\n\n";
|
||||||
|
output += leftPadding + "mon " + StringService::applyTerminalColor("rr", CMD_COLOR)
|
||||||
|
+ " " + StringService::applyTerminalColor("tca0", PARAM_COLOR) + " "
|
||||||
|
+ StringService::applyTerminalColor("tca.split", PARAM_COLOR) + "\n";
|
||||||
|
output += leftPadding + " To read all registers in the `tca.split` register group, in the `tca0` peripheral.\n\n";
|
||||||
|
output += leftPadding + "mon " + StringService::applyTerminalColor("rr", CMD_COLOR)
|
||||||
|
+ " " + StringService::applyTerminalColor("porta", PARAM_COLOR) + "\n";
|
||||||
|
output += leftPadding + " To read all registers in the `porta` peripheral.\n\n";
|
||||||
|
|
||||||
if (targetDescriptor.family == Targets::TargetFamily::AVR_8) {
|
if (targetDescriptor.family == Targets::TargetFamily::AVR_8) {
|
||||||
output += leftPadding + StringService::padRight("eeprom fill [VALUE]", ' ', RIGHT_PADDING);
|
output += StringService::applyTerminalColor("eeprom fill", CMD_COLOR)
|
||||||
output += "Fills the target's EEPROM with the specified value. The value should be in hexadecimal\n";
|
+ " [" + StringService::applyTerminalColor("VALUE", PARAM_COLOR) + "]\n";
|
||||||
output += leftRightPadding + "format: \"monitor eeprom fill AABBCC\". If the specified value is smaller than the EEPROM\n";
|
output += leftPadding + "Fills the target's EEPROM with the specified value. The value should be in hexadecimal\n";
|
||||||
output += leftRightPadding + "memory segment size, it will be repeated across the entire segment address range. If the\n";
|
output += leftPadding + "format: \"monitor eeprom fill AABBCC\". If the specified value is smaller than the EEPROM\n";
|
||||||
output += leftRightPadding + "value size is not a multiple of the segment size, the value will be truncated in the final\n";
|
output += leftPadding + "memory segment size, it will be repeated across the entire segment address range. If the\n";
|
||||||
output += leftRightPadding + "repetition. The value size must not exceed the segment size.\n";
|
output += leftPadding + "value size is not a multiple of the segment size, the value will be truncated in the final\n";
|
||||||
|
output += leftPadding + "repetition. The value size must not exceed the segment size.\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
output += "\n";
|
||||||
debugSession.connection.writePacket(ResponsePacket{Services::StringService::toHex(output)});
|
debugSession.connection.writePacket(ResponsePacket{Services::StringService::toHex(output)});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -42,11 +42,6 @@ namespace Services
|
|||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string StringService::padRight(std::string str, char padChar, std::size_t padSize) {
|
|
||||||
str.insert(str.end(), str.size() < padSize ? padSize - str.size() : 0, padChar);
|
|
||||||
return str;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string StringService::toHex(std::uint64_t value) {
|
std::string StringService::toHex(std::uint64_t value) {
|
||||||
auto stream = std::stringstream{};
|
auto stream = std::stringstream{};
|
||||||
stream << std::hex << std::setfill('0') << std::setw(16) << static_cast<unsigned int>(value);
|
stream << std::hex << std::setfill('0') << std::setw(16) << static_cast<unsigned int>(value);
|
||||||
|
|||||||
@@ -16,7 +16,6 @@ namespace Services
|
|||||||
|
|
||||||
static bool isAscii(const std::string& str);
|
static bool isAscii(const std::string& str);
|
||||||
static std::string replaceUnprintable(std::string str);
|
static std::string replaceUnprintable(std::string str);
|
||||||
static std::string padRight(std::string str, char padChar, std::size_t padSize);
|
|
||||||
|
|
||||||
static std::string toHex(std::uint64_t value);
|
static std::string toHex(std::uint64_t value);
|
||||||
static std::string toHex(std::uint32_t value);
|
static std::string toHex(std::uint32_t value);
|
||||||
|
|||||||
Reference in New Issue
Block a user