editor_debugger_plugin.h 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. /**************************************************************************/
  2. /* editor_debugger_plugin.h */
  3. /**************************************************************************/
  4. /* This file is part of: */
  5. /* GODOT ENGINE */
  6. /* https://godotengine.org */
  7. /**************************************************************************/
  8. /* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
  9. /* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
  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 EDITOR_DEBUGGER_PLUGIN_H
  31. #define EDITOR_DEBUGGER_PLUGIN_H
  32. #include "scene/gui/control.h"
  33. class ScriptEditorDebugger;
  34. class EditorDebuggerSession : public RefCounted {
  35. GDCLASS(EditorDebuggerSession, RefCounted);
  36. private:
  37. HashSet<Control *> tabs;
  38. ScriptEditorDebugger *debugger = nullptr;
  39. void _breaked(bool p_really_did, bool p_can_debug, const String &p_message, bool p_has_stackdump);
  40. void _started();
  41. void _stopped();
  42. void _debugger_gone_away();
  43. protected:
  44. static void _bind_methods();
  45. public:
  46. void detach_debugger();
  47. void add_session_tab(Control *p_tab);
  48. void remove_session_tab(Control *p_tab);
  49. void send_message(const String &p_message, const Array &p_args = Array());
  50. void toggle_profiler(const String &p_profiler, bool p_enable, const Array &p_data = Array());
  51. bool is_breaked();
  52. bool is_debuggable();
  53. bool is_active();
  54. void set_breakpoint(const String &p_path, int p_line, bool p_enabled);
  55. EditorDebuggerSession(ScriptEditorDebugger *p_debugger);
  56. ~EditorDebuggerSession();
  57. };
  58. class EditorDebuggerPlugin : public RefCounted {
  59. GDCLASS(EditorDebuggerPlugin, RefCounted);
  60. private:
  61. List<Ref<EditorDebuggerSession>> sessions;
  62. protected:
  63. static void _bind_methods();
  64. public:
  65. void create_session(ScriptEditorDebugger *p_debugger);
  66. void clear();
  67. virtual void setup_session(int p_idx);
  68. virtual bool capture(const String &p_message, const Array &p_data, int p_session);
  69. virtual bool has_capture(const String &p_capture) const;
  70. Ref<EditorDebuggerSession> get_session(int p_session_id);
  71. Array get_sessions();
  72. GDVIRTUAL3R(bool, _capture, const String &, const Array &, int);
  73. GDVIRTUAL1RC(bool, _has_capture, const String &);
  74. GDVIRTUAL1(_setup_session, int);
  75. virtual void goto_script_line(const Ref<Script> &p_script, int p_line);
  76. virtual void breakpoints_cleared_in_tree();
  77. virtual void breakpoint_set_in_tree(const Ref<Script> &p_script, int p_line, bool p_enabled);
  78. GDVIRTUAL2(_goto_script_line, const Ref<Script> &, int);
  79. GDVIRTUAL0(_breakpoints_cleared_in_tree);
  80. GDVIRTUAL3(_breakpoint_set_in_tree, const Ref<Script> &, int, bool);
  81. EditorDebuggerPlugin();
  82. ~EditorDebuggerPlugin();
  83. };
  84. #endif // EDITOR_DEBUGGER_PLUGIN_H