Formatting keys in log output
This commit is contained in:
@@ -48,7 +48,7 @@ namespace DebugServer::Gdb::CommandPackets
|
||||
const auto peripheralDescriptorOpt = targetDescriptor.tryGetPeripheralDescriptor(peripheralKey);
|
||||
|
||||
if (!peripheralDescriptorOpt.has_value()) {
|
||||
throw Exception{"Unknown peripheral key \"" + peripheralKey + "\""};
|
||||
throw Exception{"Unknown peripheral key `" + peripheralKey + "`"};
|
||||
}
|
||||
|
||||
const auto& peripheralDescriptor = peripheralDescriptorOpt->get();
|
||||
@@ -67,7 +67,7 @@ namespace DebugServer::Gdb::CommandPackets
|
||||
);
|
||||
|
||||
if (!registerGroupDescriptorOpt.has_value()) {
|
||||
throw Exception{"Unknown register group key \"" + registerGroupKey + "\""};
|
||||
throw Exception{"Unknown register group key `" + registerGroupKey + "`"};
|
||||
}
|
||||
|
||||
const auto& registerGroupDescriptor = registerGroupDescriptorOpt->get();
|
||||
@@ -99,10 +99,8 @@ namespace DebugServer::Gdb::CommandPackets
|
||||
"---------- \"" + StringService::applyTerminalColor(
|
||||
peripheralDescriptor.name,
|
||||
StringService::TerminalColor::DARK_GREEN
|
||||
) + "\" (`" + StringService::applyTerminalColor(
|
||||
peripheralDescriptor.key,
|
||||
StringService::TerminalColor::DARK_YELLOW
|
||||
) + "`) peripheral registers ----------\n\n"
|
||||
) + "\" (" + StringService::formatKey(peripheralDescriptor.key)
|
||||
+ ") peripheral registers ----------\n\n"
|
||||
)});
|
||||
|
||||
for (const auto& [groupKey, groupDescriptor] : peripheralDescriptor.registerGroupDescriptorsByKey) {
|
||||
@@ -115,13 +113,11 @@ namespace DebugServer::Gdb::CommandPackets
|
||||
DebugSession& debugSession
|
||||
) {
|
||||
for (const auto* registerDescriptor : this->sortRegisterDescriptors(groupDescriptor.registerDescriptorsByKey)) {
|
||||
auto output = std::string{"`" + registerDescriptor->absoluteGroupKey + "`, "};
|
||||
output += "`" + registerDescriptor->key + "`, ";
|
||||
auto output = StringService::formatKey(registerDescriptor->absoluteGroupKey) + ", ";
|
||||
output += StringService::formatKey(registerDescriptor->key) + ", ";
|
||||
output += "\"" + registerDescriptor->name + "\", ";
|
||||
output += StringService::applyTerminalColor(
|
||||
"0x" + StringService::asciiToUpper(StringService::toHex(registerDescriptor->startAddress)),
|
||||
StringService::TerminalColor::BLUE
|
||||
) + ", ";
|
||||
output += "0x" + StringService::asciiToUpper(StringService::toHex(registerDescriptor->startAddress))
|
||||
+ ", ";
|
||||
output += std::to_string(registerDescriptor->size * 8) + "-bit";
|
||||
|
||||
if (registerDescriptor->description.has_value()) {
|
||||
|
||||
@@ -47,7 +47,7 @@ namespace DebugServer::Gdb::CommandPackets
|
||||
const auto peripheralDescriptorOpt = targetDescriptor.tryGetPeripheralDescriptor(peripheralKey);
|
||||
|
||||
if (!peripheralDescriptorOpt.has_value()) {
|
||||
throw Exception{"Unknown peripheral key \"" + peripheralKey + "\""};
|
||||
throw Exception{"Unknown peripheral key `" + peripheralKey + "`"};
|
||||
}
|
||||
|
||||
const auto& peripheralDescriptor = peripheralDescriptorOpt->get();
|
||||
@@ -67,7 +67,7 @@ namespace DebugServer::Gdb::CommandPackets
|
||||
|
||||
if (!registerGroupDescriptorOpt.has_value()) {
|
||||
if (peripheralDescriptor.registerGroupDescriptorsByKey.size() != 1 || argCount >= 4) {
|
||||
throw Exception{"Unknown register group key \"" + registerGroupKey + "\""};
|
||||
throw Exception{"Unknown register group key `" + registerGroupKey + "`"};
|
||||
}
|
||||
|
||||
registerGroupDescriptorOpt = peripheralDescriptor.registerGroupDescriptorsByKey.begin()->second;
|
||||
@@ -89,7 +89,7 @@ namespace DebugServer::Gdb::CommandPackets
|
||||
const auto registerDescriptorOpt = registerGroupDescriptor.tryGetRegisterDescriptor(*registerKey);
|
||||
|
||||
if (!registerDescriptorOpt.has_value()) {
|
||||
throw Exception{"Unknown register key \"" + *registerKey + "\""};
|
||||
throw Exception{"Unknown register key `" + *registerKey + "`"};
|
||||
}
|
||||
|
||||
this->handleSingleRegisterOutput(registerDescriptorOpt->get(), debugSession, targetControllerService);
|
||||
@@ -112,10 +112,8 @@ namespace DebugServer::Gdb::CommandPackets
|
||||
TargetControllerService& targetControllerService
|
||||
) {
|
||||
auto output = std::string{"\nName: \"" + registerDescriptor.name + "\"\n"};
|
||||
output += "Address: " + StringService::applyTerminalColor(
|
||||
"0x" + StringService::asciiToUpper(StringService::toHex(registerDescriptor.startAddress)),
|
||||
StringService::TerminalColor::BLUE
|
||||
) + "\n";
|
||||
output += "Address: 0x" + StringService::asciiToUpper(StringService::toHex(registerDescriptor.startAddress))
|
||||
+ "\n";
|
||||
output += "Width: " + std::to_string(registerDescriptor.size * 8) + "-bit\n\n";
|
||||
|
||||
output += "----------- Value -----------\n";
|
||||
@@ -177,13 +175,11 @@ namespace DebugServer::Gdb::CommandPackets
|
||||
TargetControllerService& targetControllerService
|
||||
) {
|
||||
for (const auto* registerDescriptor : this->sortRegisterDescriptors(groupDescriptor.registerDescriptorsByKey)) {
|
||||
auto output = std::string{"`" + registerDescriptor->absoluteGroupKey + "`, "};
|
||||
output += "`" + registerDescriptor->key + "`, ";
|
||||
auto output = StringService::formatKey(registerDescriptor->absoluteGroupKey) + ", ";
|
||||
output += StringService::formatKey(registerDescriptor->key) + ", ";
|
||||
output += "\"" + registerDescriptor->name + "\", ";
|
||||
output += StringService::applyTerminalColor(
|
||||
"0x" + StringService::asciiToUpper(StringService::toHex(registerDescriptor->startAddress)),
|
||||
StringService::TerminalColor::BLUE
|
||||
) + ", ";
|
||||
output += "0x" + StringService::asciiToUpper(StringService::toHex(registerDescriptor->startAddress))
|
||||
+ ", ";
|
||||
output += std::to_string(registerDescriptor->size * 8) + "-bit | ";
|
||||
|
||||
if (registerDescriptor->access.readable) {
|
||||
|
||||
@@ -38,13 +38,9 @@ namespace DebugServer::Gdb::CommandPackets
|
||||
|
||||
debugSession.connection.writePacket(ResponsePacket{Services::StringService::toHex(
|
||||
"Target reset complete\n"
|
||||
"Current PC: " + StringService::applyTerminalColor(
|
||||
"0x" + StringService::asciiToUpper(
|
||||
StringService::toHex(targetControllerService.getProgramCounter())
|
||||
),
|
||||
StringService::TerminalColor::BLUE
|
||||
) + "\n"
|
||||
"Use the 'continue' command to begin execution\n"
|
||||
"Current PC: 0x" + StringService::asciiToUpper(
|
||||
StringService::toHex(targetControllerService.getProgramCounter())
|
||||
) + "\nUse the 'continue' command to begin execution\n"
|
||||
)});
|
||||
|
||||
} catch (const Exception& exception) {
|
||||
|
||||
@@ -49,7 +49,7 @@ namespace DebugServer::Gdb::CommandPackets
|
||||
|
||||
const auto peripheralDescriptorOpt = targetDescriptor.tryGetPeripheralDescriptor(peripheralKey);
|
||||
if (!peripheralDescriptorOpt.has_value()) {
|
||||
throw Exception{"Unknown peripheral key \"" + peripheralKey + "\""};
|
||||
throw Exception{"Unknown peripheral key `" + peripheralKey + "`"};
|
||||
}
|
||||
|
||||
const auto& peripheralDescriptor = peripheralDescriptorOpt->get();
|
||||
@@ -63,7 +63,7 @@ namespace DebugServer::Gdb::CommandPackets
|
||||
const auto& registerGroupKey = this->commandArguments[2];
|
||||
registerGroupDescriptorOpt = peripheralDescriptor.tryGetRegisterGroupDescriptor(registerGroupKey);
|
||||
if (!registerGroupDescriptorOpt.has_value()) {
|
||||
throw Exception{"Unknown absolute register group key \"" + registerGroupKey + "\""};
|
||||
throw Exception{"Unknown absolute register group key `" + registerGroupKey + "`"};
|
||||
}
|
||||
|
||||
} else {
|
||||
@@ -83,7 +83,7 @@ namespace DebugServer::Gdb::CommandPackets
|
||||
const auto& registerKey = registerGroupKeyProvided ? this->commandArguments[3] : this->commandArguments[2];
|
||||
const auto registerDescriptorOpt = registerGroupDescriptor.tryGetRegisterDescriptor(registerKey);
|
||||
if (!registerDescriptorOpt.has_value()) {
|
||||
throw Exception{"Unknown register key \"" + registerKey + "\""};
|
||||
throw Exception{"Unknown register key `" + registerKey + "`"};
|
||||
}
|
||||
|
||||
const auto& registerDescriptor = registerDescriptorOpt->get();
|
||||
@@ -103,7 +103,7 @@ namespace DebugServer::Gdb::CommandPackets
|
||||
const auto& bitFieldKey = registerGroupKeyProvided ? this->commandArguments[4] : this->commandArguments[3];
|
||||
const auto bitFieldDescriptorOpt = registerDescriptor.tryGetBitFieldDescriptor(bitFieldKey);
|
||||
if (!bitFieldDescriptorOpt.has_value()) {
|
||||
throw Exception{"Unknown bit field key \"" + bitFieldKey + "\""};
|
||||
throw Exception{"Unknown bit field key `" + bitFieldKey + "`"};
|
||||
}
|
||||
|
||||
const auto& bitFieldDescriptor = bitFieldDescriptorOpt->get();
|
||||
@@ -181,10 +181,8 @@ namespace DebugServer::Gdb::CommandPackets
|
||||
"0x" + newValueHex,
|
||||
StringService::TerminalColor::DARK_YELLOW
|
||||
) + " (" + std::to_string(registerDescriptor.size * 8) + "-bit" + ") to \"" + registerDescriptor.name
|
||||
+ "\" register, at address " + StringService::applyTerminalColor(
|
||||
"0x" + StringService::toHex(registerDescriptor.startAddress),
|
||||
StringService::TerminalColor::BLUE
|
||||
) + ", via `" + registerDescriptor.addressSpaceKey + "` address space...\n"
|
||||
+ "\" register, at address 0x" + StringService::toHex(registerDescriptor.startAddress) + ", via "
|
||||
+ StringService::formatKey(registerDescriptor.addressSpaceKey) + " address space...\n"
|
||||
)});
|
||||
|
||||
targetControllerService.writeRegister(registerDescriptor, dynamicValue.data());
|
||||
|
||||
@@ -48,7 +48,7 @@ namespace DebugServer::Gdb::CommandPackets
|
||||
|
||||
const auto peripheralDescriptorOpt = targetDescriptor.tryGetPeripheralDescriptor(peripheralKey);
|
||||
if (!peripheralDescriptorOpt.has_value()) {
|
||||
throw Exception{"Unknown peripheral key \"" + peripheralKey + "\""};
|
||||
throw Exception{"Unknown peripheral key `" + peripheralKey + "`"};
|
||||
}
|
||||
|
||||
const auto& peripheralDescriptor = peripheralDescriptorOpt->get();
|
||||
@@ -62,7 +62,7 @@ namespace DebugServer::Gdb::CommandPackets
|
||||
const auto& registerGroupKey = this->commandArguments[2];
|
||||
registerGroupDescriptorOpt = peripheralDescriptor.tryGetRegisterGroupDescriptor(registerGroupKey);
|
||||
if (!registerGroupDescriptorOpt.has_value()) {
|
||||
throw Exception{"Unknown absolute register group key \"" + registerGroupKey + "\""};
|
||||
throw Exception{"Unknown absolute register group key `" + registerGroupKey + "`"};
|
||||
}
|
||||
|
||||
} else {
|
||||
@@ -82,7 +82,7 @@ namespace DebugServer::Gdb::CommandPackets
|
||||
const auto& registerKey = registerGroupKeyProvided ? this->commandArguments[3] : this->commandArguments[2];
|
||||
const auto registerDescriptorOpt = registerGroupDescriptor.tryGetRegisterDescriptor(registerKey);
|
||||
if (!registerDescriptorOpt.has_value()) {
|
||||
throw Exception{"Unknown register key \"" + registerKey + "\""};
|
||||
throw Exception{"Unknown register key `" + registerKey + "`"};
|
||||
}
|
||||
|
||||
const auto& registerDescriptor = registerDescriptorOpt->get();
|
||||
@@ -121,10 +121,8 @@ namespace DebugServer::Gdb::CommandPackets
|
||||
"0x" + StringService::toHex(value).substr(16 - (registerDescriptor.size * 2)),
|
||||
StringService::TerminalColor::DARK_YELLOW
|
||||
) + " (" + std::to_string(buffer.size() * 8) + "-bit" + ") to \"" + registerDescriptor.name
|
||||
+ "\" register, at address " + StringService::applyTerminalColor(
|
||||
"0x" + StringService::toHex(registerDescriptor.startAddress),
|
||||
StringService::TerminalColor::BLUE
|
||||
) + ", via `" + registerDescriptor.addressSpaceKey + "` address space...\n"
|
||||
+ "\" register, at address 0x" + StringService::toHex(registerDescriptor.startAddress) + ", via "
|
||||
+ StringService::formatKey(registerDescriptor.addressSpaceKey) + " address space...\n"
|
||||
)});
|
||||
|
||||
targetControllerService.writeRegister(registerDescriptor, buffer);
|
||||
|
||||
Reference in New Issue
Block a user