debugger_panel.rst 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  1. .. _doc_debugger_panel:
  2. Debugger panel
  3. ==============
  4. Many of Godot's debugging tools, including the debugger, can be found in the
  5. debugger panel at the bottom of the screen. Click on **Debugger** to open it.
  6. .. image:: img/overview_debugger.webp
  7. The debugger panel is split into several tabs, each focusing on a specific task.
  8. Debugger
  9. --------
  10. The Debugger tab opens automatically when the GDScript compiler reaches
  11. a breakpoint in your code.
  12. It gives you a `stack trace <https://en.wikipedia.org/wiki/Stack_trace>`__,
  13. information about the state of the object, and buttons to control the program's
  14. execution. When the debugger breaks on a breakpoint, a green triangle arrow is
  15. visible in the script editor's gutter. This arrow indicates the line of code the
  16. debugger broke on.
  17. .. tip::
  18. You can create a breakpoint by clicking the gutter in the left of the script
  19. editor (on the left of the line numbers). When hovering this gutter, you
  20. will see a transparent red dot appearing, which turns into an opaque red dot
  21. after the breakpoint is placed by clicking. Click the red dot again to
  22. remove the breakpoint. Breakpoints created this way persist across editor
  23. restarts, even if the script wasn't saved when exiting the editor.
  24. You can also use the ``breakpoint`` keyword in GDScript to create a
  25. breakpoint that is stored in the script iself. Unlike breakpoints created by
  26. clicking in the gutter, this keyword-based breakpoint is persistent across
  27. different machines when using version control.
  28. You can use the buttons in the top-right corner to:
  29. - Skip all breakpoints. That way, you can save breakpoints for future
  30. debugging sessions.
  31. - Copy the current error message.
  32. - **Step Into** the code. This button takes you to the next line of code,
  33. and if it's a function, it steps line-by-line through the function.
  34. - **Step Over** the code. This button goes to the next line of code,
  35. but it doesn't step line-by-line through functions.
  36. - **Break**. This button pauses the game's execution.
  37. - **Continue**. This button resumes the game after a breakpoint or pause.
  38. .. warning::
  39. Breakpoints won't break on code if it's
  40. :ref:`running in a thread <doc_using_multiple_threads>`.
  41. This is a current limitation of the GDScript debugger.
  42. Errors
  43. ------
  44. This is where error and warning messages are printed while running the game.
  45. You can disable specific warnings in **Project Settings > Debug > GDScript**.
  46. Profiler
  47. --------
  48. The profiler is used to see what code is running while your project is in use,
  49. and how that effects performance.
  50. .. seealso::
  51. A detailed explanation of how to use the profiler can be found in the
  52. dedicated :ref:`doc_the_profiler` page.
  53. Visual Profiler
  54. ---------------
  55. The Visual Profiler can be used to monitor what is taking the most time when
  56. rendering a frame on the CPU and GPU respectively. This allows tracking sources
  57. of potential CPU and GPU bottlenecks caused by rendering.
  58. .. warning::
  59. The Visual Profiler only measures CPU time taken for rendering tasks, such
  60. as performing draw calls. The Visual Profiler does **not** include CPU time
  61. taken for other tasks such as scripting and physics. Use the standard
  62. Profiler tab to track non-rendering-related CPU tasks.
  63. To use the visual profiler, run the project, switch to the **Visual Profiler**
  64. tab within the Debugger bottom panel, then click **Start**:
  65. .. figure:: img/debugger_visual_profiler_results.webp
  66. :alt: Visual Profiler tab after clicking Start, waiting for a few seconds, then clicking Stop
  67. Visual Profiler tab after clicking **Start**, waiting for a few seconds, then clicking **Stop**
  68. You will see categories and results appearing as the profiler is running. Graph
  69. lines also appear, with the left side being a CPU framegraph and the right side
  70. being a GPU framegraph.
  71. Click **Stop** to finish profiling, which will keep the results visible but
  72. frozen in place. Results remain visible after stopping the running project, but
  73. not after exiting the editor.
  74. Click on result categories on the left to highlight them in the CPU and GPU
  75. graphs on the right. You can also click on the graph to move the cursor to a
  76. specific frame number and highlight the selected data type in the result
  77. categories on the left.
  78. You can switch the result display between a time value (in milliseconds per
  79. frame) or a percentage of the target frametime (which is currently hardcoded to
  80. 16.67 milliseconds, or 60 FPS).
  81. If framerate spikes occur during profiling, this can cause the graph to be
  82. poorly scaled. Disable **Fit to Frame** so that the graph will zoom onto the 60
  83. FPS+ portion.
  84. .. note::
  85. Remember that Visual Profiler results can vary **heavily** based on
  86. viewport resolution, which is determined by the window size if using the
  87. ``disabled`` or ``canvas_items`` :ref:`stretch modes
  88. <doc_multiple_resolutions>`.
  89. When comparing results across different runs, make sure to use the same
  90. viewport size for all runs.
  91. Visual Profiler is supported when using any rendering method (Forward+, Mobile
  92. or Compatibility), but the reported categories will vary depending on the
  93. current rendering method as well as the enabled graphics features. For example,
  94. when using Forward+, a simple 2D scene with shadow-casting lights will result in
  95. the following categories appearing:
  96. .. figure:: img/debugger_visual_profiler_2d_example.webp
  97. :alt: Example results from a 2D scene in the Visual Profiler
  98. Example results from a 2D scene in the Visual Profiler
  99. To give another example with Forward+, a 3D scene with shadow-casting lights and
  100. various effects enabled will result in the following categories enabled:
  101. .. figure:: img/debugger_visual_profiler_3d_example.webp
  102. :alt: Example results from a 3D scene in the Visual Profiler
  103. Example results from a 3D scene in the Visual Profiler
  104. Notice how in the 3D example, several of the categories have **(Parallel)**
  105. appended to their name. This hints that multiple tasks are being performed in
  106. parallel on the GPU. This generally means that disabling only one of the
  107. features involved won't improve performance as much as anticipated, as the other
  108. task still needs to be performed sequentially.
  109. Network Profiler
  110. ----------------
  111. The Network Profiler contains a list of all the nodes that communicate over the
  112. multiplayer API and, for each one, some counters on the amount of incoming and
  113. outgoing network interactions. It also features a bandwidth meter that displays
  114. the total bandwidth usage at any given moment.
  115. .. note::
  116. The bandwidth meter does **not** take the :ref:`doc_high_level_multiplayer`
  117. API's own compression system into account. This means that changing the
  118. compression algorithm used will not change the metrics reported by the
  119. bandwidth meter.
  120. Monitors
  121. --------
  122. The monitors are graphs of several aspects of the game while its running such as
  123. FPS, memory usage, how many nodes are in a scene and more. All monitors keep
  124. track of stats automatically, so even if one monitor isn't open while the game
  125. is running, you can open it later and see how the values changed.
  126. .. seealso::
  127. In addition to the default performance monitors, you can also create
  128. :ref:`custom performance monitors <doc_custom_performance_monitors>`
  129. to track arbitrary values in your project.
  130. Video RAM
  131. ---------
  132. The **Video RAM** tab shows the video RAM usage of the game while it is running.
  133. It provides a list of every resource using video RAM by resource path, the type
  134. of resource it is, what format it is in, and how much Video RAM that resource is
  135. using. There is also a total video RAM usage number at the top right of the panel.
  136. .. image:: img/video_ram.png
  137. Misc
  138. ----
  139. The **Misc** tab contains tools to identify the control nodes you are clicking
  140. at runtime:
  141. - **Clicked Control** tells you where the clicked node is in the scene tree.
  142. - **Clicked Control Type** tells you the type of the node you clicked is.