Added "monitor help" command, to display help text on supported GDB custom commands
This commit is contained in:
7
resources/gdbHelpMonitorInfo.txt
Normal file
7
resources/gdbHelpMonitorInfo.txt
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
Supported Bloom commands:
|
||||||
|
|
||||||
|
help Displays this help text.
|
||||||
|
version Outputs Bloom's version information.
|
||||||
|
version machine Outputs Bloom's version information in JSON format.
|
||||||
|
|
||||||
|
reset Resets the target and holds it in a stopped state.
|
||||||
@@ -19,6 +19,7 @@ target_sources(
|
|||||||
${CMAKE_CURRENT_SOURCE_DIR}/Gdb/CommandPackets/RemoveBreakpoint.cpp
|
${CMAKE_CURRENT_SOURCE_DIR}/Gdb/CommandPackets/RemoveBreakpoint.cpp
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/Gdb/CommandPackets/Monitor.cpp
|
${CMAKE_CURRENT_SOURCE_DIR}/Gdb/CommandPackets/Monitor.cpp
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/Gdb/CommandPackets/ResetTarget.cpp
|
${CMAKE_CURRENT_SOURCE_DIR}/Gdb/CommandPackets/ResetTarget.cpp
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/Gdb/CommandPackets/HelpMonitorInfo.cpp
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/Gdb/CommandPackets/BloomVersion.cpp
|
${CMAKE_CURRENT_SOURCE_DIR}/Gdb/CommandPackets/BloomVersion.cpp
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/Gdb/CommandPackets/BloomVersionMachine.cpp
|
${CMAKE_CURRENT_SOURCE_DIR}/Gdb/CommandPackets/BloomVersionMachine.cpp
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/Gdb/ResponsePackets/SupportedFeaturesResponse.cpp
|
${CMAKE_CURRENT_SOURCE_DIR}/Gdb/ResponsePackets/SupportedFeaturesResponse.cpp
|
||||||
|
|||||||
51
src/DebugServer/Gdb/CommandPackets/HelpMonitorInfo.cpp
Normal file
51
src/DebugServer/Gdb/CommandPackets/HelpMonitorInfo.cpp
Normal file
@@ -0,0 +1,51 @@
|
|||||||
|
#include "HelpMonitorInfo.hpp"
|
||||||
|
|
||||||
|
#include <QFile>
|
||||||
|
#include <QString>
|
||||||
|
|
||||||
|
#include "src/DebugServer/Gdb/ResponsePackets/ErrorResponsePacket.hpp"
|
||||||
|
#include "src/DebugServer/Gdb/ResponsePackets/ResponsePacket.hpp"
|
||||||
|
|
||||||
|
#include "src/Helpers/Paths.hpp"
|
||||||
|
#include "src/Logger/Logger.hpp"
|
||||||
|
#include "src/Exceptions/Exception.hpp"
|
||||||
|
|
||||||
|
namespace Bloom::DebugServer::Gdb::CommandPackets
|
||||||
|
{
|
||||||
|
using TargetController::TargetControllerConsole;
|
||||||
|
|
||||||
|
using ResponsePackets::ErrorResponsePacket;
|
||||||
|
using ResponsePackets::ResponsePacket;
|
||||||
|
|
||||||
|
using Exceptions::Exception;
|
||||||
|
|
||||||
|
HelpMonitorInfo::HelpMonitorInfo(Monitor&& monitorPacket)
|
||||||
|
: Monitor(std::move(monitorPacket))
|
||||||
|
{}
|
||||||
|
|
||||||
|
void HelpMonitorInfo::handle(DebugSession& debugSession, TargetControllerConsole&) {
|
||||||
|
Logger::debug("Handling HelpMonitorInfo packet");
|
||||||
|
|
||||||
|
try {
|
||||||
|
// The file gdbHelpMonitorInfo.txt is included in the binary image as a resource. See src/resource.qrc
|
||||||
|
auto helpFile = QFile(
|
||||||
|
QString::fromStdString(Paths::compiledResourcesPath() + "/resources/gdbHelpMonitorInfo.txt")
|
||||||
|
);
|
||||||
|
|
||||||
|
if (!helpFile.open(QIODevice::ReadOnly)) {
|
||||||
|
throw Exception(
|
||||||
|
"Failed to open GDB monitor info help file - please report this issue at " + Paths::homeDomainName()
|
||||||
|
+ "/report-issue"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
debugSession.connection.writePacket(
|
||||||
|
ResponsePacket(Packet::toHex("\n" + QTextStream(&helpFile).readAll().toUtf8().toStdString() + "\n"))
|
||||||
|
);
|
||||||
|
|
||||||
|
} catch (const Exception& exception) {
|
||||||
|
Logger::error(exception.getMessage());
|
||||||
|
debugSession.connection.writePacket(ErrorResponsePacket());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
24
src/DebugServer/Gdb/CommandPackets/HelpMonitorInfo.hpp
Normal file
24
src/DebugServer/Gdb/CommandPackets/HelpMonitorInfo.hpp
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <cstdint>
|
||||||
|
|
||||||
|
#include "Monitor.hpp"
|
||||||
|
|
||||||
|
namespace Bloom::DebugServer::Gdb::CommandPackets
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* The HelpMonitorInfo class implements a structure for the "monitor help" GDB command.
|
||||||
|
*
|
||||||
|
* We just respond with some help info on the available "monitor" commands.
|
||||||
|
*/
|
||||||
|
class HelpMonitorInfo: public Monitor
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
explicit HelpMonitorInfo(Monitor&& monitorPacket);
|
||||||
|
|
||||||
|
void handle(
|
||||||
|
DebugSession& debugSession,
|
||||||
|
TargetController::TargetControllerConsole& targetControllerConsole
|
||||||
|
) override;
|
||||||
|
};
|
||||||
|
}
|
||||||
@@ -26,6 +26,7 @@
|
|||||||
#include "CommandPackets/RemoveBreakpoint.hpp"
|
#include "CommandPackets/RemoveBreakpoint.hpp"
|
||||||
#include "CommandPackets/Monitor.hpp"
|
#include "CommandPackets/Monitor.hpp"
|
||||||
#include "CommandPackets/ResetTarget.hpp"
|
#include "CommandPackets/ResetTarget.hpp"
|
||||||
|
#include "CommandPackets/HelpMonitorInfo.hpp"
|
||||||
#include "CommandPackets/BloomVersion.hpp"
|
#include "CommandPackets/BloomVersion.hpp"
|
||||||
#include "CommandPackets/BloomVersionMachine.hpp"
|
#include "CommandPackets/BloomVersionMachine.hpp"
|
||||||
|
|
||||||
@@ -296,6 +297,10 @@ namespace Bloom::DebugServer::Gdb
|
|||||||
// This is a monitor packet
|
// This is a monitor packet
|
||||||
auto monitorCommand = std::make_unique<CommandPackets::Monitor>(rawPacket);
|
auto monitorCommand = std::make_unique<CommandPackets::Monitor>(rawPacket);
|
||||||
|
|
||||||
|
if (monitorCommand->command == "help") {
|
||||||
|
return std::make_unique<CommandPackets::HelpMonitorInfo>(std::move(*(monitorCommand.get())));
|
||||||
|
}
|
||||||
|
|
||||||
if (monitorCommand->command == "version") {
|
if (monitorCommand->command == "version") {
|
||||||
return std::make_unique<CommandPackets::BloomVersion>(std::move(*(monitorCommand.get())));
|
return std::make_unique<CommandPackets::BloomVersion>(std::move(*(monitorCommand.get())));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,6 +13,9 @@
|
|||||||
<!-- The contents of help.txt is presented to the user in response to the invocation of the help command -->
|
<!-- The contents of help.txt is presented to the user in response to the invocation of the help command -->
|
||||||
<file alias="/compiled/resources/help.txt">../resources/help.txt</file>
|
<file alias="/compiled/resources/help.txt">../resources/help.txt</file>
|
||||||
|
|
||||||
|
<!-- The contents of gdbHelpMonitorInfo.txt is presented to the user in response to the invocation of the "monitor help" GDB command -->
|
||||||
|
<file alias="/compiled/resources/gdbHelpMonitorInfo.txt">../resources/gdbHelpMonitorInfo.txt</file>
|
||||||
|
|
||||||
<!-- The bloom.template.json is a template configuration file that is used to initiate a new project, via the init command -->
|
<!-- The bloom.template.json is a template configuration file that is used to initiate a new project, via the init command -->
|
||||||
<file alias="/compiled/resources/bloom.template.json">../resources/bloom.template.json</file>
|
<file alias="/compiled/resources/bloom.template.json">../resources/bloom.template.json</file>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user