| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
#pragma once |
| 32 |
|
| 33 |
#include "core/debugger/debugger_marshalls.h" |
| 34 |
#include "core/debugger/engine_debugger.h" |
| 35 |
#include "core/debugger/remote_debugger_peer.h" |
| 36 |
#include "core/object/class_db.h" |
| 37 |
#include "core/string/string_name.h" |
| 38 |
#include "core/string/ustring.h" |
| 39 |
#include "core/variant/array.h" |
| 40 |
|
| 41 |
class RemoteDebugger : public EngineDebugger { |
| 42 |
public: |
| 43 |
enum MessageType { |
| 44 |
MESSAGE_TYPE_LOG, |
| 45 |
MESSAGE_TYPE_ERROR, |
| 46 |
MESSAGE_TYPE_LOG_RICH, |
| 47 |
}; |
| 48 |
|
| 49 |
private: |
| 50 |
typedef DebuggerMarshalls::OutputError ErrorMessage; |
| 51 |
|
| 52 |
class PerformanceProfiler; |
| 53 |
|
| 54 |
Ref<PerformanceProfiler> performance_profiler; |
| 55 |
|
| 56 |
Ref<RemoteDebuggerPeer> peer; |
| 57 |
|
| 58 |
struct OutputString { |
| 59 |
String message; |
| 60 |
MessageType type; |
| 61 |
}; |
| 62 |
List<OutputString> output_strings; |
| 63 |
List<ErrorMessage> errors; |
| 64 |
|
| 65 |
int n_messages_dropped = 0; |
| 66 |
int max_errors_per_second = 0; |
| 67 |
int max_chars_per_second = 0; |
| 68 |
int max_warnings_per_second = 0; |
| 69 |
int n_errors_dropped = 0; |
| 70 |
int n_warnings_dropped = 0; |
| 71 |
int char_count = 0; |
| 72 |
int err_count = 0; |
| 73 |
int warn_count = 0; |
| 74 |
int last_reset = 0; |
| 75 |
bool reload_all_scripts = false; |
| 76 |
Array script_paths_to_reload; |
| 77 |
|
| 78 |
|
| 79 |
Mutex mutex; |
| 80 |
bool flushing = false; |
| 81 |
Thread::ID flush_thread = 0; |
| 82 |
|
| 83 |
struct Message { |
| 84 |
String message; |
| 85 |
Array data; |
| 86 |
}; |
| 87 |
|
| 88 |
HashMap<Thread::ID, List<Message>> messages; |
| 89 |
HashSet<Thread::ID> threads_in_break; |
| 90 |
|
| 91 |
void _poll_messages(); |
| 92 |
bool _has_messages(); |
| 93 |
Array _get_message(); |
| 94 |
|
| 95 |
PrintHandlerList phl; |
| 96 |
static void _print_handler(void *p_this, const String &p_string, bool p_error, bool p_rich); |
| 97 |
ErrorHandlerList eh; |
| 98 |
static void _err_handler(void *p_this, const char *p_func, const char *p_file, int p_line, const char *p_err, const char *p_descr, bool p_editor_notify, ErrorHandlerType p_type); |
| 99 |
|
| 100 |
ErrorMessage _create_overflow_error(const String &p_what, const String &p_descr); |
| 101 |
Error _put_msg(const String &p_message, const Array &p_data); |
| 102 |
|
| 103 |
bool is_peer_connected() { return peer->is_peer_connected(); } |
| 104 |
void flush_output(); |
| 105 |
|
| 106 |
void _send_stack_vars(List<String> &p_names, List<Variant> &p_vals, int p_type); |
| 107 |
|
| 108 |
Error _profiler_capture(const String &p_cmd, const Array &p_data, bool &r_captured); |
| 109 |
Error _core_capture(const String &p_cmd, const Array &p_data, bool &r_captured); |
| 110 |
Error _try_capture(const String &p_name, const Array &p_data, bool &r_captured); |
| 111 |
|
| 112 |
public: |
| 113 |
|
| 114 |
void poll_events(bool p_is_idle); |
| 115 |
void send_message(const String &p_message, const Array &p_args); |
| 116 |
void send_error(const String &p_func, const String &p_file, int p_line, const String &p_err, const String &p_descr, bool p_editor_notify, ErrorHandlerType p_type); |
| 117 |
void debug(bool p_can_continue = true, bool p_is_error_breakpoint = false); |
| 118 |
|
| 119 |
explicit RemoteDebugger(Ref<RemoteDebuggerPeer> p_peer); |
| 120 |
~RemoteDebugger(); |
| 121 |
}; |