summaryrefslogtreecommitdiff
path: root/core/debugger
diff options
context:
space:
mode:
Diffstat (limited to 'core/debugger')
-rw-r--r--core/debugger/debugger_marshalls.h6
-rw-r--r--core/debugger/engine_debugger.cpp12
-rw-r--r--core/debugger/engine_debugger.h12
-rw-r--r--core/debugger/engine_profiler.cpp10
-rw-r--r--core/debugger/engine_profiler.h2
-rw-r--r--core/debugger/local_debugger.cpp19
-rw-r--r--core/debugger/local_debugger.h2
-rw-r--r--core/debugger/remote_debugger.cpp25
-rw-r--r--core/debugger/remote_debugger.h3
-rw-r--r--core/debugger/script_debugger.cpp2
-rw-r--r--core/debugger/script_debugger.h8
11 files changed, 64 insertions, 37 deletions
diff --git a/core/debugger/debugger_marshalls.h b/core/debugger/debugger_marshalls.h
index 378c3af8aa..751e8a6371 100644
--- a/core/debugger/debugger_marshalls.h
+++ b/core/debugger/debugger_marshalls.h
@@ -28,8 +28,8 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#ifndef DEBUGGER_MARSHARLLS_H
-#define DEBUGGER_MARSHARLLS_H
+#ifndef DEBUGGER_MARSHALLS_H
+#define DEBUGGER_MARSHALLS_H
#include "core/object/script_language.h"
@@ -69,4 +69,4 @@ struct DebuggerMarshalls {
};
};
-#endif // DEBUGGER_MARSHARLLS_H
+#endif // DEBUGGER_MARSHALLS_H
diff --git a/core/debugger/engine_debugger.cpp b/core/debugger/engine_debugger.cpp
index 54760d8d65..d495a8ee20 100644
--- a/core/debugger/engine_debugger.cpp
+++ b/core/debugger/engine_debugger.cpp
@@ -39,9 +39,11 @@
EngineDebugger *EngineDebugger::singleton = nullptr;
ScriptDebugger *EngineDebugger::script_debugger = nullptr;
-Map<StringName, EngineDebugger::Profiler> EngineDebugger::profilers;
-Map<StringName, EngineDebugger::Capture> EngineDebugger::captures;
-Map<String, EngineDebugger::CreatePeerFunc> EngineDebugger::protocols;
+HashMap<StringName, EngineDebugger::Profiler> EngineDebugger::profilers;
+HashMap<StringName, EngineDebugger::Capture> EngineDebugger::captures;
+HashMap<String, EngineDebugger::CreatePeerFunc> EngineDebugger::protocols;
+
+void (*EngineDebugger::allow_focus_steal_fn)();
void EngineDebugger::register_profiler(const StringName &p_name, const Profiler &p_func) {
ERR_FAIL_COND_MSG(profilers.has(p_name), "Profiler already registered: " + p_name);
@@ -133,7 +135,7 @@ void EngineDebugger::iteration(uint64_t p_frame_ticks, uint64_t p_process_ticks,
singleton->poll_events(true);
}
-void EngineDebugger::initialize(const String &p_uri, bool p_skip_breakpoints, Vector<String> p_breakpoints) {
+void EngineDebugger::initialize(const String &p_uri, bool p_skip_breakpoints, Vector<String> p_breakpoints, void (*p_allow_focus_steal_fn)()) {
register_uri_handler("tcp://", RemoteDebuggerPeerTCP::create); // TCP is the default protocol. Platforms/modules can add more.
if (p_uri.is_empty()) {
return;
@@ -174,6 +176,8 @@ void EngineDebugger::initialize(const String &p_uri, bool p_skip_breakpoints, Ve
singleton_script_debugger->insert_breakpoint(bp.substr(sp + 1, bp.length()).to_int(), bp.substr(0, sp));
}
+
+ allow_focus_steal_fn = p_allow_focus_steal_fn;
}
void EngineDebugger::deinitialize() {
diff --git a/core/debugger/engine_debugger.h b/core/debugger/engine_debugger.h
index fdfa41c9cc..236d5e5f63 100644
--- a/core/debugger/engine_debugger.h
+++ b/core/debugger/engine_debugger.h
@@ -33,7 +33,7 @@
#include "core/string/string_name.h"
#include "core/string/ustring.h"
-#include "core/templates/map.h"
+#include "core/templates/hash_map.h"
#include "core/templates/vector.h"
#include "core/variant/array.h"
#include "core/variant/variant.h"
@@ -96,9 +96,11 @@ protected:
static EngineDebugger *singleton;
static ScriptDebugger *script_debugger;
- static Map<StringName, Profiler> profilers;
- static Map<StringName, Capture> captures;
- static Map<String, CreatePeerFunc> protocols;
+ static HashMap<StringName, Profiler> profilers;
+ static HashMap<StringName, Capture> captures;
+ static HashMap<String, CreatePeerFunc> protocols;
+
+ static void (*allow_focus_steal_fn)();
public:
_FORCE_INLINE_ static EngineDebugger *get_singleton() { return singleton; }
@@ -106,7 +108,7 @@ public:
_FORCE_INLINE_ static ScriptDebugger *get_script_debugger() { return script_debugger; };
- static void initialize(const String &p_uri, bool p_skip_breakpoints, Vector<String> p_breakpoints);
+ static void initialize(const String &p_uri, bool p_skip_breakpoints, Vector<String> p_breakpoints, void (*p_allow_focus_steal_fn)());
static void deinitialize();
static void register_profiler(const StringName &p_name, const Profiler &p_profiler);
static void unregister_profiler(const StringName &p_name);
diff --git a/core/debugger/engine_profiler.cpp b/core/debugger/engine_profiler.cpp
index 6235d19405..b99ee7dd5a 100644
--- a/core/debugger/engine_profiler.cpp
+++ b/core/debugger/engine_profiler.cpp
@@ -35,7 +35,7 @@
void EngineProfiler::_bind_methods() {
GDVIRTUAL_BIND(_toggle, "enable", "options");
GDVIRTUAL_BIND(_add_frame, "data");
- GDVIRTUAL_BIND(_tick, "frame_time", "idle_time", "physics_time", "physics_frame_time");
+ GDVIRTUAL_BIND(_tick, "frame_time", "process_time", "physics_time", "physics_frame_time");
}
void EngineProfiler::toggle(bool p_enable, const Array &p_array) {
@@ -46,8 +46,8 @@ void EngineProfiler::add(const Array &p_data) {
GDVIRTUAL_CALL(_add_frame, p_data);
}
-void EngineProfiler::tick(double p_frame_time, double p_idle_time, double p_physics_time, double p_physics_frame_time) {
- GDVIRTUAL_CALL(_tick, p_frame_time, p_idle_time, p_physics_time, p_physics_frame_time);
+void EngineProfiler::tick(double p_frame_time, double p_process_time, double p_physics_time, double p_physics_frame_time) {
+ GDVIRTUAL_CALL(_tick, p_frame_time, p_process_time, p_physics_time, p_physics_frame_time);
}
Error EngineProfiler::bind(const String &p_name) {
@@ -60,8 +60,8 @@ Error EngineProfiler::bind(const String &p_name) {
[](void *p_user, const Array &p_data) {
static_cast<EngineProfiler *>(p_user)->add(p_data);
},
- [](void *p_user, double p_frame_time, double p_idle_time, double p_physics_time, double p_physics_frame_time) {
- static_cast<EngineProfiler *>(p_user)->tick(p_frame_time, p_idle_time, p_physics_time, p_physics_frame_time);
+ [](void *p_user, double p_frame_time, double p_process_time, double p_physics_time, double p_physics_frame_time) {
+ static_cast<EngineProfiler *>(p_user)->tick(p_frame_time, p_process_time, p_physics_time, p_physics_frame_time);
});
registration = p_name;
EngineDebugger::register_profiler(p_name, prof);
diff --git a/core/debugger/engine_profiler.h b/core/debugger/engine_profiler.h
index ade280a7bb..e50924a1ed 100644
--- a/core/debugger/engine_profiler.h
+++ b/core/debugger/engine_profiler.h
@@ -48,7 +48,7 @@ protected:
public:
virtual void toggle(bool p_enable, const Array &p_opts);
virtual void add(const Array &p_data);
- virtual void tick(double p_frame_time, double p_idle_time, double p_physics_time, double p_physics_frame_time);
+ virtual void tick(double p_frame_time, double p_process_time, double p_physics_time, double p_physics_frame_time);
Error bind(const String &p_name);
Error unbind();
diff --git a/core/debugger/local_debugger.cpp b/core/debugger/local_debugger.cpp
index 131cbaed6c..58d239ccb9 100644
--- a/core/debugger/local_debugger.cpp
+++ b/core/debugger/local_debugger.cpp
@@ -31,7 +31,7 @@
#include "local_debugger.h"
#include "core/debugger/script_debugger.h"
-#include "scene/main/scene_tree.h"
+#include "core/os/os.h"
struct LocalDebugger::ScriptsProfiler {
struct ProfileInfoSort {
@@ -60,7 +60,7 @@ struct LocalDebugger::ScriptsProfiler {
}
}
- void tick(double p_frame_time, double p_idle_time, double p_physics_time, double p_physics_frame_time) {
+ void tick(double p_frame_time, double p_process_time, double p_physics_time, double p_physics_frame_time) {
frame_time = p_frame_time;
_print_frame_data(false);
}
@@ -241,15 +241,15 @@ void LocalDebugger::debug(bool p_can_continue, bool p_is_error_breakpoint) {
} else if (line.begins_with("br") || line.begins_with("break")) {
if (line.get_slice_count(" ") <= 1) {
- const Map<int, Set<StringName>> &breakpoints = script_debugger->get_breakpoints();
+ const HashMap<int, HashSet<StringName>> &breakpoints = script_debugger->get_breakpoints();
if (breakpoints.size() == 0) {
print_line("No Breakpoints.");
continue;
}
print_line("Breakpoint(s): " + itos(breakpoints.size()));
- for (const KeyValue<int, Set<StringName>> &E : breakpoints) {
- print_line("\t" + String(E.value.front()->get()) + ":" + itos(E.key));
+ for (const KeyValue<int, HashSet<StringName>> &E : breakpoints) {
+ print_line("\t" + String(*E.value.begin()) + ":" + itos(E.key));
}
} else {
@@ -273,7 +273,10 @@ void LocalDebugger::debug(bool p_can_continue, bool p_is_error_breakpoint) {
script_debugger->set_depth(-1);
script_debugger->set_lines_left(-1);
- SceneTree::get_singleton()->quit();
+ MainLoop *main_loop = OS::get_singleton()->get_main_loop();
+ if (main_loop->get_class() == "SceneTree") {
+ main_loop->call("quit");
+ }
break;
} else if (line.begins_with("delete")) {
if (line.get_slice_count(" ") <= 1) {
@@ -372,8 +375,8 @@ LocalDebugger::LocalDebugger() {
static_cast<ScriptsProfiler *>(p_user)->toggle(p_enable, p_opts);
},
nullptr,
- [](void *p_user, double p_frame_time, double p_idle_time, double p_physics_time, double p_physics_frame_time) {
- static_cast<ScriptsProfiler *>(p_user)->tick(p_frame_time, p_idle_time, p_physics_time, p_physics_frame_time);
+ [](void *p_user, double p_frame_time, double p_process_time, double p_physics_time, double p_physics_frame_time) {
+ static_cast<ScriptsProfiler *>(p_user)->tick(p_frame_time, p_process_time, p_physics_time, p_physics_frame_time);
});
register_profiler("scripts", scr_prof);
}
diff --git a/core/debugger/local_debugger.h b/core/debugger/local_debugger.h
index ecd805a6cb..c687214c65 100644
--- a/core/debugger/local_debugger.h
+++ b/core/debugger/local_debugger.h
@@ -42,7 +42,7 @@ private:
ScriptsProfiler *scripts_profiler = nullptr;
String target_function;
- Map<String, String> options;
+ HashMap<String, String> options;
Pair<String, int> to_breakpoint(const String &p_line);
void print_variables(const List<String> &names, const List<Variant> &values, const String &variable_prefix);
diff --git a/core/debugger/remote_debugger.cpp b/core/debugger/remote_debugger.cpp
index c3506a7eea..23ee977df4 100644
--- a/core/debugger/remote_debugger.cpp
+++ b/core/debugger/remote_debugger.cpp
@@ -107,7 +107,7 @@ public:
}
}
- void tick(double p_frame_time, double p_idle_time, double p_physics_time, double p_physics_frame_time) {
+ void tick(double p_frame_time, double p_process_time, double p_physics_time, double p_physics_frame_time) {
uint64_t pt = OS::get_singleton()->get_ticks_msec();
if (pt - last_bandwidth_time > 200) {
last_bandwidth_time = pt;
@@ -130,7 +130,7 @@ class RemoteDebugger::PerformanceProfiler : public EngineProfiler {
public:
void toggle(bool p_enable, const Array &p_opts) {}
void add(const Array &p_data) {}
- void tick(double p_frame_time, double p_idle_time, double p_physics_time, double p_physics_frame_time) {
+ void tick(double p_frame_time, double p_process_time, double p_physics_time, double p_physics_frame_time) {
if (!performance) {
return;
}
@@ -208,7 +208,7 @@ void RemoteDebugger::_err_handler(void *p_this, const char *p_func, const char *
rd->script_debugger->send_error(String::utf8(p_func), String::utf8(p_file), p_line, String::utf8(p_err), String::utf8(p_descr), p_editor_notify, p_type, si);
}
-void RemoteDebugger::_print_handler(void *p_this, const String &p_string, bool p_error) {
+void RemoteDebugger::_print_handler(void *p_this, const String &p_string, bool p_error, bool p_rich) {
RemoteDebugger *rd = static_cast<RemoteDebugger *>(p_this);
if (rd->flushing && Thread::get_caller_id() == rd->flush_thread) { // Can't handle recursive prints during flush.
@@ -237,7 +237,13 @@ void RemoteDebugger::_print_handler(void *p_this, const String &p_string, bool p
OutputString output_string;
output_string.message = s;
- output_string.type = p_error ? MESSAGE_TYPE_ERROR : MESSAGE_TYPE_LOG;
+ if (p_error) {
+ output_string.type = MESSAGE_TYPE_ERROR;
+ } else if (p_rich) {
+ output_string.type = MESSAGE_TYPE_LOG_RICH;
+ } else {
+ output_string.type = MESSAGE_TYPE_LOG;
+ }
rd->output_strings.push_back(output_string);
if (overflowed) {
@@ -291,6 +297,14 @@ void RemoteDebugger::flush_output() {
}
strings.push_back(output_string.message);
types.push_back(MESSAGE_TYPE_ERROR);
+ } else if (output_string.type == MESSAGE_TYPE_LOG_RICH) {
+ if (!joined_log_strings.is_empty()) {
+ strings.push_back(String("\n").join(joined_log_strings));
+ types.push_back(MESSAGE_TYPE_LOG_RICH);
+ joined_log_strings.clear();
+ }
+ strings.push_back(output_string.message);
+ types.push_back(MESSAGE_TYPE_LOG_RICH);
} else {
joined_log_strings.push_back(output_string.message);
}
@@ -438,6 +452,9 @@ void RemoteDebugger::debug(bool p_can_continue, bool p_is_error_breakpoint) {
msg.push_back(error_str);
ERR_FAIL_COND(!script_lang);
msg.push_back(script_lang->debug_get_stack_level_count() > 0);
+ if (allow_focus_steal_fn) {
+ allow_focus_steal_fn();
+ }
send_message("debug_enter", msg);
Input::MouseMode mouse_mode = Input::get_singleton()->get_mouse_mode();
diff --git a/core/debugger/remote_debugger.h b/core/debugger/remote_debugger.h
index fdb312ae68..fe4bbe86ea 100644
--- a/core/debugger/remote_debugger.h
+++ b/core/debugger/remote_debugger.h
@@ -44,6 +44,7 @@ public:
enum MessageType {
MESSAGE_TYPE_LOG,
MESSAGE_TYPE_ERROR,
+ MESSAGE_TYPE_LOG_RICH,
};
private:
@@ -82,7 +83,7 @@ private:
Thread::ID flush_thread = 0;
PrintHandlerList phl;
- static void _print_handler(void *p_this, const String &p_string, bool p_error);
+ static void _print_handler(void *p_this, const String &p_string, bool p_error, bool p_rich);
ErrorHandlerList eh;
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);
diff --git a/core/debugger/script_debugger.cpp b/core/debugger/script_debugger.cpp
index 4dd93249ef..e30f3e7886 100644
--- a/core/debugger/script_debugger.cpp
+++ b/core/debugger/script_debugger.cpp
@@ -50,7 +50,7 @@ int ScriptDebugger::get_depth() const {
void ScriptDebugger::insert_breakpoint(int p_line, const StringName &p_source) {
if (!breakpoints.has(p_line)) {
- breakpoints[p_line] = Set<StringName>();
+ breakpoints[p_line] = HashSet<StringName>();
}
breakpoints[p_line].insert(p_source);
}
diff --git a/core/debugger/script_debugger.h b/core/debugger/script_debugger.h
index feb6702b54..5124b357a5 100644
--- a/core/debugger/script_debugger.h
+++ b/core/debugger/script_debugger.h
@@ -33,8 +33,8 @@
#include "core/object/script_language.h"
#include "core/string/string_name.h"
-#include "core/templates/map.h"
-#include "core/templates/set.h"
+#include "core/templates/hash_set.h"
+#include "core/templates/rb_map.h"
#include "core/templates/vector.h"
class ScriptDebugger {
@@ -44,7 +44,7 @@ class ScriptDebugger {
int depth = -1;
bool skip_breakpoints = false;
- Map<int, Set<StringName>> breakpoints;
+ HashMap<int, HashSet<StringName>> breakpoints;
ScriptLanguage *break_lang = nullptr;
Vector<StackInfo> error_stack_info;
@@ -66,7 +66,7 @@ public:
bool is_breakpoint(int p_line, const StringName &p_source) const;
bool is_breakpoint_line(int p_line) const;
void clear_breakpoints();
- const Map<int, Set<StringName>> &get_breakpoints() const { return breakpoints; }
+ const HashMap<int, HashSet<StringName>> &get_breakpoints() const { return breakpoints; }
void debug(ScriptLanguage *p_lang, bool p_can_continue = true, bool p_is_error_breakpoint = false);
ScriptLanguage *get_break_language() const;