From b6d12041861960804554a23b3d7820c9f7772c3e Mon Sep 17 00:00:00 2001 From: Ricardo Subtil Date: Thu, 14 Mar 2024 10:53:30 +0000 Subject: [PATCH] Add output type to DAP `output` events --- editor/debugger/debug_adapter/debug_adapter_parser.cpp | 4 ++-- editor/debugger/debug_adapter/debug_adapter_parser.h | 3 ++- editor/debugger/debug_adapter/debug_adapter_protocol.cpp | 8 ++++---- editor/debugger/debug_adapter/debug_adapter_protocol.h | 4 ++-- editor/debugger/script_editor_debugger.cpp | 4 ++-- 5 files changed, 12 insertions(+), 11 deletions(-) diff --git a/editor/debugger/debug_adapter/debug_adapter_parser.cpp b/editor/debugger/debug_adapter/debug_adapter_parser.cpp index e8546810106..19757c8db75 100644 --- a/editor/debugger/debug_adapter/debug_adapter_parser.cpp +++ b/editor/debugger/debug_adapter/debug_adapter_parser.cpp @@ -600,12 +600,12 @@ Dictionary DebugAdapterParser::ev_continued() const { return event; } -Dictionary DebugAdapterParser::ev_output(const String &p_message) const { +Dictionary DebugAdapterParser::ev_output(const String &p_message, RemoteDebugger::MessageType p_type) const { Dictionary event = prepare_base_event(), body; event["event"] = "output"; event["body"] = body; - body["category"] = "stdout"; + body["category"] = (p_type == RemoteDebugger::MessageType::MESSAGE_TYPE_ERROR) ? "stderr" : "stdout"; body["output"] = p_message + "\r\n"; return event; diff --git a/editor/debugger/debug_adapter/debug_adapter_parser.h b/editor/debugger/debug_adapter/debug_adapter_parser.h index e5493a4b9f9..9860e964988 100644 --- a/editor/debugger/debug_adapter/debug_adapter_parser.h +++ b/editor/debugger/debug_adapter/debug_adapter_parser.h @@ -32,6 +32,7 @@ #define DEBUG_ADAPTER_PARSER_H #include "core/config/project_settings.h" +#include "core/debugger/remote_debugger.h" #include "debug_adapter_protocol.h" #include "debug_adapter_types.h" @@ -98,7 +99,7 @@ public: Dictionary ev_stopped_breakpoint(const int &p_id) const; Dictionary ev_stopped_step() const; Dictionary ev_continued() const; - Dictionary ev_output(const String &p_message) const; + Dictionary ev_output(const String &p_message, RemoteDebugger::MessageType p_type) const; Dictionary ev_custom_data(const String &p_msg, const Array &p_data) const; Dictionary ev_breakpoint(const DAP::Breakpoint &p_breakpoint, const bool &p_enabled) const; }; diff --git a/editor/debugger/debug_adapter/debug_adapter_protocol.cpp b/editor/debugger/debug_adapter/debug_adapter_protocol.cpp index 7417a3d8f73..d03df88b75d 100644 --- a/editor/debugger/debug_adapter/debug_adapter_protocol.cpp +++ b/editor/debugger/debug_adapter/debug_adapter_protocol.cpp @@ -763,8 +763,8 @@ void DebugAdapterProtocol::notify_continued() { reset_stack_info(); } -void DebugAdapterProtocol::notify_output(const String &p_message) { - Dictionary event = parser->ev_output(p_message); +void DebugAdapterProtocol::notify_output(const String &p_message, RemoteDebugger::MessageType p_type) { + Dictionary event = parser->ev_output(p_message, p_type); for (List>::Element *E = clients.front(); E; E = E->next()) { E->get()->res_queue.push_back(event); } @@ -828,8 +828,8 @@ void DebugAdapterProtocol::on_debug_stopped() { notify_terminated(); } -void DebugAdapterProtocol::on_debug_output(const String &p_message) { - notify_output(p_message); +void DebugAdapterProtocol::on_debug_output(const String &p_message, int p_type) { + notify_output(p_message, RemoteDebugger::MessageType(p_type)); } void DebugAdapterProtocol::on_debug_breaked(const bool &p_reallydid, const bool &p_can_debug, const String &p_reason, const bool &p_has_stackdump) { diff --git a/editor/debugger/debug_adapter/debug_adapter_protocol.h b/editor/debugger/debug_adapter/debug_adapter_protocol.h index fb1c533bbbf..caff0f9c7ff 100644 --- a/editor/debugger/debug_adapter/debug_adapter_protocol.h +++ b/editor/debugger/debug_adapter/debug_adapter_protocol.h @@ -86,7 +86,7 @@ private: void on_client_disconnected(const Ref &p_peer); void on_debug_paused(); void on_debug_stopped(); - void on_debug_output(const String &p_message); + void on_debug_output(const String &p_message, int p_type); void on_debug_breaked(const bool &p_reallydid, const bool &p_can_debug, const String &p_reason, const bool &p_has_stackdump); void on_debug_breakpoint_toggled(const String &p_path, const int &p_line, const bool &p_enabled); void on_debug_stack_dump(const Array &p_stack_dump); @@ -139,7 +139,7 @@ public: void notify_stopped_breakpoint(const int &p_id); void notify_stopped_step(); void notify_continued(); - void notify_output(const String &p_message); + void notify_output(const String &p_message, RemoteDebugger::MessageType p_type); void notify_custom_data(const String &p_msg, const Array &p_data); void notify_breakpoint(const DAP::Breakpoint &p_breakpoint, const bool &p_enabled); diff --git a/editor/debugger/script_editor_debugger.cpp b/editor/debugger/script_editor_debugger.cpp index 979834ebab2..2b880274f88 100644 --- a/editor/debugger/script_editor_debugger.cpp +++ b/editor/debugger/script_editor_debugger.cpp @@ -495,7 +495,7 @@ void ScriptEditorDebugger::_parse_message(const String &p_msg, uint64_t p_thread } break; } EditorNode::get_log()->add_message(output_strings[i], msg_type); - emit_signal(SNAME("output"), output_strings[i]); + emit_signal(SNAME("output"), output_strings[i], msg_type); } } else if (p_msg == "performance:profile_frame") { Vector frame_data; @@ -1757,7 +1757,7 @@ void ScriptEditorDebugger::_bind_methods() { ADD_SIGNAL(MethodInfo("remote_object_updated", PropertyInfo(Variant::INT, "id"))); ADD_SIGNAL(MethodInfo("remote_object_property_updated", PropertyInfo(Variant::INT, "id"), PropertyInfo(Variant::STRING, "property"))); ADD_SIGNAL(MethodInfo("remote_tree_updated")); - ADD_SIGNAL(MethodInfo("output")); + ADD_SIGNAL(MethodInfo("output", PropertyInfo(Variant::STRING, "msg"), PropertyInfo(Variant::INT, "level"))); ADD_SIGNAL(MethodInfo("stack_dump", PropertyInfo(Variant::ARRAY, "stack_dump"))); ADD_SIGNAL(MethodInfo("stack_frame_vars", PropertyInfo(Variant::INT, "num_vars"))); ADD_SIGNAL(MethodInfo("stack_frame_var", PropertyInfo(Variant::ARRAY, "data")));