/**************************************************************************/1/* script_debugger.cpp */2/**************************************************************************/3/* This file is part of: */4/* GODOT ENGINE */5/* https://godotengine.org */6/**************************************************************************/7/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */8/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */9/* */10/* Permission is hereby granted, free of charge, to any person obtaining */11/* a copy of this software and associated documentation files (the */12/* "Software"), to deal in the Software without restriction, including */13/* without limitation the rights to use, copy, modify, merge, publish, */14/* distribute, sublicense, and/or sell copies of the Software, and to */15/* permit persons to whom the Software is furnished to do so, subject to */16/* the following conditions: */17/* */18/* The above copyright notice and this permission notice shall be */19/* included in all copies or substantial portions of the Software. */20/* */21/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */22/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */23/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */24/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */25/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */26/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */27/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */28/**************************************************************************/2930#include "script_debugger.h"3132#include "core/debugger/engine_debugger.h"3334thread_local Vector<ScriptDebugger::StackInfo> ScriptDebugger::error_stack_info;3536void ScriptDebugger::set_lines_left(int p_left) {37lines_left = p_left;38}3940void ScriptDebugger::set_depth(int p_depth) {41depth = p_depth;42}4344void ScriptDebugger::insert_breakpoint(int p_line, const StringName &p_source) {45if (!breakpoints.has(p_line)) {46breakpoints[p_line] = HashSet<StringName>();47}48breakpoints[p_line].insert(p_source);49}5051void ScriptDebugger::remove_breakpoint(int p_line, const StringName &p_source) {52if (!breakpoints.has(p_line)) {53return;54}5556breakpoints[p_line].erase(p_source);57if (breakpoints[p_line].is_empty()) {58breakpoints.erase(p_line);59}60}6162String ScriptDebugger::breakpoint_find_source(const String &p_source) const {63return p_source;64}6566void ScriptDebugger::clear_breakpoints() {67breakpoints.clear();68}6970void ScriptDebugger::set_skip_breakpoints(bool p_skip_breakpoints) {71skip_breakpoints = p_skip_breakpoints;72}7374bool ScriptDebugger::is_skipping_breakpoints() {75return skip_breakpoints;76}7778void ScriptDebugger::set_ignore_error_breaks(bool p_ignore) {79ignore_error_breaks = p_ignore;80}8182bool ScriptDebugger::is_ignoring_error_breaks() {83return ignore_error_breaks;84}8586void ScriptDebugger::debug(ScriptLanguage *p_lang, bool p_can_continue, bool p_is_error_breakpoint) {87ScriptLanguage *prev = break_lang;88break_lang = p_lang;89EngineDebugger::get_singleton()->debug(p_can_continue, p_is_error_breakpoint);90break_lang = prev;91}9293void ScriptDebugger::send_error(const String &p_func, const String &p_file, int p_line, const String &p_err, const String &p_descr, bool p_editor_notify, ErrorHandlerType p_type, const Vector<StackInfo> &p_stack_info) {94// Store stack info, this is ugly, but allows us to separate EngineDebugger and ScriptDebugger. There might be a better way.95error_stack_info.append_array(p_stack_info);96EngineDebugger::get_singleton()->send_error(p_func, p_file, p_line, p_err, p_descr, p_editor_notify, p_type);97error_stack_info.clear(); // Clear because this is thread local98}99100Vector<ScriptLanguage::StackInfo> ScriptDebugger::get_error_stack_info() const {101return error_stack_info;102}103104ScriptLanguage *ScriptDebugger::get_break_language() const {105return break_lang;106}107108109