Add output type to DAP `output` events

This commit is contained in:
Ricardo Subtil 2024-03-14 10:53:30 +00:00
parent f2045ba822
commit b6d1204186
5 changed files with 12 additions and 11 deletions

View File

@ -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;

View File

@ -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;
};

View File

@ -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<Ref<DAPeer>>::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) {

View File

@ -86,7 +86,7 @@ private:
void on_client_disconnected(const Ref<DAPeer> &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);

View File

@ -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<float> 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")));