2
0

overview_of_debugging_tools.rst 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219
  1. .. _doc_overview_of_debugging_tools:
  2. Overview of debugging tools
  3. ===========================
  4. This guide will give you an overview of the available debugging tools in the
  5. engine.
  6. Godot comes with a powerful debugger and profilers to track down bugs, inspect
  7. your game at runtime, monitor essential metrics, and measure performances.
  8. It also offers options to visualize collision boxes and navigation polygons
  9. in the running game.
  10. Finally, you have options to debug the game running on a remote device
  11. and to reload changes to your scenes or your code while the game is running.
  12. Debug menu options
  13. ------------------
  14. There are a few common debug options you can toggle on or off when running
  15. your game in the editor, which can help you in debugging your game.
  16. You can find these options in the **Debug** editor menu.
  17. .. image:: img/overview_debug.png
  18. Here are the descriptions of the options:
  19. Deploy with Remote Debug
  20. ++++++++++++++++++++++++
  21. When exporting and deploying, the resulting executable will attempt to connect
  22. to the IP of your computer for debugging.
  23. Small Deploy with Network FS
  24. ++++++++++++++++++++++++++++
  25. This option speeds up testing for games with a large footprint on remote devices.
  26. When **Small Deploy with Network FS** is on, instead of exporting the full game,
  27. deploying the game builds a minimal executable. The editor then provides files
  28. from the project over the network.
  29. Also, on Android, the game is deployed using the USB cable to speed up deployment.
  30. Visible Collision Shapes
  31. ++++++++++++++++++++++++
  32. This option makes collision shapes and raycast nodes visible in the running game.
  33. Visible Navigation
  34. ++++++++++++++++++
  35. Navigation meshes and polygons will be visible on the running game.
  36. Sync Scene Changes
  37. ++++++++++++++++++
  38. With this option, any change you make to a scene in the editor at runtime
  39. appears instantly. When used remotely on a device, this is more efficient
  40. with the network filesystem.
  41. Sync Script Changes
  42. +++++++++++++++++++
  43. Any script that is saved will be reloaded on the running game. When used
  44. remotely on a device, this is more efficient with the network filesystem.
  45. Script editor debug tools and options
  46. -------------------------------------
  47. The script editor has its own set of debug tools for use with breakpoints and
  48. two options. The breakpoint tools can also be found in the **Debugger** tab
  49. of the debugger.
  50. .. image:: img/overview_script_editor.png
  51. The **Break** button causes a break in the script like a breakpoint would.
  52. **Continue** makes the game continue after pausing at a breakpoint.
  53. **Step Over** goes to the next line of code, and **Step Into** goes into
  54. a function if possible. Otherwise, it does the same thing as **Step Over**.
  55. The **Keep Debugger Open** option keeps the debugger open after a scene
  56. has been closed. And the **Debug with External Editor** option lets you
  57. debug your game with an external editor.
  58. Debug project settings
  59. ----------------------
  60. In the project settings, there is a **Debug** category with three subcategories
  61. which control different things.
  62. Settings
  63. ++++++++
  64. These are some general settings such as printing the current FPS
  65. to the **Output** panel, the maximum amount of functions when profiling
  66. and others.
  67. GDScript
  68. ++++++++
  69. These settings allow you to toggle specific GDScript warnings, such as for
  70. unused variables. You can also turn off warnings completely.
  71. Shapes
  72. ++++++
  73. Shapes are where you can adjust the color of shapes that only appear for
  74. debugging purposes, such as collision and navigation shapes.
  75. Debugging tools
  76. ---------------
  77. You can find the debugger in the bottom panel. Click on **Debugger** to open it.
  78. .. image:: img/overview_debugger.png
  79. The debugger is split into several tabs, each focusing on a specific task.
  80. Debugger
  81. ++++++++
  82. The debugger tab opens automatically when the GDScript compiler reaches
  83. a breakpoint in your code.
  84. It gives you a `stack trace <https://en.wikipedia.org/wiki/Stack_trace>`__,
  85. information about the state of the object, and buttons to control
  86. the program's execution.
  87. You can use the buttons in the top-right to:
  88. - Skip all breakpoints. That way, you can save breakpoints for future
  89. debugging sessions.
  90. - Copy the current error message.
  91. - **Step Into** the code. This button takes you to the next line of code,
  92. and if it's a function, it steps line-by-line through the function.
  93. - **Step Over** the code. This button goes to the next line of code,
  94. but it doesn't step line-by-line through functions.
  95. - **Break**. This button pauses the game's execution.
  96. - **Continue**. This button resumes the game after a breakpoint or pause.
  97. Errors
  98. ++++++
  99. This is where errors and warning messages are printed while running the game.
  100. Profiler
  101. ++++++++
  102. The debugger comes with three profilers for your processor, network operations,
  103. and video memory.
  104. The profiler is used to show why individual frames take as long as they do
  105. to process and render.
  106. Unlike other debugging tools, the profiler does not start automatically. It can
  107. be started at any time during gameplay by pressing the start button. You can
  108. even start the profiler before opening the game to profile startup performance.
  109. It can also be started and stopped while the game is running without losing
  110. information from when it was last running. The information it records won't
  111. go away unless you click clear, or close the game, reopen it and start
  112. the profiler again.
  113. After starting and stopping the profiler you should see things being kept track
  114. of on the left and a graph on the right. The items listed on the left are
  115. everything that contributes to frame time, and they should each have a value
  116. for time and calls for the current frame you are looking at.
  117. The frame number in the top right tells you which frame you are currently
  118. looking at. You can change this by using the up or down arrows, typing in the
  119. frame number, or clicking on the graph.
  120. If you want to add something to your graph, or think it looks too cluttered,
  121. you can check and uncheck the box next to an item to add or remove it
  122. from the graph.
  123. Network Profiler
  124. ++++++++++++++++
  125. The Network Profiler contains a list of all the nodes that communicate over the
  126. multiplayer API and, for each one, some counters on the amount of incoming and
  127. outgoing network interactions. It also features a bandwidth meter that displays
  128. the total bandwidth usage at any given moment.
  129. Monitors
  130. ++++++++
  131. The monitors are graphs of several aspects of the game while its running such as
  132. FPS, memory usage, how many nodes are in a scene and more. All monitors keep
  133. track of stats automatically, so even if one monitor isn't open while the game
  134. is running, you can open it later and see how the values changed.
  135. Video Memory
  136. ++++++++++++
  137. The **Video Mem** tab lists the video memory usage of the running game
  138. and the resources using it.
  139. Misc
  140. ++++
  141. The **Misc** tab contains tools to identify the control nodes you are clicking
  142. at runtime:
  143. - **Clicked Control** tells you where the clicked node is in the scene tree.
  144. - **Clicked Control Type** tells you the type of the node you clicked is.
  145. Remote in scene dock
  146. --------------------
  147. When running a game in the editor two options appear at the top of the **Scene**
  148. dock, **Remote** and **Local**. While using **Remote** you can inspect or change
  149. the nodes' parameters in the running project.
  150. .. image:: img/overview_remote.png
  151. .. note:: Some editor settings related to debugging can be found inside
  152. the **Editor Settings**, under the **Network > Debug** and **Debugger** sections.