debugger_marshalls.h 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. /*************************************************************************/
  2. /* debugger_marshalls.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 DEBUGGER_MARSHARLLS_H
  31. #define DEBUGGER_MARSHARLLS_H
  32. #include "core/script_language.h"
  33. #include "servers/rendering_server.h"
  34. struct DebuggerMarshalls {
  35. // Memory usage
  36. struct ResourceInfo {
  37. String path;
  38. String format;
  39. String type;
  40. RID id;
  41. int vram;
  42. bool operator<(const ResourceInfo &p_img) const { return vram == p_img.vram ? id < p_img.id : vram > p_img.vram; }
  43. ResourceInfo() {
  44. vram = 0;
  45. }
  46. };
  47. struct ResourceUsage {
  48. List<ResourceInfo> infos;
  49. Array serialize();
  50. bool deserialize(const Array &p_arr);
  51. };
  52. // Network profiler
  53. struct MultiplayerNodeInfo {
  54. ObjectID node;
  55. String node_path;
  56. int incoming_rpc = 0;
  57. int incoming_rset = 0;
  58. int outgoing_rpc = 0;
  59. int outgoing_rset = 0;
  60. };
  61. struct NetworkProfilerFrame {
  62. Vector<MultiplayerNodeInfo> infos;
  63. Array serialize();
  64. bool deserialize(const Array &p_arr);
  65. };
  66. // Script Profiler
  67. class ScriptFunctionSignature {
  68. public:
  69. StringName name;
  70. int id = -1;
  71. Array serialize();
  72. bool deserialize(const Array &p_arr);
  73. };
  74. struct ScriptFunctionInfo {
  75. StringName name;
  76. int sig_id = -1;
  77. int call_count = 0;
  78. float self_time = 0;
  79. float total_time = 0;
  80. };
  81. // Servers profiler
  82. struct ServerFunctionInfo {
  83. StringName name;
  84. float time = 0;
  85. };
  86. struct ServerInfo {
  87. StringName name;
  88. List<ServerFunctionInfo> functions;
  89. };
  90. struct ServersProfilerFrame {
  91. int frame_number = 0;
  92. float frame_time = 0;
  93. float idle_time = 0;
  94. float physics_time = 0;
  95. float physics_frame_time = 0;
  96. float script_time = 0;
  97. List<ServerInfo> servers;
  98. Vector<ScriptFunctionInfo> script_functions;
  99. Array serialize();
  100. bool deserialize(const Array &p_arr);
  101. };
  102. struct ScriptStackVariable {
  103. String name;
  104. Variant value;
  105. int type;
  106. ScriptStackVariable() {
  107. type = -1;
  108. }
  109. Array serialize(int max_size = 1 << 20); // 1 MiB default.
  110. bool deserialize(const Array &p_arr);
  111. };
  112. struct ScriptStackDump {
  113. List<ScriptLanguage::StackInfo> frames;
  114. ScriptStackDump() {}
  115. Array serialize();
  116. bool deserialize(const Array &p_arr);
  117. };
  118. struct OutputError {
  119. int hr;
  120. int min;
  121. int sec;
  122. int msec;
  123. String source_file;
  124. String source_func;
  125. int source_line;
  126. String error;
  127. String error_descr;
  128. bool warning;
  129. Vector<ScriptLanguage::StackInfo> callstack;
  130. OutputError() {
  131. hr = -1;
  132. min = -1;
  133. sec = -1;
  134. msec = -1;
  135. source_line = -1;
  136. warning = false;
  137. }
  138. Array serialize();
  139. bool deserialize(const Array &p_arr);
  140. };
  141. // Visual Profiler
  142. struct VisualProfilerFrame {
  143. uint64_t frame_number;
  144. Vector<RS::FrameProfileArea> areas;
  145. Array serialize();
  146. bool deserialize(const Array &p_arr);
  147. };
  148. };
  149. #endif // DEBUGGER_MARSHARLLS_H