| 47 | #include "core/variant/array.h" |
| 48 | |
| 49 | class RemoteDebugger : public EngineDebugger { |
| 50 | public: |
| 51 | enum MessageType { |
| 52 | MESSAGE_TYPE_LOG, |
| 53 | MESSAGE_TYPE_ERROR, |
| 54 | MESSAGE_TYPE_LOG_RICH, |
| 55 | }; |
| 56 | |
| 57 | private: |
| 58 | typedef DebuggerMarshalls::OutputError ErrorMessage; |
| 59 | |
| 60 | class PerformanceProfiler; |
| 61 | |
| 62 | Ref<PerformanceProfiler> performance_profiler; |
| 63 | |
| 64 | Ref<RemoteDebuggerPeer> peer; |
| 65 | |
| 66 | struct OutputString { |
| 67 | String message; |
| 68 | MessageType type; |
| 69 | }; |
| 70 | List<OutputString> output_strings; |
| 71 | List<ErrorMessage> errors; |
| 72 | |
| 73 | int n_messages_dropped = 0; |
| 74 | int max_errors_per_second = 0; |
| 75 | int max_chars_per_second = 0; |
| 76 | int max_warnings_per_second = 0; |
| 77 | int n_errors_dropped = 0; |
| 78 | int n_warnings_dropped = 0; |
| 79 | int char_count = 0; |
| 80 | int err_count = 0; |
| 81 | int warn_count = 0; |
| 82 | int last_reset = 0; |
| 83 | bool reload_all_scripts = false; |
| 84 | Array script_paths_to_reload; |
| 85 | |
| 86 | // Make handlers and send_message thread safe. |
| 87 | Mutex mutex; |
| 88 | bool flushing = false; |
| 89 | Thread::ID flush_thread = 0; |
| 90 | |
| 91 | struct Message { |
| 92 | String message; |
| 93 | Array data; |
| 94 | }; |
| 95 | |
| 96 | HashMap<Thread::ID, List<Message>> messages; |
| 97 | |
| 98 | void _poll_messages(); |
| 99 | bool _has_messages(); |
| 100 | Array _get_message(); |
| 101 | |
| 102 | PrintHandlerList phl; |
| 103 | static void _print_handler(void *p_this, const String &p_string, bool p_error, bool p_rich); |
| 104 | ErrorHandlerList eh; |
| 105 | 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); |
| 106 | |