| 129 | } |
| 130 | |
| 131 | void EngineDebugger::initialize(const String &p_uri, bool p_skip_breakpoints, bool p_ignore_error_breaks, const Vector<String> &p_breakpoints, void (*p_allow_focus_steal_fn)()) { |
| 132 | register_uri_handler("tcp://", RemoteDebuggerPeerTCP::create); // TCP is the default protocol. Platforms/modules can add more. |
| 133 | if (p_uri.is_empty()) { |
| 134 | return; |
| 135 | } |
| 136 | if (p_uri == "local://") { |
| 137 | singleton = memnew(LocalDebugger); |
| 138 | script_debugger = memnew(ScriptDebugger); |
| 139 | // Tell the OS that we want to handle termination signals. |
| 140 | OS::get_singleton()->initialize_debugging(); |
| 141 | } else if (p_uri.contains("://")) { |
| 142 | const String proto = p_uri.substr(0, p_uri.find("://") + 3); |
| 143 | if (!protocols.has(proto)) { |
| 144 | return; |
| 145 | } |
| 146 | RemoteDebuggerPeer *peer = protocols[proto](p_uri); |
| 147 | if (!peer) { |
| 148 | return; |
| 149 | } |
| 150 | singleton = memnew(RemoteDebugger(Ref<RemoteDebuggerPeer>(peer))); |
| 151 | script_debugger = memnew(ScriptDebugger); |
| 152 | // Notify editor of our pid (to allow focus stealing). |
| 153 | Array msg = { OS::get_singleton()->get_process_id() }; |
| 154 | singleton->send_message("set_pid", msg); |
| 155 | } |
| 156 | if (!singleton) { |
| 157 | return; |
| 158 | } |
| 159 | |
| 160 | // There is a debugger, parse breakpoints. |
| 161 | ScriptDebugger *singleton_script_debugger = singleton->get_script_debugger(); |
| 162 | singleton_script_debugger->set_skip_breakpoints(p_skip_breakpoints); |
| 163 | singleton_script_debugger->set_ignore_error_breaks(p_ignore_error_breaks); |
| 164 | |
| 165 | for (int i = 0; i < p_breakpoints.size(); i++) { |
| 166 | const String &bp = p_breakpoints[i]; |
| 167 | int sp = bp.rfind_char(':'); |
| 168 | ERR_CONTINUE_MSG(sp == -1, vformat("Invalid breakpoint: '%s', expected file:line format.", bp)); |
| 169 | |
| 170 | singleton_script_debugger->insert_breakpoint(bp.substr(sp + 1).to_int(), bp.substr(0, sp)); |
| 171 | } |
| 172 | |
| 173 | allow_focus_steal_fn = p_allow_focus_steal_fn; |
| 174 | } |
| 175 | |
| 176 | void EngineDebugger::deinitialize() { |
| 177 | if (singleton) { |
nothing calls this directly
no test coverage detected