mirror of
https://github.com/godotengine/godot.git
synced 2025-10-19 16:03:29 +00:00
Support threads in the script debugger
* This implementation adds threads on the side of the client (script debugger). * Some functions of the debugger are optimized. * The profile is also now thread safe using atomics. * The editor can switch between multiple threads when debugging. This PR adds threaded support for the script language debugger. Every thread has its own thread local data and it will connect to the debugger using multiple thread IDs. This means that, now, the editor can receive multiple threads entering debug mode at the same time.
This commit is contained in:
parent
202e4b2c1e
commit
5e512b705e
17 changed files with 409 additions and 223 deletions
|
@ -2094,10 +2094,7 @@ String GDScriptLanguage::get_extension() const {
|
|||
}
|
||||
|
||||
void GDScriptLanguage::finish() {
|
||||
if (_call_stack) {
|
||||
memdelete_arr(_call_stack);
|
||||
_call_stack = nullptr;
|
||||
}
|
||||
_call_stack.free();
|
||||
|
||||
// Clear the cache before parsing the script_list
|
||||
GDScriptCache::clear();
|
||||
|
@ -2140,12 +2137,12 @@ void GDScriptLanguage::profiling_start() {
|
|||
|
||||
SelfList<GDScriptFunction> *elem = function_list.first();
|
||||
while (elem) {
|
||||
elem->self()->profile.call_count = 0;
|
||||
elem->self()->profile.self_time = 0;
|
||||
elem->self()->profile.total_time = 0;
|
||||
elem->self()->profile.frame_call_count = 0;
|
||||
elem->self()->profile.frame_self_time = 0;
|
||||
elem->self()->profile.frame_total_time = 0;
|
||||
elem->self()->profile.call_count.set(0);
|
||||
elem->self()->profile.self_time.set(0);
|
||||
elem->self()->profile.total_time.set(0);
|
||||
elem->self()->profile.frame_call_count.set(0);
|
||||
elem->self()->profile.frame_self_time.set(0);
|
||||
elem->self()->profile.frame_total_time.set(0);
|
||||
elem->self()->profile.last_frame_call_count = 0;
|
||||
elem->self()->profile.last_frame_self_time = 0;
|
||||
elem->self()->profile.last_frame_total_time = 0;
|
||||
|
@ -2175,9 +2172,9 @@ int GDScriptLanguage::profiling_get_accumulated_data(ProfilingInfo *p_info_arr,
|
|||
if (current >= p_info_max) {
|
||||
break;
|
||||
}
|
||||
p_info_arr[current].call_count = elem->self()->profile.call_count;
|
||||
p_info_arr[current].self_time = elem->self()->profile.self_time;
|
||||
p_info_arr[current].total_time = elem->self()->profile.total_time;
|
||||
p_info_arr[current].call_count = elem->self()->profile.call_count.get();
|
||||
p_info_arr[current].self_time = elem->self()->profile.self_time.get();
|
||||
p_info_arr[current].total_time = elem->self()->profile.total_time.get();
|
||||
p_info_arr[current].signature = elem->self()->profile.signature;
|
||||
elem = elem->next();
|
||||
current++;
|
||||
|
@ -2395,12 +2392,12 @@ void GDScriptLanguage::frame() {
|
|||
|
||||
SelfList<GDScriptFunction> *elem = function_list.first();
|
||||
while (elem) {
|
||||
elem->self()->profile.last_frame_call_count = elem->self()->profile.frame_call_count;
|
||||
elem->self()->profile.last_frame_self_time = elem->self()->profile.frame_self_time;
|
||||
elem->self()->profile.last_frame_total_time = elem->self()->profile.frame_total_time;
|
||||
elem->self()->profile.frame_call_count = 0;
|
||||
elem->self()->profile.frame_self_time = 0;
|
||||
elem->self()->profile.frame_total_time = 0;
|
||||
elem->self()->profile.last_frame_call_count = elem->self()->profile.frame_call_count.get();
|
||||
elem->self()->profile.last_frame_self_time = elem->self()->profile.frame_self_time.get();
|
||||
elem->self()->profile.last_frame_total_time = elem->self()->profile.frame_total_time.get();
|
||||
elem->self()->profile.frame_call_count.set(0);
|
||||
elem->self()->profile.frame_self_time.set(0);
|
||||
elem->self()->profile.frame_total_time.set(0);
|
||||
elem = elem->next();
|
||||
}
|
||||
}
|
||||
|
@ -2607,6 +2604,8 @@ String GDScriptLanguage::get_global_class_name(const String &p_path, String *r_b
|
|||
return c->identifier != nullptr ? String(c->identifier->name) : String();
|
||||
}
|
||||
|
||||
thread_local GDScriptLanguage::CallStack GDScriptLanguage::_call_stack;
|
||||
|
||||
GDScriptLanguage::GDScriptLanguage() {
|
||||
calls = 0;
|
||||
ERR_FAIL_COND(singleton);
|
||||
|
@ -2626,18 +2625,14 @@ GDScriptLanguage::GDScriptLanguage() {
|
|||
profiling = false;
|
||||
script_frame_time = 0;
|
||||
|
||||
_debug_call_stack_pos = 0;
|
||||
int dmcs = GLOBAL_DEF(PropertyInfo(Variant::INT, "debug/settings/gdscript/max_call_stack", PROPERTY_HINT_RANGE, "512," + itos(GDScriptFunction::MAX_CALL_DEPTH - 1) + ",1"), 1024);
|
||||
|
||||
if (EngineDebugger::is_active()) {
|
||||
//debugging enabled!
|
||||
|
||||
_debug_max_call_stack = dmcs;
|
||||
_call_stack = memnew_arr(CallLevel, _debug_max_call_stack + 1);
|
||||
|
||||
} else {
|
||||
_debug_max_call_stack = 0;
|
||||
_call_stack = nullptr;
|
||||
}
|
||||
|
||||
#ifdef DEBUG_ENABLED
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue