From 0b1bf15c4c8bedbd7a9070c0ae8c3d35f8af1bcf Mon Sep 17 00:00:00 2001 From: Daniel Brondani Date: Tue, 17 Nov 2026 17:12:48 +0100 Subject: [PATCH] [projmgr] Add debugger `rtt` nodes and `stdio`/`telnet` alias to align with documentation --- tools/projmgr/include/ProjMgrParser.h | 39 ++++-- tools/projmgr/include/ProjMgrRunDebug.h | 4 +- tools/projmgr/include/ProjMgrWorker.h | 9 +- tools/projmgr/include/ProjMgrYamlParser.h | 8 +- tools/projmgr/schemas/common.schema.json | 34 +++-- tools/projmgr/src/ProjMgrCbuildRun.cpp | 48 +++++-- tools/projmgr/src/ProjMgrRunDebug.cpp | 65 +++++---- tools/projmgr/src/ProjMgrWorker.cpp | 29 ++++- tools/projmgr/src/ProjMgrYamlParser.cpp | 59 ++++++--- .../data/TestRunDebug/stdio.csolution.yml | 46 +++++++ .../src/ProjMgrSchemaCheckerUnitTests.cpp | 63 +++++++++ tools/projmgr/test/src/ProjMgrUnitTests.cpp | 123 ++++++++++++++++-- .../test/src/ProjMgrYamlParserUnitTest.cpp | 74 +++++++++++ 13 files changed, 498 insertions(+), 103 deletions(-) create mode 100644 tools/projmgr/test/data/TestRunDebug/stdio.csolution.yml diff --git a/tools/projmgr/include/ProjMgrParser.h b/tools/projmgr/include/ProjMgrParser.h index fda796d03..0f9b279de 100644 --- a/tools/projmgr/include/ProjMgrParser.h +++ b/tools/projmgr/include/ProjMgrParser.h @@ -136,16 +136,19 @@ struct MemoryItem { }; /** - * @brief telnet item containing + * @brief stdio item containing * mode * port - * file + * legacy output file + * input and output files * pname */ -struct TelnetItem { +struct StdioItem { std::string mode; std::string port; std::string file; + std::string fileIn; + std::string fileOut; std::string pname; }; @@ -182,6 +185,19 @@ struct CustomItem { std::vector> map; }; +// Keep RTT configuration extensible, processing file paths separately from +// the remaining channel and control-block properties, as for trace options. +struct RttChannelItem { + std::string fileIn; + std::string fileOut; + CustomItem custom; +}; + +struct RttItem { + std::vector channels; + CustomItem custom; +}; + struct TraceItem { std::string file; CustomItem custom; @@ -195,7 +211,7 @@ struct TraceItem { * debug configuration file * device settings * start pname - * telnet options + * stdio options * systemview options * custom properties */ @@ -206,7 +222,8 @@ struct DebuggerItem { std::string dbgconf; std::map deviceSettings; std::string startPname; - std::vector telnet; + std::vector stdio; + std::vector rtt; std::vector trace; SystemViewItem systemView; CustomItem custom; @@ -795,12 +812,12 @@ struct GdbServerDefaults { }; /** - * @brief telnet defaults item containing - * telnet port - * telnet mode + * @brief stdio defaults item containing + * stdio port + * stdio mode * active flag */ -struct TelnetDefaults { +struct StdioDefaults { std::string port; std::string mode; bool active = false; @@ -809,14 +826,14 @@ struct TelnetDefaults { /** * @brief debug-adapter defaults item containing * gdbserver defaults - * telnet defaults + * stdio defaults * systemview defaults * debug protocol(jtag or swd) * debug clock speed */ struct DebugAdapterDefaultsItem { GdbServerDefaults gdbserver; - TelnetDefaults telnet; + StdioDefaults stdio; std::string protocol; std::string clock; CustomItem custom; diff --git a/tools/projmgr/include/ProjMgrRunDebug.h b/tools/projmgr/include/ProjMgrRunDebug.h index d8566f249..7eb5eb190 100644 --- a/tools/projmgr/include/ProjMgrRunDebug.h +++ b/tools/projmgr/include/ProjMgrRunDebug.h @@ -292,10 +292,10 @@ class ProjMgrRunDebug { const std::map& pnames); void CollectDebugTopology(const ContextItem& context, std::vector>> debugs, const std::map& pnames); - void CollectTelnetOptions(const ContextItem& context, DebugAdapterItem& adapter, + void CollectStdioOptions(const ContextItem& context, DebugAdapterItem& adapter, const std::map& pnames); void CollectSystemViewOptions(const SystemViewItem& context); - void SetTelnetPort(TelnetOptionsItem& item, unsigned long long& port, std::set& usedPorts); + void SetStdioPort(StdioOptionsItem& item, unsigned long long& port, std::set& usedPorts); }; #endif // PROJMGRRUNDEBUG_H diff --git a/tools/projmgr/include/ProjMgrWorker.h b/tools/projmgr/include/ProjMgrWorker.h index 2f55a7dc2..394b3a589 100644 --- a/tools/projmgr/include/ProjMgrWorker.h +++ b/tools/projmgr/include/ProjMgrWorker.h @@ -310,10 +310,10 @@ struct GdbServerItem { }; /** - * @brief telnet port item extends TelnetItem containing + * @brief stdio port item extends StdioItem containing resolved port number */ -struct TelnetOptionsItem : TelnetItem { +struct StdioOptionsItem : StdioItem { unsigned long long ullPort; }; @@ -390,7 +390,7 @@ struct TemplateItem { * device settings * start pname * list of gdbserver items - * list of telnet options items + * list of stdio options items * custom options */ struct DebuggerType { @@ -402,7 +402,8 @@ struct DebuggerType { std::map deviceSettings; std::string startPname; std::vector gdbserver; - std::map telnet; + std::map stdio; + std::vector rtt; std::vector trace; SystemViewItem systemView; CustomItem custom; diff --git a/tools/projmgr/include/ProjMgrYamlParser.h b/tools/projmgr/include/ProjMgrYamlParser.h index 718fd574d..590fa619b 100644 --- a/tools/projmgr/include/ProjMgrYamlParser.h +++ b/tools/projmgr/include/ProjMgrYamlParser.h @@ -275,7 +275,12 @@ static constexpr const char* YAML_TARGET_SET = "target-set"; static constexpr const char* YAML_TARGETTYPE = "target-type"; static constexpr const char* YAML_TARGETTYPES = "target-types"; static constexpr const char* YAML_TEMPLATE = "template"; +static constexpr const char* YAML_STDIO = "stdio"; static constexpr const char* YAML_TELNET = "telnet"; +static constexpr const char* YAML_RTT = "rtt"; +static constexpr const char* YAML_CHANNEL = "channel"; +static constexpr const char* YAML_FILE_IN = "file-in"; +static constexpr const char* YAML_FILE_OUT = "file-out"; static constexpr const char* YAML_TRACE = "trace"; static constexpr const char* YAML_TRACE_SINKS = "trace-sinks"; static constexpr const char* YAML_TRACEBUFFER = "tracebuffer"; @@ -411,7 +416,8 @@ class ProjMgrYamlParser { bool ParseLinker(const YAML::Node& parent, const std::string& file, std::vector& linker); void ParseRte(const YAML::Node& parent, std::string& rteBaseDir); void ParseDebugDefaults(const YAML::Node& parent, const std::string& file, DebugAdapterDefaultsItem& defaults); - void ParseTelnet(const YAML::Node& parent, const std::string& file, std::vector& telnet); + void ParseRtt(const YAML::Node& parent, const std::string& file, std::vector& rtt); + void ParseStdio(const YAML::Node& parent, const std::string& file, std::vector& stdio); void ParseTrace(const YAML::Node& parent, const std::string& file, std::vector& trace); void ParseSystemView(const YAML::Node& parent, const std::string& file, SystemViewItem& systemView); void ParseCustom(const YAML::Node& parent, const std::vector& skip, CustomItem& custom); diff --git a/tools/projmgr/schemas/common.schema.json b/tools/projmgr/schemas/common.schema.json index ffb1f62b8..e67febf55 100644 --- a/tools/projmgr/schemas/common.schema.json +++ b/tools/projmgr/schemas/common.schema.json @@ -2316,7 +2316,8 @@ "dbgconf": { "type": "string", "description": "Debugger configuration file (pinout, trace)." }, "start-pname": { "type": "string", "description": "Debugger connects at start to this processor." }, "gdbserver": { "$ref": "#/definitions/GdbServersType" }, - "telnet": { "$ref": "#/definitions/TelnetOptionsType" }, + "stdio": { "$ref": "#/definitions/StdioOptionsType" }, + "telnet": { "$ref": "#/definitions/StdioOptionsType", "description": "Legacy alias for stdio." }, "rtt": { "$ref": "#/definitions/RttOptionsType" }, "trace": { "$ref": "#/definitions/TraceOptionsType" }, "systemview": { "$ref": "#/definitions/SystemViewOptionType" }, @@ -2400,26 +2401,32 @@ "type": "object", "properties": { "number": { "type": "number", "description": "RTT channel number." }, - "mode": { "enum": [ "stdio", "server", "systemview", "systemview-server" ], "description": "RTT channel mode." }, - "port": { "type": "number", "description": "TCP port number (required for server and systemview-server)." } + "mode": { "enum": [ "stdio", "server", "file", "systemview", "systemview-server" ], "description": "RTT channel mode." }, + "port": { "type": "number", "description": "TCP port number (required for server and systemview-server)." }, + "file-in": { "type": "string", "description": "Path to the RTT channel input file in file mode." }, + "file-out": { "type": "string", "description": "Path to the RTT channel output file in file mode." } }, "additionalProperties": false, "required": [ "number", "mode" ] }, - "TelnetOptionsType": { - "title": "telnet:\nDocumentation: https://open-cmsis-pack.github.io/cmsis-toolbox/pyOCD-Debugger/#telnet", - "description": "Telnet port for connecting remote tools.", + "TelnetOptionsType": { "$ref": "#/definitions/StdioOptionsType" }, + "TelnetOptionType": { "$ref": "#/definitions/StdioOptionType" }, + "StdioOptionsType": { + "title": "stdio:\nDocumentation: https://open-cmsis-pack.github.io/cmsis-toolbox/pyOCD-Debugger/#stdio", + "description": "Standard I/O configuration.", "type": "array", "uniqueItems": true, - "items": { "$ref": "#/definitions/TelnetOptionType" } + "items": { "$ref": "#/definitions/StdioOptionType" } }, - "TelnetOptionType": { + "StdioOptionType": { "type": "object", "properties": { - "mode": { "enum": [ "off", "server", "file", "console", "monitor" ], "description": "Redirect output mode." }, - "pname": { "type": "string", "description": "Processor name of the processor (only required for multi-core systems)." }, - "port": { "type": "number", "description": "Set TCP/IP port number of Telnet Server." }, - "file": { "type": "string", "description": "Base path and name of the telnet output file (without extension)."} + "mode": { "enum": [ "off", "server", "file", "console", "monitor" ], "description": "Redirect output mode." }, + "pname": { "type": "string", "description": "Processor name of the processor (only required for multi-core systems)." }, + "port": { "type": "number", "description": "Set TCP/IP port number of Telnet Server." }, + "file": { "type": "string", "description": "Legacy explicit path and name of the standard I/O output file." }, + "file-in": { "type": "string", "description": "Complete path and filename of the standard I/O input file." }, + "file-out": { "type": "string", "description": "Complete path and filename of the standard I/O output file." } }, "additionalProperties": false, "required": ["mode"] @@ -2659,7 +2666,8 @@ "clock": { "type": "number", "description": "Selected debug clock speed (in Hz)." }, "dbgconf": { "type": "string", "description": "Debugger configuration file (pinout, trace)." }, "start-pname": { "type": "string", "description": "Debugger connects at start to this processor." }, - "telnet": { "$ref": "#/definitions/TelnetOptionsType" }, + "stdio": { "$ref": "#/definitions/StdioOptionsType" }, + "telnet": { "$ref": "#/definitions/StdioOptionsType", "description": "Legacy alias for stdio." }, "rtt": { "$ref": "#/definitions/RttOptionsType" }, "trace": { "$ref": "#/definitions/TraceOptionsType" }, "systemview": { "$ref": "#/definitions/SystemViewOptionType" }, diff --git a/tools/projmgr/src/ProjMgrCbuildRun.cpp b/tools/projmgr/src/ProjMgrCbuildRun.cpp index 14601e684..22d5566a0 100644 --- a/tools/projmgr/src/ProjMgrCbuildRun.cpp +++ b/tools/projmgr/src/ProjMgrCbuildRun.cpp @@ -36,7 +36,8 @@ class ProjMgrCbuildRun : public ProjMgrCbuildBase { void SetAccessPortsNode(YAML::Node node, const std::vector& accessPorts); void SetDatapatchNode(YAML::Node node, const std::vector& datapatch); void SetGdbServerNode(YAML::Node node, const std::vector& gdbserver); - void SetTelnetNode(YAML::Node node, const std::map& telnet); + void SetRttNode(YAML::Node node, const std::vector& rtt); + void SetStdioNode(YAML::Node node, const std::map& stdio); void SetTraceNode(YAML::Node node, const std::vector& trace); void SetSystemViewNode(YAML::Node node, const SystemViewItem& systemView); }; @@ -189,7 +190,8 @@ void ProjMgrCbuildRun::SetDebuggerNode(YAML::Node node, const DebuggerType& debu } SetNodeValue(node[YAML_START_PNAME], debugger.startPname); SetGdbServerNode(node[YAML_GDBSERVER], debugger.gdbserver); - SetTelnetNode(node[YAML_TELNET], debugger.telnet); + SetStdioNode(node[YAML_STDIO], debugger.stdio); + SetRttNode(node[YAML_RTT], debugger.rtt); SetTraceNode(node[YAML_TRACE], debugger.trace); SetSystemViewNode(node[YAML_SYSTEMVIEW], debugger.systemView); SetDeviceSettingsNode(node[YAML_DEVICE_SETTINGS], debugger.deviceSettings); @@ -212,16 +214,42 @@ void ProjMgrCbuildRun::SetGdbServerNode(YAML::Node node, const std::vector& telnet) { - for (const auto& [pname, item] : telnet) { - YAML::Node telnetNode; - SetNodeValue(telnetNode[YAML_MODE], item.mode); - SetNodeValue(telnetNode[YAML_PNAME], pname); - telnetNode[YAML_PORT] = item.ullPort; +void ProjMgrCbuildRun::SetStdioNode(YAML::Node node, const std::map& stdio) { + for (const auto& [pname, item] : stdio) { + YAML::Node stdioNode; + SetNodeValue(stdioNode[YAML_MODE], item.mode); + SetNodeValue(stdioNode[YAML_PNAME], pname); + stdioNode[YAML_PORT] = item.ullPort; if (!item.file.empty()) { - SetNodeValue(telnetNode[YAML_FILE], FormatPath(item.file, m_directory)); + SetNodeValue(stdioNode[YAML_FILE], FormatPath(item.file, m_directory)); } - node.push_back(telnetNode); + if (!item.fileIn.empty()) { + SetNodeValue(stdioNode[YAML_FILE_IN], FormatPath(item.fileIn, m_directory)); + } + if (!item.fileOut.empty()) { + SetNodeValue(stdioNode[YAML_FILE_OUT], FormatPath(item.fileOut, m_directory)); + } + node.push_back(stdioNode); + } +} + +void ProjMgrCbuildRun::SetRttNode(YAML::Node node, const std::vector& rtt) { + for (const auto& item : rtt) { + YAML::Node rttNode(YAML::NodeType::Map); + SetCustomNodes(rttNode, item.custom); + rttNode[YAML_CHANNEL] = YAML::Node(YAML::NodeType::Sequence); + for (const auto& channel : item.channels) { + YAML::Node channelNode(YAML::NodeType::Map); + SetCustomNodes(channelNode, channel.custom); + if (!channel.fileIn.empty()) { + SetNodeValue(channelNode[YAML_FILE_IN], FormatPath(channel.fileIn, m_directory)); + } + if (!channel.fileOut.empty()) { + SetNodeValue(channelNode[YAML_FILE_OUT], FormatPath(channel.fileOut, m_directory)); + } + rttNode[YAML_CHANNEL].push_back(channelNode); + } + node.push_back(rttNode); } } diff --git a/tools/projmgr/src/ProjMgrRunDebug.cpp b/tools/projmgr/src/ProjMgrRunDebug.cpp index e3d3f88cd..a9de31d56 100644 --- a/tools/projmgr/src/ProjMgrRunDebug.cpp +++ b/tools/projmgr/src/ProjMgrRunDebug.cpp @@ -471,81 +471,90 @@ void ProjMgrRunDebug::CollectDebuggerSettings(const ContextItem& context, const } } - // collect telnet options - CollectTelnetOptions(context, adapter, pnames); + // collect stdio options + CollectStdioOptions(context, adapter, pnames); // collect system view options CollectSystemViewOptions(context.debugger.systemView); // merge custom options ProjMgrUtils::MergeCustomItems(context.debugger.custom, m_runDebug.debugger.custom); - if (!context.debugger.trace.empty()) { + if (!context.debugger.trace.empty() || !context.debugger.rtt.empty()) { auto& custom = m_runDebug.debugger.custom.map; - custom.erase(remove_if(custom.begin(), custom.end(), [](const auto& item) { - return item.first == YAML_TRACE; + custom.erase(remove_if(custom.begin(), custom.end(), [&](const auto& item) { + return (item.first == YAML_TRACE && !context.debugger.trace.empty()) || + (item.first == YAML_RTT && !context.debugger.rtt.empty()); }), custom.end()); } } -void ProjMgrRunDebug::CollectTelnetOptions(const ContextItem& context, DebugAdapterItem& adapter, +void ProjMgrRunDebug::CollectStdioOptions(const ContextItem& context, DebugAdapterItem& adapter, const std::map& pnames) { - if (!context.debugger.telnet.empty() || adapter.defaults.telnet.active) { + if (!context.debugger.stdio.empty() || adapter.defaults.stdio.active) { set usedPorts; const string fileBase = context.directories.cprj + "/" + context.directories.outBaseDir + "/" + m_runDebug.solutionName + "+" + m_runDebug.targetType; // get values from user definitions - for (const auto& [pname, value] : context.debugger.telnet) { + for (const auto& [pname, value] : context.debugger.stdio) { if (pnames.size() > 1 && value.pname.empty()) { - ProjMgrLogger::Get().Warn("'telnet:' pname is required (multicore device)"); + ProjMgrLogger::Get().Warn("'stdio:' pname is required (multicore device)"); continue; } if (pnames.find(pname) == pnames.end()) { ProjMgrLogger::Get().Warn("pname '" + pname + "' does not match any device pname"); continue; } - m_runDebug.debugger.telnet[pname] = { value }; + m_runDebug.debugger.stdio[pname] = { value }; if (!value.port.empty()) { - m_runDebug.debugger.telnet[pname].ullPort = RteUtils::StringToULL(value.port); - usedPorts.insert(m_runDebug.debugger.telnet[pname].ullPort); + m_runDebug.debugger.stdio[pname].ullPort = RteUtils::StringToULL(value.port); + usedPorts.insert(m_runDebug.debugger.stdio[pname].ullPort); } if (value.mode.empty()) { - m_runDebug.debugger.telnet[pname].mode = adapter.defaults.telnet.mode.empty() ? "off" : adapter.defaults.telnet.mode; - } - if (value.mode == "file" && value.file.empty()) { - m_runDebug.debugger.telnet[pname].file = fileBase + (pname.empty() ? "" : '.' + pname); + m_runDebug.debugger.stdio[pname].mode = adapter.defaults.stdio.mode.empty() ? "off" : adapter.defaults.stdio.mode; } } - // active flag: enable telnet options for all cores - if (adapter.defaults.telnet.active) { + // active flag: enable stdio options for all cores + if (adapter.defaults.stdio.active) { for (const auto& [pname, _] : pnames) { - auto& telnet = m_runDebug.debugger.telnet[pname]; - if (telnet.mode.empty()) { - telnet.mode = adapter.defaults.telnet.mode.empty() ? "off" : adapter.defaults.telnet.mode; + auto& stdio = m_runDebug.debugger.stdio[pname]; + if (stdio.mode.empty()) { + stdio.mode = adapter.defaults.stdio.mode.empty() ? "off" : adapter.defaults.stdio.mode; + } + } + } + for (auto& [pname, stdio] : m_runDebug.debugger.stdio) { + if (stdio.mode == "file" && stdio.file.empty()) { + const auto base = fileBase + (pname.empty() ? "" : '.' + pname); + if (stdio.fileIn.empty()) { + stdio.fileIn = base + ".in"; + } + if (stdio.fileOut.empty()) { + stdio.fileOut = base + ".out"; } } } // port number handling - unsigned long long port = adapter.defaults.telnet.port.empty() ? 0 : RteUtils::StringToULL(adapter.defaults.telnet.port); - if (m_runDebug.debugger.telnet.find(m_runDebug.debugger.startPname) != m_runDebug.debugger.telnet.end()) { + unsigned long long port = adapter.defaults.stdio.port.empty() ? 0 : RteUtils::StringToULL(adapter.defaults.stdio.port); + if (m_runDebug.debugger.stdio.find(m_runDebug.debugger.startPname) != m_runDebug.debugger.stdio.end()) { // add primary processor port first - auto& start = m_runDebug.debugger.telnet[m_runDebug.debugger.startPname]; + auto& start = m_runDebug.debugger.stdio[m_runDebug.debugger.startPname]; // set next available port - SetTelnetPort(start, port, usedPorts); + SetStdioPort(start, port, usedPorts); // set starting port for other processors port = start.ullPort; } - for (auto& [pname, telnet] : m_runDebug.debugger.telnet) { + for (auto& [pname, stdio] : m_runDebug.debugger.stdio) { // add ports for other processors if (pname != m_runDebug.debugger.startPname) { // set next available port - SetTelnetPort(telnet, port, usedPorts); + SetStdioPort(stdio, port, usedPorts); } } } } -void ProjMgrRunDebug::SetTelnetPort(TelnetOptionsItem& item, unsigned long long& port, std::set& usedPorts) { +void ProjMgrRunDebug::SetStdioPort(StdioOptionsItem& item, unsigned long long& port, std::set& usedPorts) { // only assign a port number if it has not been already specified if (item.port.empty()) { while (usedPorts.find(port) != usedPorts.end()) { diff --git a/tools/projmgr/src/ProjMgrWorker.cpp b/tools/projmgr/src/ProjMgrWorker.cpp index ce8bddb75..74d9715a9 100644 --- a/tools/projmgr/src/ProjMgrWorker.cpp +++ b/tools/projmgr/src/ProjMgrWorker.cpp @@ -2797,16 +2797,31 @@ bool ProjMgrWorker::ProcessDebuggers(ContextItem& context) { } context.debugger.startPname = m_activeTargetSet.debugger.startPname; context.debugger.deviceSettings = m_activeTargetSet.debugger.deviceSettings; - for (auto telnet : m_activeTargetSet.debugger.telnet) { - if (!telnet.file.empty()) { - if (!ProcessSequenceRelative(context, telnet.file, context.csolution->directory, false)) { + const auto processFile = [&](std::string& path) { + if (path.empty()) { + return true; + } + if (!ProcessSequenceRelative(context, path, context.csolution->directory, false)) { + return false; + } + if (RteFsUtils::IsRelative(path)) { + RteFsUtils::NormalizePath(path, context.directories.cprj); + } + return true; + }; + for (auto stdio : m_activeTargetSet.debugger.stdio) { + if (!processFile(stdio.file) || !processFile(stdio.fileIn) || !processFile(stdio.fileOut)) { + return false; + } + context.debugger.stdio[stdio.pname] = { stdio }; + } + for (auto rtt : m_activeTargetSet.debugger.rtt) { + for (auto& channel : rtt.channels) { + if (!processFile(channel.fileIn) || !processFile(channel.fileOut)) { return false; } - if (RteFsUtils::IsRelative(telnet.file)) { - RteFsUtils::NormalizePath(telnet.file, context.directories.cprj); - } } - context.debugger.telnet[telnet.pname] = { telnet }; + context.debugger.rtt.push_back(rtt); } for (auto trace : m_activeTargetSet.debugger.trace) { if (!trace.file.empty()) { diff --git a/tools/projmgr/src/ProjMgrYamlParser.cpp b/tools/projmgr/src/ProjMgrYamlParser.cpp index 0a0873a60..71a85f841 100644 --- a/tools/projmgr/src/ProjMgrYamlParser.cpp +++ b/tools/projmgr/src/ProjMgrYamlParser.cpp @@ -633,16 +633,36 @@ void ProjMgrYamlParser::ParseExecutes(const YAML::Node& parent, const string& fi } } -void ProjMgrYamlParser::ParseTelnet(const YAML::Node& parent, const std::string& file, std::vector& telnet) { - if (parent[YAML_TELNET].IsDefined()) { - const YAML::Node& telnetNode = parent[YAML_TELNET]; - for (const auto& telnetEntry : telnetNode) { - TelnetItem telnetItem; - ParseString(telnetEntry, YAML_MODE, telnetItem.mode); - ParseString(telnetEntry, YAML_PORT, telnetItem.port); - ParseString(telnetEntry, YAML_FILE, telnetItem.file); - ParseString(telnetEntry, YAML_PNAME, telnetItem.pname); - telnet.push_back(telnetItem); +void ProjMgrYamlParser::ParseStdio(const YAML::Node& parent, const std::string& file, std::vector& stdio) { + // The current spelling wins when both it and the legacy alias are present. + const auto& stdioNode = parent[YAML_STDIO].IsDefined() ? parent[YAML_STDIO] : parent[YAML_TELNET]; + if (stdioNode.IsDefined()) { + for (const auto& stdioEntry : stdioNode) { + StdioItem stdioItem; + ParseString(stdioEntry, YAML_MODE, stdioItem.mode); + ParseString(stdioEntry, YAML_PORT, stdioItem.port); + ParseString(stdioEntry, YAML_FILE, stdioItem.file); + ParseString(stdioEntry, YAML_FILE_IN, stdioItem.fileIn); + ParseString(stdioEntry, YAML_FILE_OUT, stdioItem.fileOut); + ParseString(stdioEntry, YAML_PNAME, stdioItem.pname); + stdio.push_back(stdioItem); + } + } +} + +void ProjMgrYamlParser::ParseRtt(const YAML::Node& parent, const std::string& file, std::vector& rtt) { + if (parent[YAML_RTT].IsDefined()) { + for (const auto& rttEntry : parent[YAML_RTT]) { + RttItem item; + ParseCustom(rttEntry, { YAML_CHANNEL }, item.custom); + for (const auto& channelEntry : rttEntry[YAML_CHANNEL]) { + RttChannelItem channel; + ParseString(channelEntry, YAML_FILE_IN, channel.fileIn); + ParseString(channelEntry, YAML_FILE_OUT, channel.fileOut); + ParseCustom(channelEntry, { YAML_FILE_IN, YAML_FILE_OUT }, channel.custom); + item.channels.push_back(channel); + } + rtt.push_back(item); } } } @@ -680,10 +700,11 @@ void ProjMgrYamlParser::ParseDebugger(const YAML::Node& parent, const string& fi ParsePortablePath(debuggerNode, file, YAML_DBGCONF, debugger.dbgconf); ParseMapOfStrings(debuggerNode, YAML_DEVICE_SETTINGS, debugger.deviceSettings); ParseString(debuggerNode, YAML_START_PNAME, debugger.startPname); - ParseTelnet(debuggerNode, file, debugger.telnet); + ParseStdio(debuggerNode, file, debugger.stdio); + ParseRtt(debuggerNode, file, debugger.rtt); ParseTrace(debuggerNode, file, debugger.trace); - ParseSystemView(debuggerNode, file, debugger.systemView); - ParseCustom(debuggerNode, { YAML_NAME, YAML_PROTOCOL, YAML_CLOCK, YAML_DBGCONF, YAML_DEVICE_SETTINGS, YAML_START_PNAME, YAML_TELNET, YAML_TRACE, YAML_SYSTEMVIEW }, debugger.custom); + ParseSystemView(debuggerNode, file, debugger.systemView); + ParseCustom(debuggerNode, { YAML_NAME, YAML_PROTOCOL, YAML_CLOCK, YAML_DBGCONF, YAML_DEVICE_SETTINGS, YAML_START_PNAME, YAML_STDIO, YAML_TELNET, YAML_RTT, YAML_TRACE, YAML_SYSTEMVIEW }, debugger.custom); } } @@ -702,15 +723,15 @@ void ProjMgrYamlParser::ParseDebugDefaults(const YAML::Node& parent, const strin ParseString(gdbserverNode, YAML_PORT, defaults.gdbserver.port); defaults.gdbserver.active = gdbserverNode[YAML_ACTIVE].IsDefined(); } - if (defaultsNode[YAML_TELNET].IsDefined()) { - const YAML::Node& telnetNode = defaultsNode[YAML_TELNET]; - ParseString(telnetNode, YAML_PORT, defaults.telnet.port); - ParseString(telnetNode, YAML_MODE, defaults.telnet.mode); - defaults.telnet.active = telnetNode[YAML_ACTIVE].IsDefined(); + const auto& stdioNode = defaultsNode[YAML_STDIO].IsDefined() ? defaultsNode[YAML_STDIO] : defaultsNode[YAML_TELNET]; + if (stdioNode.IsDefined()) { + ParseString(stdioNode, YAML_PORT, defaults.stdio.port); + ParseString(stdioNode, YAML_MODE, defaults.stdio.mode); + defaults.stdio.active = stdioNode[YAML_ACTIVE].IsDefined(); } ParseString(defaultsNode, YAML_PROTOCOL, defaults.protocol); ParseNumber(defaultsNode, file, YAML_CLOCK, defaults.clock); - ParseCustom(defaultsNode, { YAML_GDBSERVER, YAML_TELNET, YAML_SYSTEMVIEW, YAML_PROTOCOL, YAML_CLOCK }, defaults.custom); + ParseCustom(defaultsNode, { YAML_GDBSERVER, YAML_STDIO, YAML_TELNET, YAML_SYSTEMVIEW, YAML_PROTOCOL, YAML_CLOCK }, defaults.custom); } } diff --git a/tools/projmgr/test/data/TestRunDebug/stdio.csolution.yml b/tools/projmgr/test/data/TestRunDebug/stdio.csolution.yml new file mode 100644 index 000000000..bf3925145 --- /dev/null +++ b/tools/projmgr/test/data/TestRunDebug/stdio.csolution.yml @@ -0,0 +1,46 @@ +solution: + compiler: AC6 + packs: + - pack: ARM::RteTest_DFP + target-types: + - type: SingleCore + device: RteTest_ARMCM0 + target-set: + - set: + debugger: + name: CMSIS-DAP + stdio: + - mode: file + file-in: $OutDir(telnet)$/stdio.in + file-out: captures/stdio.out + rtt: + - control-block: + address: 0x20000000 + size: 0x10000 + auto-detect: false + channel: + - number: 0 + mode: stdio + - number: 1 + mode: server + port: 4453 + - number: 2 + mode: file + file-in: ../rtt2.in + file-out: $OutDir(telnet)$/rtt2.out + - number: 3 + mode: file + - number: 4 + mode: systemview + - number: 5 + mode: systemview-server + port: 4454 + - pname: Core1 + channel: + - number: 0 + mode: file + file-out: captures/Core1.out + images: + - project-context: telnet + projects: + - project: telnet.cproject.yml diff --git a/tools/projmgr/test/src/ProjMgrSchemaCheckerUnitTests.cpp b/tools/projmgr/test/src/ProjMgrSchemaCheckerUnitTests.cpp index 438bb327e..24a3edef8 100644 --- a/tools/projmgr/test/src/ProjMgrSchemaCheckerUnitTests.cpp +++ b/tools/projmgr/test/src/ProjMgrSchemaCheckerUnitTests.cpp @@ -11,6 +11,7 @@ #include "CrossPlatformUtils.h" #include "RteFsUtils.h" #include "gtest/gtest.h" +#include "yaml-cpp/yaml.h" #include @@ -694,3 +695,65 @@ TEST_F(ProjMgrSchemaCheckerUnitTests, SchemaCheck_CbuildRun) { EXPECT_TRUE(errList.end() != errItr); } } + +TEST_F(ProjMgrSchemaCheckerUnitTests, SchemaCheck_StdioRttFiles) { + const auto debugger = YAML::Load(R"( +name: CMSIS-DAP +stdio: + - mode: file + file-in: ../stdio.in + file-out: ../stdio.out +rtt: + - channel: + - number: 2 + mode: file + file-in: ../rtt2.in + file-out: ../rtt2.out + - number: 3 + mode: file +)"); + for (const auto& extension : { "csolution", "cbuild-run" }) { + YAML::Node root; + YAML::Node debugNode; + if (string(extension) == "csolution") { + root = YAML::Load("solution: {target-types: [{type: SingleCore, target-set: [{set: null}]}]}"); + root["solution"]["target-types"][0]["target-set"][0]["debugger"] = YAML::Clone(debugger); + debugNode.reset(root["solution"]["target-types"][0]["target-set"][0]["debugger"]); + } + else { + root = YAML::Load("cbuild-run: {generated-by: test, output: [{file: test.elf, type: elf, load: image+symbols}]}"); + root["cbuild-run"]["debugger"] = YAML::Clone(debugger); + debugNode.reset(root["cbuild-run"]["debugger"]); + } + const string filename = testoutput_folder + "/stdio-rtt." + extension + ".yml"; + const auto validate = [&]() { + stringstream content; + content << root; + EXPECT_TRUE(RteFsUtils::CreateTextFile(filename, content.str())); + return Validate(filename); + }; + EXPECT_TRUE(validate()); + debugNode["telnet"] = YAML::Clone(debugNode["stdio"]); + debugNode.remove("stdio"); + EXPECT_TRUE(validate()); + debugNode["telnet"][0]["mode"] = "rtt"; + EXPECT_FALSE(validate()); + debugNode["telnet"][0]["mode"] = "file"; + for (const auto& key : { "file-in", "file-out" }) { + debugNode["telnet"][0][key] = 123; + EXPECT_FALSE(validate()); + debugNode["telnet"][0][key] = "capture"; + debugNode["rtt"][0]["channel"][0][key] = 123; + EXPECT_FALSE(validate()); + debugNode["rtt"][0]["channel"][0][key] = "capture"; + } + debugNode["stdio"] = YAML::Clone(debugNode["telnet"]); + debugNode.remove("telnet"); + debugNode["stdio"][0]["mode"] = "rtt"; + EXPECT_FALSE(validate()); + debugNode["stdio"][0]["mode"] = "file"; + debugNode["rtt"][0]["channel"][0]["mode"] = "invalid"; + EXPECT_FALSE(validate()); + EXPECT_TRUE(RteFsUtils::RemoveFile(filename)); + } +} diff --git a/tools/projmgr/test/src/ProjMgrUnitTests.cpp b/tools/projmgr/test/src/ProjMgrUnitTests.cpp index 44831b194..16aa8e865 100644 --- a/tools/projmgr/test/src/ProjMgrUnitTests.cpp +++ b/tools/projmgr/test/src/ProjMgrUnitTests.cpp @@ -7416,6 +7416,112 @@ TEST_F(ProjMgrUnitTests, TestRunDebugTrace) { EXPECT_TRUE(RteFsUtils::RemoveFile(invalidSolution)); } +TEST_F(ProjMgrUnitTests, TestRunDebugStdioRttFiles) { + const string csolution = testinput_folder + "/TestRunDebug/stdio.csolution.yml"; + for (const auto& output : { testinput_folder + "/TestRunDebug", testoutput_folder }) { + StdStreamRedirect streamRedirect; + char* argv[7] = { nullptr, (char*)"convert", (char*)csolution.c_str(), + (char*)"--active", (char*)"SingleCore", (char*)"--output", (char*)output.c_str() }; + ASSERT_EQ(0, RunProjMgr(7, argv, m_envp)) << streamRedirect.GetErrorString(); + const auto root = YAML::LoadFile(output + "/out/stdio+SingleCore.cbuild-run.yml"); + const auto debugger = root["cbuild-run"]["debugger"]; + EXPECT_FALSE(debugger["telnet"].IsDefined()); + const auto stdio = debugger["stdio"][0]; + EXPECT_EQ("file", stdio["mode"].as()); + EXPECT_EQ(4444, stdio["port"].as()); + EXPECT_EQ("telnet/SingleCore/stdio.in", stdio["file-in"].as()); + EXPECT_EQ(RteFsUtils::RelativePath(testinput_folder + "/TestRunDebug/captures/stdio.out", output + "/out"), + stdio["file-out"].as()); + EXPECT_FALSE(stdio["file"].IsDefined()); + const auto rtt = debugger["rtt"]; + ASSERT_EQ(2, rtt.size()); + EXPECT_EQ(0x20000000, rtt[0]["control-block"]["address"].as()); + EXPECT_EQ(0x10000, rtt[0]["control-block"]["size"].as()); + EXPECT_FALSE(rtt[0]["control-block"]["auto-detect"].as()); + const auto channels = rtt[0]["channel"]; + ASSERT_EQ(6, channels.size()); + EXPECT_EQ("stdio", channels[0]["mode"].as()); + EXPECT_EQ(4453, channels[1]["port"].as()); + EXPECT_EQ(2, channels[2]["number"].as()); + EXPECT_EQ("file", channels[2]["mode"].as()); + EXPECT_EQ(RteFsUtils::RelativePath(testinput_folder + "/rtt2.in", output + "/out"), + channels[2]["file-in"].as()); + EXPECT_EQ("telnet/SingleCore/rtt2.out", channels[2]["file-out"].as()); + // Omitted RTT paths are defaulted by the debugger. + EXPECT_FALSE(channels[3]["file-in"].IsDefined()); + EXPECT_FALSE(channels[3]["file-out"].IsDefined()); + EXPECT_EQ("systemview", channels[4]["mode"].as()); + EXPECT_EQ("systemview-server", channels[5]["mode"].as()); + EXPECT_EQ(4454, channels[5]["port"].as()); + EXPECT_EQ("Core1", rtt[1]["pname"].as()); + EXPECT_EQ(RteFsUtils::RelativePath(testinput_folder + "/TestRunDebug/captures/Core1.out", output + "/out"), + rtt[1]["channel"][0]["file-out"].as()); + } + + // Invalid access sequences must fail for either service and direction. + for (const auto& service : { "stdio", "rtt" }) { + for (const auto& key : { "file-in", "file-out" }) { + auto root = YAML::LoadFile(csolution); + auto debugger = root["solution"]["target-types"][0]["target-set"][0]["debugger"]; + if (string(service) == "stdio") { + debugger[service][0][key] = "$Unknown$/capture"; + } + else { + debugger[service][0]["channel"][2][key] = "$Unknown$/capture"; + } + const string invalidSolution = testinput_folder + "/TestRunDebug/stdio-invalid.csolution.yml"; + stringstream content; + content << root; + ASSERT_TRUE(RteFsUtils::CreateTextFile(invalidSolution, content.str())); + StdStreamRedirect streamRedirect; + char* argv[5] = { nullptr, (char*)"convert", (char*)invalidSolution.c_str(), + (char*)"--active", (char*)"SingleCore" }; + EXPECT_EQ(1, RunProjMgr(5, argv, m_envp)); + EXPECT_NE(string::npos, streamRedirect.GetErrorString().find("unknown access sequence: 'Unknown'")); + EXPECT_TRUE(RteFsUtils::RemoveFile(invalidSolution)); + } + } +} + +TEST_F(ProjMgrUnitTests, TestRunDebugStdioDefaults) { + const string csolution = testinput_folder + "/TestRunDebug/stdio-defaults.csolution.yml"; + auto root = YAML::LoadFile(testinput_folder + "/TestRunDebug/stdio.csolution.yml"); + root["solution"]["target-types"][0]["target-set"][0]["debugger"].remove("stdio"); + stringstream content; + content << root; + ASSERT_TRUE(RteFsUtils::CreateTextFile(csolution, content.str())); + const string adapterPath = etc_folder + "/debug-adapters.yml"; + auto adapters = YAML::LoadFile(adapterPath); + for (auto adapter : adapters["debug-adapters"]) { + if (adapter["name"].as() == "CMSIS-DAP@pyOCD") { + adapter["defaults"].remove("telnet"); + adapter["defaults"]["stdio"] = YAML::Load("{active: null, mode: file, port: 6000}"); + } + } + const string backup = RteFsUtils::BackupFile(adapterPath); + ASSERT_FALSE(backup.empty()); + stringstream adapterContent; + adapterContent << adapters; + const bool written = RteFsUtils::CreateTextFile(adapterPath, adapterContent.str()); + StdStreamRedirect streamRedirect; + char* argv[5] = { nullptr, (char*)"convert", (char*)csolution.c_str(), + (char*)"--active", (char*)"SingleCore" }; + const auto result = written ? RunProjMgr(5, argv, m_envp) : -1; + error_code ec; + fs::copy_file(backup, adapterPath, fs::copy_options::overwrite_existing, ec); + ASSERT_FALSE(ec) << ec.message(); + EXPECT_TRUE(RteFsUtils::RemoveFile(backup)); + EXPECT_TRUE(RteFsUtils::RemoveFile(csolution)); + ASSERT_TRUE(written); + ASSERT_EQ(0, result) << streamRedirect.GetErrorString(); + const auto cbuildrun = YAML::LoadFile(testinput_folder + "/TestRunDebug/out/stdio-defaults+SingleCore.cbuild-run.yml"); + const auto stdio = cbuildrun["cbuild-run"]["debugger"]["stdio"][0]; + EXPECT_EQ("file", stdio["mode"].as()); + EXPECT_EQ(6000, stdio["port"].as()); + EXPECT_EQ("stdio-defaults+SingleCore.in", stdio["file-in"].as()); + EXPECT_EQ("stdio-defaults+SingleCore.out", stdio["file-out"].as()); +} + TEST_F(ProjMgrUnitTests, TestRunDebugTelnet) { char* argv[5]; const string& csolution = testinput_folder + "/TestRunDebug/telnet.csolution.yml"; @@ -7428,7 +7534,7 @@ TEST_F(ProjMgrUnitTests, TestRunDebugTelnet) { EXPECT_EQ(0, RunProjMgr(5, argv, m_envp)); stringstream sstream0, sstreamRTT, sstreamSystemView; const YAML::Node& cbuildrun0 = YAML::LoadFile(testinput_folder + "/TestRunDebug/out/telnet+SingleCore.cbuild-run.yml"); - sstream0 << cbuildrun0["cbuild-run"]["debugger"]["telnet"]; + sstream0 << cbuildrun0["cbuild-run"]["debugger"]["stdio"]; EXPECT_EQ( R"(- mode: file port: 4444 @@ -7457,7 +7563,7 @@ auto-stop: false)", sstreamSystemView.str()); EXPECT_EQ(0, RunProjMgr(5, argv, m_envp)); const YAML::Node& cbuildrun1 = YAML::LoadFile(testinput_folder + "/TestRunDebug/out/telnet+DualCore.cbuild-run.yml"); stringstream sstream1; - sstream1 << cbuildrun1["cbuild-run"]["debugger"]["telnet"]; + sstream1 << cbuildrun1["cbuild-run"]["debugger"]["stdio"]; EXPECT_EQ( R"(- mode: server pname: cm0_core0 @@ -7471,7 +7577,7 @@ R"(- mode: server EXPECT_EQ(0, RunProjMgr(5, argv, m_envp)); const YAML::Node& cbuildrun2 = YAML::LoadFile(testinput_folder + "/TestRunDebug/out/telnet+DualCore.cbuild-run.yml"); stringstream sstream2; - sstream2 << cbuildrun2["cbuild-run"]["debugger"]["telnet"]; + sstream2 << cbuildrun2["cbuild-run"]["debugger"]["stdio"]; EXPECT_EQ( R"(- mode: monitor pname: cm0_core0 @@ -7479,14 +7585,15 @@ R"(- mode: monitor - mode: file pname: cm0_core1 port: 5555 - file: telnet+DualCore.cm0_core1)", sstream2.str()); + file-in: telnet+DualCore.cm0_core1.in + file-out: telnet+DualCore.cm0_core1.out)", sstream2.str()); // dual core with jlink and no telnet argv[4] = (char*)"DualCore@JLinkNoTelnet"; EXPECT_EQ(0, RunProjMgr(5, argv, m_envp)); const YAML::Node& cbuildrun3 = YAML::LoadFile(testinput_folder + "/TestRunDebug/out/telnet+DualCore.cbuild-run.yml"); stringstream sstream3; - sstream3 << cbuildrun3["cbuild-run"]["debugger"]["telnet"]; + sstream3 << cbuildrun3["cbuild-run"]["debugger"]["stdio"]; EXPECT_EQ( R"(- mode: off pname: cm0_core0 @@ -7500,7 +7607,7 @@ R"(- mode: off EXPECT_EQ(0, RunProjMgr(5, argv, m_envp)); const YAML::Node& cbuildrun4 = YAML::LoadFile(testinput_folder + "/TestRunDebug/out/telnet+DualCore.cbuild-run.yml"); stringstream sstream4; - sstream4 << cbuildrun4["cbuild-run"]["debugger"]["telnet"]; + sstream4 << cbuildrun4["cbuild-run"]["debugger"]["stdio"]; EXPECT_EQ( R"(- mode: monitor pname: cm0_core0 @@ -7514,7 +7621,7 @@ R"(- mode: off argv[4] = (char*)"DualCore@Warnings"; EXPECT_EQ(0, RunProjMgr(5, argv, m_envp)); string expected = "\ -warning csolution: \\'telnet:\\' pname is required \\(multicore device\\)\n\ +warning csolution: \\'stdio:\\' pname is required \\(multicore device\\)\n\ warning csolution: pname \\'unknown\\' does not match any device pname\n\ "; string errStr = streamRedirect.GetErrorString(); @@ -8131,7 +8238,7 @@ TEST_F(ProjMgrUnitTests, TargetSetDependencies) { EXPECT_EQ("project/CM4/project.bin", cbuildRun["cbuild-run"]["output"][2]["file"].as()); EXPECT_EQ("project2/CM4/project2.bin", cbuildRun["cbuild-run"]["output"][3]["file"].as()); EXPECT_EQ("../RteTest_ARMCM4_NOFP.dbgconf", cbuildRun["cbuild-run"]["debugger"]["dbgconf"].as()); - EXPECT_EQ("project2/CM4/telnet.log", cbuildRun["cbuild-run"]["debugger"]["telnet"][0]["file"].as()); + EXPECT_EQ("project2/CM4/telnet.log", cbuildRun["cbuild-run"]["debugger"]["stdio"][0]["file"].as()); // ensure dependencies are not set const YAML::Node& cbuildIdx = YAML::LoadFile(testinput_folder + "/TestTargetSet/cross-dependency.cbuild-idx.yml"); diff --git a/tools/projmgr/test/src/ProjMgrYamlParserUnitTest.cpp b/tools/projmgr/test/src/ProjMgrYamlParserUnitTest.cpp index 1b570a26f..11bc01368 100644 --- a/tools/projmgr/test/src/ProjMgrYamlParserUnitTest.cpp +++ b/tools/projmgr/test/src/ProjMgrYamlParserUnitTest.cpp @@ -104,3 +104,77 @@ TEST_F(ProjMgrYamlParserUnitTests, ValidateCbuildSet) { invalidRoot["processor"] = "invalid"; EXPECT_FALSE(ValidateCbuildSet(cbuildSetFile, invalidRoot)); } + +TEST_F(ProjMgrYamlParserUnitTests, ParseStdioAliases) { + for (const auto& key : { "stdio", "telnet" }) { + const auto node = YAML::Load(string("debugger:\n ") + key + R"(: + - mode: file + port: 4444 + pname: Core0 + file: legacy.txt + file-in: explicit.in + file-out: explicit.out + - mode: file + file-out: explicit.out + - mode: file + file: capture.txt +)"); + DebuggerItem debugger; + ParseDebugger(node, "test.csolution.yml", debugger); + ASSERT_EQ(3, debugger.stdio.size()); + EXPECT_EQ("file", debugger.stdio[0].mode); + EXPECT_EQ("4444", debugger.stdio[0].port); + EXPECT_EQ("Core0", debugger.stdio[0].pname); + EXPECT_EQ("legacy.txt", debugger.stdio[0].file); + EXPECT_EQ("explicit.in", debugger.stdio[0].fileIn); + EXPECT_EQ("explicit.out", debugger.stdio[0].fileOut); + EXPECT_TRUE(debugger.stdio[1].fileIn.empty()); + EXPECT_EQ("explicit.out", debugger.stdio[1].fileOut); + EXPECT_EQ("capture.txt", debugger.stdio[2].file); + EXPECT_TRUE(debugger.stdio[2].fileIn.empty()); + EXPECT_TRUE(debugger.stdio[2].fileOut.empty()); + EXPECT_TRUE(debugger.custom.map.empty()); + + DebugAdapterDefaultsItem defaults; + ParseDebugDefaults(YAML::Load(string("defaults:\n ") + key + R"(: + active: + port: 4444 + mode: file +)"), "debug-adapters.yml", defaults); + EXPECT_TRUE(defaults.stdio.active); + EXPECT_EQ("4444", defaults.stdio.port); + EXPECT_EQ("file", defaults.stdio.mode); + EXPECT_TRUE(defaults.custom.map.empty()); + } +} + +TEST_F(ProjMgrYamlParserUnitTests, ParseStdioPrecedence) { + const auto node = YAML::Load(R"( +debugger: + stdio: + - mode: console + telnet: + - mode: file +)"); + DebuggerItem debugger; + ParseDebugger(node, "test.csolution.yml", debugger); + ASSERT_EQ(1, debugger.stdio.size()); + EXPECT_EQ("console", debugger.stdio[0].mode); + EXPECT_TRUE(debugger.custom.map.empty()); + + DebugAdapterDefaultsItem defaults; + ParseDebugDefaults(YAML::Load(R"( +defaults: + stdio: + mode: console + port: 5555 + telnet: + active: + mode: file + port: 4444 +)"), "debug-adapters.yml", defaults); + EXPECT_EQ("console", defaults.stdio.mode); + EXPECT_EQ("5555", defaults.stdio.port); + EXPECT_FALSE(defaults.stdio.active); + EXPECT_TRUE(defaults.custom.map.empty()); +}