debugger_panel.rst 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  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 itself. 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. Errors
  39. ------
  40. This is where error and warning messages are printed while running the game.
  41. You can disable specific warnings in **Project Settings > Debug > GDScript**.
  42. Profiler
  43. --------
  44. The profiler is used to see what code is running while your project is in use,
  45. and how that effects performance.
  46. .. seealso::
  47. A detailed explanation of how to use the profiler can be found in the
  48. dedicated :ref:`doc_the_profiler` page.
  49. Visual Profiler
  50. ---------------
  51. The Visual Profiler can be used to monitor what is taking the most time when
  52. rendering a frame on the CPU and GPU respectively. This allows tracking sources
  53. of potential CPU and GPU bottlenecks caused by rendering.
  54. .. warning::
  55. The Visual Profiler only measures CPU time taken for rendering tasks, such
  56. as performing draw calls. The Visual Profiler does **not** include CPU time
  57. taken for other tasks such as scripting and physics. Use the standard
  58. Profiler tab to track non-rendering-related CPU tasks.
  59. To use the visual profiler, run the project, switch to the **Visual Profiler**
  60. tab within the Debugger bottom panel, then click **Start**:
  61. .. figure:: img/debugger_visual_profiler_results.webp
  62. :alt: Visual Profiler tab after clicking Start, waiting for a few seconds, then clicking Stop
  63. Visual Profiler tab after clicking **Start**, waiting for a few seconds, then clicking **Stop**
  64. You will see categories and results appearing as the profiler is running. Graph
  65. lines also appear, with the left side being a CPU framegraph and the right side
  66. being a GPU framegraph.
  67. Click **Stop** to finish profiling, which will keep the results visible but
  68. frozen in place. Results remain visible after stopping the running project, but
  69. not after exiting the editor.
  70. Click on result categories on the left to highlight them in the CPU and GPU
  71. graphs on the right. You can also click on the graph to move the cursor to a
  72. specific frame number and highlight the selected data type in the result
  73. categories on the left.
  74. You can switch the result display between a time value (in milliseconds per
  75. frame) or a percentage of the target frametime (which is currently hardcoded to
  76. 16.67 milliseconds, or 60 FPS).
  77. If framerate spikes occur during profiling, this can cause the graph to be
  78. poorly scaled. Disable **Fit to Frame** so that the graph will zoom onto the 60
  79. FPS+ portion.
  80. .. note::
  81. Remember that Visual Profiler results can vary **heavily** based on
  82. viewport resolution, which is determined by the window size if using the
  83. ``disabled`` or ``canvas_items`` :ref:`stretch modes
  84. <doc_multiple_resolutions>`.
  85. When comparing results across different runs, make sure to use the same
  86. viewport size for all runs.
  87. Visual Profiler is supported when using any rendering method (Forward+, Mobile
  88. or Compatibility), but the reported categories will vary depending on the
  89. current rendering method as well as the enabled graphics features. For example,
  90. when using Forward+, a simple 2D scene with shadow-casting lights will result in
  91. the following categories appearing:
  92. .. figure:: img/debugger_visual_profiler_2d_example.webp
  93. :alt: Example results from a 2D scene in the Visual Profiler
  94. Example results from a 2D scene in the Visual Profiler
  95. To give another example with Forward+, a 3D scene with shadow-casting lights and
  96. various effects enabled will result in the following categories enabled:
  97. .. figure:: img/debugger_visual_profiler_3d_example.webp
  98. :alt: Example results from a 3D scene in the Visual Profiler
  99. Example results from a 3D scene in the Visual Profiler
  100. Notice how in the 3D example, several of the categories have **(Parallel)**
  101. appended to their name. This hints that multiple tasks are being performed in
  102. parallel on the GPU. This generally means that disabling only one of the
  103. features involved won't improve performance as much as anticipated, as the other
  104. task still needs to be performed sequentially.
  105. Network Profiler
  106. ----------------
  107. The Network Profiler contains a list of all the nodes that communicate over the
  108. multiplayer API and, for each one, some counters on the amount of incoming and
  109. outgoing network interactions. It also features a bandwidth meter that displays
  110. the total bandwidth usage at any given moment.
  111. .. note::
  112. The bandwidth meter does **not** take the :ref:`doc_high_level_multiplayer`
  113. API's own compression system into account. This means that changing the
  114. compression algorithm used will not change the metrics reported by the
  115. bandwidth meter.
  116. Monitors
  117. --------
  118. The monitors are graphs of several aspects of the game while its running such as
  119. FPS, memory usage, how many nodes are in a scene and more. All monitors keep
  120. track of stats automatically, so even if one monitor isn't open while the game
  121. is running, you can open it later and see how the values changed.
  122. .. seealso::
  123. In addition to the default performance monitors, you can also create
  124. :ref:`custom performance monitors <doc_custom_performance_monitors>`
  125. to track arbitrary values in your project.
  126. Video RAM
  127. ---------
  128. The **Video RAM** tab shows the video RAM usage of the game while it is running.
  129. It provides a list of every resource using video RAM by resource path, the type
  130. of resource it is, what format it is in, and how much Video RAM that resource is
  131. using. There is also a total video RAM usage number at the top right of the panel.
  132. .. image:: img/video_ram.png
  133. Misc
  134. ----
  135. The **Misc** tab contains tools to identify the control nodes you are clicking
  136. at runtime:
  137. - **Clicked Control** tells you where the clicked node is in the scene tree.
  138. - **Clicked Control Type** tells you the type of the node you clicked is.