177 lines
6.9 KiB
C++
177 lines
6.9 KiB
C++
/*************************************************************************/
|
|
/* editor_debugger_node.h */
|
|
/*************************************************************************/
|
|
/* This file is part of: */
|
|
/* GODOT ENGINE */
|
|
/* https://godotengine.org */
|
|
/*************************************************************************/
|
|
/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
|
|
/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
|
|
/* */
|
|
/* Permission is hereby granted, free of charge, to any person obtaining */
|
|
/* a copy of this software and associated documentation files (the */
|
|
/* "Software"), to deal in the Software without restriction, including */
|
|
/* without limitation the rights to use, copy, modify, merge, publish, */
|
|
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
|
/* permit persons to whom the Software is furnished to do so, subject to */
|
|
/* the following conditions: */
|
|
/* */
|
|
/* The above copyright notice and this permission notice shall be */
|
|
/* included in all copies or substantial portions of the Software. */
|
|
/* */
|
|
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
|
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
|
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
|
|
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
|
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
|
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
|
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
|
/*************************************************************************/
|
|
|
|
#ifndef EDITOR_DEBUGGER_NODE_H
|
|
#define EDITOR_DEBUGGER_NODE_H
|
|
|
|
#include "core/io/tcp_server.h"
|
|
#include "editor/debugger/script_editor_debugger.h"
|
|
#include "scene/gui/button.h"
|
|
#include "scene/gui/tab_container.h"
|
|
|
|
class EditorDebuggerTree;
|
|
|
|
class EditorDebuggerNode : public MarginContainer {
|
|
|
|
GDCLASS(EditorDebuggerNode, MarginContainer);
|
|
|
|
private:
|
|
enum Options {
|
|
DEBUG_NEXT,
|
|
DEBUG_STEP,
|
|
DEBUG_BREAK,
|
|
DEBUG_CONTINUE,
|
|
DEBUG_SHOW_KEEP_OPEN,
|
|
DEBUG_WITH_EXTERNAL_EDITOR,
|
|
};
|
|
|
|
class Breakpoint {
|
|
public:
|
|
String source;
|
|
int line = 0;
|
|
|
|
bool operator<(const Breakpoint &p_b) const {
|
|
if (line == p_b.line)
|
|
return line < p_b.line;
|
|
return line < p_b.line;
|
|
}
|
|
|
|
Breakpoint(){};
|
|
|
|
Breakpoint(const String &p_source, int p_line) {
|
|
line = p_line;
|
|
source = p_source;
|
|
}
|
|
};
|
|
|
|
Ref<TCP_Server> server = NULL;
|
|
TabContainer *tabs = NULL;
|
|
Button *debugger_button = NULL;
|
|
MenuButton *script_menu = NULL;
|
|
|
|
Ref<Script> stack_script; // Why?!?
|
|
|
|
int last_error_count = 0;
|
|
int last_warning_count = 0;
|
|
|
|
float inspect_edited_object_timeout = 0;
|
|
EditorDebuggerTree *remote_scene_tree = NULL;
|
|
float remote_scene_tree_timeout = 0.0;
|
|
bool auto_switch_remote_scene_tree = false;
|
|
bool debug_with_external_editor = false;
|
|
bool hide_on_stop = true;
|
|
ScriptEditorDebugger::CameraOverride camera_override = ScriptEditorDebugger::OVERRIDE_NONE;
|
|
Map<Breakpoint, bool> breakpoints;
|
|
|
|
ScriptEditorDebugger *_add_debugger();
|
|
EditorDebuggerRemoteObject *get_inspected_remote_object();
|
|
|
|
friend class DebuggerEditorPlugin;
|
|
static EditorDebuggerNode *singleton;
|
|
EditorDebuggerNode();
|
|
|
|
protected:
|
|
void _debugger_stopped(int p_id);
|
|
void _debugger_wants_stop(int p_id);
|
|
void _debugger_changed(int p_tab);
|
|
void _remote_tree_updated(int p_debugger);
|
|
void _remote_object_updated(ObjectID p_id, int p_debugger);
|
|
void _remote_object_property_updated(ObjectID p_id, const String &p_property, int p_debugger);
|
|
void _remote_object_requested(ObjectID p_id, int p_debugger);
|
|
void _save_node_requested(ObjectID p_id, const String &p_file, int p_debugger);
|
|
|
|
void _clear_execution(REF p_script) {
|
|
emit_signal("clear_execution", p_script);
|
|
}
|
|
|
|
void _text_editor_stack_goto(const ScriptEditorDebugger *p_debugger);
|
|
void _stack_frame_selected(int p_debugger);
|
|
void _error_selected(const String &p_file, int p_line, int p_debugger);
|
|
void _breaked(bool p_breaked, bool p_can_debug, int p_debugger);
|
|
void _paused();
|
|
void _break_state_changed();
|
|
void _menu_option(int p_id);
|
|
|
|
protected:
|
|
void _notification(int p_what);
|
|
static void _bind_methods();
|
|
|
|
public:
|
|
static EditorDebuggerNode *get_singleton() { return singleton; }
|
|
|
|
ScriptEditorDebugger *get_current_debugger() const;
|
|
ScriptEditorDebugger *get_default_debugger() const;
|
|
ScriptEditorDebugger *get_debugger(int p_debugger) const;
|
|
|
|
void debug_next() { get_default_debugger()->debug_next(); }
|
|
void debug_step() { get_default_debugger()->debug_step(); }
|
|
void debug_break() { get_default_debugger()->debug_break(); }
|
|
void debug_continue() { get_default_debugger()->debug_continue(); }
|
|
|
|
void set_script_debug_button(MenuButton *p_button);
|
|
|
|
void set_tool_button(Button *p_button) {
|
|
debugger_button = p_button;
|
|
}
|
|
|
|
String get_var_value(const String &p_var) const { return get_default_debugger()->get_var_value(p_var); }
|
|
Ref<Script> get_dump_stack_script() const { return stack_script; } // Why do we need this?
|
|
|
|
bool get_debug_with_external_editor() { return debug_with_external_editor; }
|
|
|
|
bool is_skip_breakpoints() const;
|
|
void set_breakpoint(const String &p_path, int p_line, bool p_enabled);
|
|
void reload_scripts();
|
|
|
|
// Remote inspector/edit.
|
|
void request_remote_tree();
|
|
static void _method_changeds(void *p_ud, Object *p_base, const StringName &p_name, VARIANT_ARG_DECLARE);
|
|
static void _property_changeds(void *p_ud, Object *p_base, const StringName &p_property, const Variant &p_value);
|
|
|
|
// LiveDebug
|
|
void set_live_debugging(bool p_enabled);
|
|
void update_live_edit_root();
|
|
void live_debug_create_node(const NodePath &p_parent, const String &p_type, const String &p_name);
|
|
void live_debug_instance_node(const NodePath &p_parent, const String &p_path, const String &p_name);
|
|
void live_debug_remove_node(const NodePath &p_at);
|
|
void live_debug_remove_and_keep_node(const NodePath &p_at, ObjectID p_keep_id);
|
|
void live_debug_restore_node(ObjectID p_id, const NodePath &p_at, int p_at_pos);
|
|
void live_debug_duplicate_node(const NodePath &p_at, const String &p_new_name);
|
|
void live_debug_reparent_node(const NodePath &p_at, const NodePath &p_new_place, const String &p_new_name, int p_at_pos);
|
|
|
|
// Camera
|
|
void set_camera_override(ScriptEditorDebugger::CameraOverride p_override) { camera_override = p_override; }
|
|
ScriptEditorDebugger::CameraOverride get_camera_override() { return camera_override; }
|
|
|
|
Error start();
|
|
|
|
void stop();
|
|
};
|
|
#endif // EDITOR_DEBUGGER_NODE_H
|