diff --git a/core/script_debugger_local.cpp b/core/script_debugger_local.cpp index ac4dafcf599..e61f9f71587 100644 --- a/core/script_debugger_local.cpp +++ b/core/script_debugger_local.cpp @@ -33,7 +33,7 @@ #include "core/os/os.h" #include "scene/main/scene_tree.h" -void ScriptDebuggerLocal::debug(ScriptLanguage *p_script, bool p_can_continue) { +void ScriptDebuggerLocal::debug(ScriptLanguage *p_script, bool p_can_continue, bool p_is_error_breakpoint) { if (!target_function.empty()) { String current_function = p_script->debug_get_stack_level_function(0); diff --git a/core/script_debugger_local.h b/core/script_debugger_local.h index 19151d4cb09..b3aed5e358f 100644 --- a/core/script_debugger_local.h +++ b/core/script_debugger_local.h @@ -48,7 +48,7 @@ class ScriptDebuggerLocal : public ScriptDebugger { void print_variables(const List &names, const List &values, const String &variable_prefix); public: - void debug(ScriptLanguage *p_script, bool p_can_continue); + void debug(ScriptLanguage *p_script, bool p_can_continue, bool p_is_error_breakpoint); virtual void send_message(const String &p_message, const Array &p_args); virtual void send_error(const String &p_func, const String &p_file, int p_line, const String &p_err, const String &p_descr, ErrorHandlerType p_type, const Vector &p_stack_info); diff --git a/core/script_debugger_remote.cpp b/core/script_debugger_remote.cpp index 2a061f09476..0b2b7368d25 100644 --- a/core/script_debugger_remote.cpp +++ b/core/script_debugger_remote.cpp @@ -129,11 +129,14 @@ void ScriptDebuggerRemote::_save_node(ObjectID id, const String &p_path) { ResourceSaver::save(p_path, ps); } -void ScriptDebuggerRemote::debug(ScriptLanguage *p_script, bool p_can_continue) { +void ScriptDebuggerRemote::debug(ScriptLanguage *p_script, bool p_can_continue, bool p_is_error_breakpoint) { //this function is called when there is a debugger break (bug on script) //or when execution is paused from editor + if (skip_breakpoints && !p_is_error_breakpoint) + return; + ERR_FAIL_COND_MSG(!tcp_client->is_connected_to_host(), "Script Debugger failed to connect, but being used anyway."); packet_peer_stream->put_var("debug_enter"); @@ -155,6 +158,7 @@ void ScriptDebuggerRemote::debug(ScriptLanguage *p_script, bool p_can_continue) Variant var; Error err = packet_peer_stream->get_var(var); + ERR_CONTINUE(err != OK); ERR_CONTINUE(var.get_type() != Variant::ARRAY); @@ -266,7 +270,6 @@ void ScriptDebuggerRemote::debug(ScriptLanguage *p_script, bool p_can_continue) break; } else if (command == "continue") { - set_depth(-1); set_lines_left(-1); OS::get_singleton()->move_window_to_foreground(); @@ -302,6 +305,8 @@ void ScriptDebuggerRemote::debug(ScriptLanguage *p_script, bool p_can_continue) } else if (command == "save_node") { _save_node(cmd[1], cmd[2]); + } else if (command == "set_skip_breakpoints") { + skip_breakpoints = cmd[1]; } else { _parse_live_edit(cmd); } @@ -773,6 +778,8 @@ void ScriptDebuggerRemote::_poll_events() { insert_breakpoint(cmd[2], cmd[1]); else remove_breakpoint(cmd[2], cmd[1]); + } else if (command == "set_skip_breakpoints") { + skip_breakpoints = cmd[1]; } else { _parse_live_edit(cmd); } @@ -1102,6 +1109,10 @@ void ScriptDebuggerRemote::profiling_set_frame_times(float p_frame_time, float p physics_frame_time = p_physics_frame_time; } +void ScriptDebuggerRemote::set_skip_breakpoints(bool p_skip_breakpoints) { + skip_breakpoints = p_skip_breakpoints; +} + ScriptDebuggerRemote::ResourceUsageFunc ScriptDebuggerRemote::resource_usage_func = NULL; ScriptDebuggerRemote::ScriptDebuggerRemote() : diff --git a/core/script_debugger_remote.h b/core/script_debugger_remote.h index a5bfd7a32d9..34585afc801 100644 --- a/core/script_debugger_remote.h +++ b/core/script_debugger_remote.h @@ -140,6 +140,8 @@ class ScriptDebuggerRemote : public ScriptDebugger { void _save_node(ObjectID id, const String &p_path); + bool skip_breakpoints; + public: struct ResourceUsage { @@ -156,7 +158,7 @@ public: static ResourceUsageFunc resource_usage_func; Error connect_to_host(const String &p_host, uint16_t p_port); - virtual void debug(ScriptLanguage *p_script, bool p_can_continue = true); + virtual void debug(ScriptLanguage *p_script, bool p_can_continue = true, bool p_is_error_breakpoint = false); virtual void idle_poll(); virtual void line_poll(); @@ -176,6 +178,8 @@ public: virtual void profiling_end(); virtual void profiling_set_frame_times(float p_frame_time, float p_idle_time, float p_physics_time, float p_physics_frame_time); + virtual void set_skip_breakpoints(bool p_skip_breakpoints); + ScriptDebuggerRemote(); ~ScriptDebuggerRemote(); }; diff --git a/core/script_language.h b/core/script_language.h index 1b4f1eb4cd4..5c7e8bb36ce 100644 --- a/core/script_language.h +++ b/core/script_language.h @@ -467,7 +467,7 @@ public: void clear_breakpoints(); const Map > &get_breakpoints() const { return breakpoints; } - virtual void debug(ScriptLanguage *p_script, bool p_can_continue = true) = 0; + virtual void debug(ScriptLanguage *p_script, bool p_can_continue = true, bool p_is_error_breakpoint = false) = 0; virtual void idle_poll(); virtual void line_poll(); diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp index aab890be00a..5e3ece7b0ba 100644 --- a/editor/editor_node.cpp +++ b/editor/editor_node.cpp @@ -1850,6 +1850,7 @@ void EditorNode::_run(bool p_current, const String &p_custom) { String main_scene; String run_filename; String args; + bool skip_breakpoints; if (p_current || (editor_data.get_edited_scene_root() && p_custom == editor_data.get_edited_scene_root()->get_filename())) { @@ -1915,8 +1916,9 @@ void EditorNode::_run(bool p_current, const String &p_custom) { editor_data.get_editor_breakpoints(&breakpoints); args = ProjectSettings::get_singleton()->get("editor/main_run_args"); + skip_breakpoints = ScriptEditor::get_singleton()->get_debugger()->is_skip_breakpoints(); - Error error = editor_run.run(run_filename, args, breakpoints); + Error error = editor_run.run(run_filename, args, breakpoints, skip_breakpoints); if (error != OK) { diff --git a/editor/editor_run.cpp b/editor/editor_run.cpp index e4e32b2ce0a..7b5ec9e772b 100644 --- a/editor/editor_run.cpp +++ b/editor/editor_run.cpp @@ -37,7 +37,8 @@ EditorRun::Status EditorRun::get_status() const { return status; } -Error EditorRun::run(const String &p_scene, const String &p_custom_args, const List &p_breakpoints) { + +Error EditorRun::run(const String &p_scene, const String &p_custom_args, const List &p_breakpoints, const bool &p_skip_breakpoints) { List args; @@ -162,6 +163,10 @@ Error EditorRun::run(const String &p_scene, const String &p_custom_args, const L args.push_back(bpoints); } + if (p_skip_breakpoints) { + args.push_back("--skip-breakpoints"); + } + if (p_scene != "") { args.push_back(p_scene); } diff --git a/editor/editor_run.h b/editor/editor_run.h index 9127c620304..42724630b5f 100644 --- a/editor/editor_run.h +++ b/editor/editor_run.h @@ -51,7 +51,7 @@ private: public: Status get_status() const; - Error run(const String &p_scene, const String &p_custom_args, const List &p_breakpoints); + Error run(const String &p_scene, const String &p_custom_args, const List &p_breakpoints, const bool &p_skip_breakpoints = false); void run_native_notify() { status = STATUS_PLAY; } void stop(); diff --git a/editor/icons/icon_debug_skip_breakpoints_off.svg b/editor/icons/icon_debug_skip_breakpoints_off.svg new file mode 100644 index 00000000000..2a0b949aa9d --- /dev/null +++ b/editor/icons/icon_debug_skip_breakpoints_off.svg @@ -0,0 +1,89 @@ + + + + + + image/svg+xml + + + + + + + + + + + diff --git a/editor/icons/icon_debug_skip_breakpoints_on.svg b/editor/icons/icon_debug_skip_breakpoints_on.svg new file mode 100644 index 00000000000..186778a1b44 --- /dev/null +++ b/editor/icons/icon_debug_skip_breakpoints_on.svg @@ -0,0 +1,106 @@ + + + + + + image/svg+xml + + + + + + + + + + + + + + + diff --git a/editor/script_editor_debugger.cpp b/editor/script_editor_debugger.cpp index fc5aecdbe9d..a4270786c1d 100644 --- a/editor/script_editor_debugger.cpp +++ b/editor/script_editor_debugger.cpp @@ -201,6 +201,21 @@ void ScriptEditorDebugger::debug_copy() { OS::get_singleton()->set_clipboard(msg); } +void ScriptEditorDebugger::debug_skip_breakpoints() { + skip_breakpoints_value = !skip_breakpoints_value; + if (skip_breakpoints_value) + skip_breakpoints->set_icon(get_icon("DebugSkipBreakpointsOn", "EditorIcons")); + else + skip_breakpoints->set_icon(get_icon("DebugSkipBreakpointsOff", "EditorIcons")); + + if (connection.is_valid()) { + Array msg; + msg.push_back("set_skip_breakpoints"); + msg.push_back(skip_breakpoints_value); + ppeer->put_var(msg); + } +} + void ScriptEditorDebugger::debug_next() { ERR_FAIL_COND(!breaked); @@ -1083,7 +1098,7 @@ void ScriptEditorDebugger::_notification(int p_what) { case NOTIFICATION_ENTER_TREE: { inspector->edit(variables); - + skip_breakpoints->set_icon(get_icon("DebugSkipBreakpointsOff", "EditorIcons")); copy->set_icon(get_icon("ActionCopy", "EditorIcons")); step->set_icon(get_icon("DebugStep", "EditorIcons")); @@ -1785,6 +1800,10 @@ void ScriptEditorDebugger::reload_scripts() { } } +bool ScriptEditorDebugger::is_skip_breakpoints() { + return skip_breakpoints_value; +} + void ScriptEditorDebugger::_error_activated() { TreeItem *selected = error_tree->get_selected(); @@ -1980,6 +1999,7 @@ void ScriptEditorDebugger::_bind_methods() { ClassDB::bind_method(D_METHOD("_stack_dump_frame_selected"), &ScriptEditorDebugger::_stack_dump_frame_selected); + ClassDB::bind_method(D_METHOD("debug_skip_breakpoints"), &ScriptEditorDebugger::debug_skip_breakpoints); ClassDB::bind_method(D_METHOD("debug_copy"), &ScriptEditorDebugger::debug_copy); ClassDB::bind_method(D_METHOD("debug_next"), &ScriptEditorDebugger::debug_next); @@ -2067,6 +2087,13 @@ ScriptEditorDebugger::ScriptEditorDebugger(EditorNode *p_editor) { hbc->add_child(memnew(VSeparator)); + skip_breakpoints = memnew(ToolButton); + hbc->add_child(skip_breakpoints); + skip_breakpoints->set_tooltip(TTR("Skip Breakpoints")); + skip_breakpoints->connect("pressed", this, "debug_skip_breakpoints"); + + hbc->add_child(memnew(VSeparator)); + copy = memnew(ToolButton); hbc->add_child(copy); copy->set_tooltip(TTR("Copy Error")); diff --git a/editor/script_editor_debugger.h b/editor/script_editor_debugger.h index 947b0cca527..dc9c99591da 100644 --- a/editor/script_editor_debugger.h +++ b/editor/script_editor_debugger.h @@ -109,12 +109,15 @@ class ScriptEditorDebugger : public Control { bool hide_on_stop; bool enable_external_editor; + + bool skip_breakpoints_value = false; Ref