Format remote printerr properly in script debugger output

Fixes #33324
This commit is contained in:
PouleyKetchoupp
2019-11-29 15:06:42 +01:00
parent 44a516986d
commit 83e376e731
3 changed files with 48 additions and 6 deletions

View File

@@ -382,8 +382,14 @@ void ScriptDebuggerRemote::_get_output() {
packet_peer_stream->put_var(output_strings.size());
while (output_strings.size()) {
const OutputString &output_string = output_strings.front()->get();
Array msg_data;
msg_data.push_back(output_string.message);
msg_data.push_back(output_string.type);
packet_peer_stream->put_var(msg_data);
packet_peer_stream->put_var(output_strings.front()->get());
output_strings.pop_front();
}
locking = false;
@@ -1157,10 +1163,15 @@ void ScriptDebuggerRemote::_print_handler(void *p_this, const String &p_string,
if (overflowed)
s += "[...]";
sdr->output_strings.push_back(s);
OutputString output_string;
output_string.message = s;
output_string.type = p_error ? MESSAGE_TYPE_ERROR : MESSAGE_TYPE_LOG;
sdr->output_strings.push_back(output_string);
if (overflowed) {
sdr->output_strings.push_back("[output overflow, print less text!]");
output_string.message = "[output overflow, print less text!]";
output_string.type = MESSAGE_TYPE_ERROR;
sdr->output_strings.push_back(output_string);
}
}
sdr->mutex->unlock();

View File

@@ -92,7 +92,12 @@ class ScriptDebuggerRemote : public ScriptDebugger {
Array callstack;
};
List<String> output_strings;
struct OutputString {
String message;
int type;
};
List<OutputString> output_strings;
List<Message> messages;
int max_messages_per_frame;
int n_messages_dropped;
@@ -151,6 +156,11 @@ class ScriptDebuggerRemote : public ScriptDebugger {
bool skip_breakpoints;
public:
enum MessageType {
MESSAGE_TYPE_LOG,
MESSAGE_TYPE_ERROR,
};
struct ResourceUsage {
String path;