script_editor_debugger.h 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219
  1. /*************************************************************************/
  2. /* script_editor_debugger.h */
  3. /*************************************************************************/
  4. /* This file is part of: */
  5. /* GODOT ENGINE */
  6. /* https://godotengine.org */
  7. /*************************************************************************/
  8. /* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
  9. /* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
  10. /* */
  11. /* Permission is hereby granted, free of charge, to any person obtaining */
  12. /* a copy of this software and associated documentation files (the */
  13. /* "Software"), to deal in the Software without restriction, including */
  14. /* without limitation the rights to use, copy, modify, merge, publish, */
  15. /* distribute, sublicense, and/or sell copies of the Software, and to */
  16. /* permit persons to whom the Software is furnished to do so, subject to */
  17. /* the following conditions: */
  18. /* */
  19. /* The above copyright notice and this permission notice shall be */
  20. /* included in all copies or substantial portions of the Software. */
  21. /* */
  22. /* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
  23. /* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
  24. /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
  25. /* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
  26. /* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
  27. /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
  28. /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
  29. /*************************************************************************/
  30. #ifndef SCRIPT_EDITOR_DEBUGGER_H
  31. #define SCRIPT_EDITOR_DEBUGGER_H
  32. #include "core/io/packet_peer.h"
  33. #include "core/io/tcp_server.h"
  34. #include "property_editor.h"
  35. #include "scene/gui/box_container.h"
  36. #include "scene/gui/button.h"
  37. class Tree;
  38. class PropertyEditor;
  39. class EditorNode;
  40. class ScriptEditorDebuggerVariables;
  41. class LineEdit;
  42. class TabContainer;
  43. class RichTextLabel;
  44. class TextureButton;
  45. class AcceptDialog;
  46. class TreeItem;
  47. class HSplitContainer;
  48. class ItemList;
  49. class EditorProfiler;
  50. class ScriptEditorDebuggerInspectedObject;
  51. class ScriptEditorDebugger : public Control {
  52. OBJ_TYPE(ScriptEditorDebugger, Control);
  53. AcceptDialog *msgdialog;
  54. Button *debugger_button;
  55. LineEdit *clicked_ctrl;
  56. LineEdit *clicked_ctrl_type;
  57. LineEdit *live_edit_root;
  58. Button *le_set;
  59. Button *le_clear;
  60. Tree *inspect_scene_tree;
  61. float inspect_scene_tree_timeout;
  62. float inspect_edited_object_timeout;
  63. ObjectID inspected_object_id;
  64. Map<ObjectID, ScriptEditorDebuggerInspectedObject *> remote_objects;
  65. bool updating_scene_tree;
  66. Set<ObjectID> unfold_cache;
  67. HSplitContainer *error_split;
  68. ItemList *error_list;
  69. ItemList *error_stack;
  70. int error_count;
  71. int last_error_count;
  72. bool hide_on_stop;
  73. TabContainer *tabs;
  74. LineEdit *reason;
  75. ScriptEditorDebuggerVariables *variables;
  76. Button *step;
  77. Button *next;
  78. Button *back;
  79. Button *forward;
  80. Button *dobreak;
  81. Button *docontinue;
  82. List<Vector<float> > perf_history;
  83. Vector<float> perf_max;
  84. Vector<TreeItem *> perf_items;
  85. Map<int, String> profiler_signature;
  86. Tree *perf_monitors;
  87. Control *perf_draw;
  88. Tree *vmem_tree;
  89. Button *vmem_refresh;
  90. LineEdit *vmem_total;
  91. Tree *stack_dump;
  92. PropertyEditor *inspector;
  93. Ref<TCP_Server> server;
  94. Ref<StreamPeerTCP> connection;
  95. Ref<PacketPeerStream> ppeer;
  96. String message_type;
  97. Array message;
  98. int pending_in_queue;
  99. HashMap<NodePath, int> node_path_cache;
  100. int last_path_id;
  101. Map<String, int> res_path_cache;
  102. EditorProfiler *profiler;
  103. EditorNode *editor;
  104. bool breaked;
  105. bool live_debug;
  106. void _performance_draw();
  107. void _performance_select(Object *, int, bool);
  108. void _stack_dump_frame_selected();
  109. void _output_clear();
  110. void _scene_tree_folded(Object *obj);
  111. void _scene_tree_selected();
  112. void _scene_tree_request();
  113. void _parse_message(const String &p_msg, const Array &p_data);
  114. Variant _unserialize_variant(const DVector<uint8_t> &data, PropertyInfo &r_info, int &r_len);
  115. void _scene_tree_property_select_object(ObjectID p_object);
  116. void _scene_tree_property_value_edited(const String &p_prop, const Variant &p_value);
  117. void _scene_tree_variable_value_edited(const String &p_prop, const Variant &p_value);
  118. void _video_mem_request();
  119. int _get_node_path_cache(const NodePath &p_path);
  120. int _get_res_path_cache(const String &p_path);
  121. void _live_edit_set();
  122. void _live_edit_clear();
  123. void _method_changed(Object *p_base, const StringName &p_name, VARIANT_ARG_DECLARE);
  124. void _property_changed(Object *p_base, const StringName &p_property, const Variant &p_value);
  125. static void _method_changeds(void *p_ud, Object *p_base, const StringName &p_name, VARIANT_ARG_DECLARE);
  126. static void _property_changeds(void *p_ud, Object *p_base, const StringName &p_property, const Variant &p_value);
  127. void _error_selected(int p_idx);
  128. void _error_stack_selected(int p_idx);
  129. void _profiler_activate(bool p_enable);
  130. void _profiler_seeked();
  131. void _paused();
  132. void _set_remote_object(ObjectID p_id, ScriptEditorDebuggerInspectedObject *p_obj);
  133. void _clear_remote_objects();
  134. protected:
  135. void _notification(int p_what);
  136. static void _bind_methods();
  137. public:
  138. void start();
  139. void pause();
  140. void unpause();
  141. void stop();
  142. void debug_next();
  143. void debug_step();
  144. void debug_break();
  145. void debug_continue();
  146. bool is_connected() const;
  147. String get_var_value(const String &p_var) const;
  148. void set_live_debugging(bool p_enable);
  149. void live_debug_create_node(const NodePath &p_parent, const String &p_type, const String &p_name);
  150. void live_debug_instance_node(const NodePath &p_parent, const String &p_path, const String &p_name);
  151. void live_debug_remove_node(const NodePath &p_at);
  152. void live_debug_remove_and_keep_node(const NodePath &p_at, ObjectID p_keep_id);
  153. void live_debug_restore_node(ObjectID p_id, const NodePath &p_at, int p_at_pos);
  154. void live_debug_duplicate_node(const NodePath &p_at, const String &p_new_name);
  155. void live_debug_reparent_node(const NodePath &p_at, const NodePath &p_new_place, const String &p_new_name, int p_at_pos);
  156. void set_breakpoint(const String &p_path, int p_line, bool p_enabled);
  157. void update_live_edit_root();
  158. void set_hide_on_stop(bool p_hide);
  159. void set_tool_button(Button *p_tb) { debugger_button = p_tb; }
  160. void reload_scripts();
  161. virtual Size2 get_minimum_size() const;
  162. ScriptEditorDebugger(EditorNode *p_editor = NULL);
  163. ~ScriptEditorDebugger();
  164. };
  165. #endif // SCRIPT_EDITOR_DEBUGGER_H