overview_of_debugging_tools.rst 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285
  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. Debugger Panel
  13. --------------
  14. Many of Godot's debugging tools are part of the Debugger panel, which you can
  15. find information about in :ref:`doc_debugger_panel`.
  16. Debug menu options
  17. ------------------
  18. There are a few common debug options you can toggle on or off when running
  19. your game in the editor, which can help you in debugging your game.
  20. You can find these options in the **Debug** editor menu.
  21. .. image:: img/overview_debug.webp
  22. Here are the descriptions of the options:
  23. Deploy with Remote Debug
  24. ++++++++++++++++++++++++
  25. When this option is enabled, using one-click deploy will make the executable
  26. attempt to connect to this computer's IP so the running project can be debugged.
  27. This option is intended to be used for remote debugging (typically with a mobile
  28. device).
  29. You don't need to enable it to use the GDScript debugger locally.
  30. Small Deploy with Network Filesystem
  31. ++++++++++++++++++++++++++++++++++++
  32. This option speeds up testing for games with a large footprint on remote devices.
  33. When **Small Deploy with Network Filesystem** is on, instead of exporting the
  34. full game, deploying the game builds a minimal executable. The editor then
  35. provides files from the project over the network.
  36. Also, on Android, the game is deployed using the USB cable to speed up
  37. deployment.
  38. Visible Collision Shapes
  39. ++++++++++++++++++++++++
  40. When this option is enabled, collision shapes and raycast nodes (for 2D and 3D)
  41. will be visible in the running project.
  42. Visible Paths
  43. +++++++++++++
  44. When this option is enabled, curve resources used by path nodes will be visible
  45. in the running project.
  46. Visible Navigation
  47. ++++++++++++++++++
  48. When this option is enabled, navigation meshes, and polygons will be visible in
  49. the running project.
  50. Visible Avoidance
  51. +++++++++++++++++
  52. When this option is enabled, avoidance object shapes, radiuses, and velocities
  53. will be visible in the running project.
  54. Debug CanvasItem Redraws
  55. ++++++++++++++++++++++++
  56. When this option is enabled, redraw requests of 2D objects will become visible
  57. (as a short flash) in the running project.
  58. This is useful to troubleshoot low processor mode.
  59. Synchronize Scene Changes
  60. ++++++++++++++++++++++++++
  61. When this option is enabled, any changes made to the scene in the editor will be
  62. replicated in the running project.
  63. When used remotely on a device, this is more efficient when the network
  64. filesystem option is enabled.
  65. Synchronize Script Changes
  66. +++++++++++++++++++++++++++
  67. When this option is enabled, any changes made to the script in the editor will
  68. be reloaded in the running project. When used
  69. remotely on a device, this is more efficient with the network filesystem.
  70. Keep Debug Server Open
  71. ++++++++++++++++++++++
  72. When this option is enabled, the editor debug server will stay open and listen
  73. for new sessions started outside of the editor itself.
  74. Customize Run Instances...
  75. ++++++++++++++++++++++++++
  76. This opens a dialog allowing you to tell Godot to run multiple instances of the
  77. game at once, and to specify the command line arguments for each instance. This
  78. is especially useful when building and debugging multiplayer games.
  79. .. image:: img/customize_run_instances.webp
  80. Enable Multiple Instances
  81. ^^^^^^^^^^^^^^^^^^^^^^^^^
  82. When this option is enabled, the editor will run multiple instances of the
  83. project at once when you Run Project.
  84. Below this checkbox is a selector to pick how many instances to run.
  85. Checking the box and setting this to only 1 is the same as not checking this box
  86. at all.
  87. Main Run Args
  88. ^^^^^^^^^^^^^
  89. These are the arguments that will be passed to **every** instance of the project
  90. when you Run Project, unless you select "Enabled" under "Override Main Run Args"
  91. for a specific instance.
  92. Note that these arguments are space-separated.
  93. .. tip::
  94. These arguments can be accessed in your script by using
  95. :ref:`get_cmdline_args<class_OS_method_get_cmdline_args>`.
  96. .. warning::
  97. Even if you uncheck "Enable Multiple Instances" these arguments will be
  98. passed when you Run Project.
  99. Main Feature Tags
  100. ^^^^^^^^^^^^^^^^^
  101. These are the feature tags that will be passed to **every** instance of the
  102. project when you Run Project, unless you select "Enabled" under "Override Main
  103. Tags" for a specific instance.
  104. Override Main Run Args
  105. ^^^^^^^^^^^^^^^^^^^^^^
  106. When this is enabled, the arguments in the "Main Run Args" field will **not be
  107. passed** to this specific instance of the project when you Run Project.
  108. Launch Arguments
  109. ^^^^^^^^^^^^^^^^
  110. These are the arguments that will be passed to this specific instance of the
  111. project when you Run Project. They will be **combined with** the "Main Run Args"
  112. unless you select "Enabled" under "Override Main Run Args".
  113. Override Main Tags
  114. ^^^^^^^^^^^^^^^^^^
  115. When this is enabled, the tags in the "Main Feature Tags" field will **not be
  116. passed** to this specific instance of the project when you Run Project.
  117. Feature Tags
  118. ^^^^^^^^^^^^
  119. These are the feature tags that will be passed to this specific instance of the
  120. project when you Run Project. They will be **combined with** the "Main Feature
  121. Tags" unless you select "Enabled" under "Override Main Tags".
  122. .. warning::
  123. If you want to pass "User" arguments, that can be accessed with
  124. :ref:`get_cmdline_user_args<class_OS_method_get_cmdline_user_args>` then you
  125. must prefix them with two dashes **and a space** like `-- one two three`.
  126. Be aware that these dashes will apply to arguments added later in the
  127. "Launch Arguments" on a per instance basis, which can cause some confusion
  128. when combining the `Main Run Args` and `Launch Arguments`.
  129. If you place `-- one two three` in the "Main Run Args" and `-- four five
  130. six` in the "Launch Arguments" then the final command line arguments will be
  131. `one two three -- four five six`. This is because the `--` is repeated in
  132. the "Launch Arguments".
  133. .. _doc_debugger_tools_and_options:
  134. Script editor debug tools and options
  135. -------------------------------------
  136. The script editor has its own set of debug tools for use with breakpoints and
  137. two options. The breakpoint tools can also be found in the **Debugger** tab
  138. of the debugger.
  139. .. tip::
  140. You can create a breakpoint by clicking the gutter in the left of the script
  141. editor (on the left of the line numbers). When hovering this gutter, you
  142. will see a transparent red dot appearing, which turns into an opaque red dot
  143. after the breakpoint is placed by clicking. Click the red dot again to
  144. remove the breakpoint. Breakpoints created this way persist across editor
  145. restarts, even if the script wasn't saved when exiting the editor.
  146. You can also use the ``breakpoint`` keyword in GDScript to create a
  147. breakpoint that is stored in the script itself. Unlike breakpoints created by
  148. clicking in the gutter, this keyword-based breakpoint is persistent across
  149. different machines when using version control.
  150. .. image:: img/overview_script_editor.webp
  151. The **Break** button causes a break in the script like a breakpoint would.
  152. **Continue** makes the game continue after pausing at a breakpoint.
  153. **Step Over** goes to the next line of code, and **Step Into** goes into
  154. a function if possible. Otherwise, it does the same thing as **Step Over**.
  155. The **Debug with External Editor** option lets you debug your game with an external editor.
  156. You can set a shortcut for it in **Editor Settings > Shortcuts > Debugger**.
  157. When the debugger breaks on a breakpoint, a green triangle arrow is visible in
  158. the script editor's gutter. This arrow indicates the line of code the debugger
  159. broke on.
  160. Debug project settings
  161. ----------------------
  162. In the project settings, there is a **Debug** category with subcategories which
  163. control different things. Enable **Advanced Settings** to change these settings.
  164. Settings
  165. ++++++++
  166. These are some general settings such as printing the current FPS
  167. to the **Output** panel, the maximum amount of functions when profiling
  168. and others.
  169. File Logging
  170. ++++++++++++
  171. These settings allow you to log console output and error messages to files.
  172. GDScript
  173. ++++++++
  174. These settings allow you to toggle specific GDScript warnings, such as for
  175. unused variables. You can also turn off warnings completely. See
  176. :ref:`doc_gdscript_warning_system` for more information.
  177. Shader Language
  178. +++++++++++++++
  179. These settings allow you to toggle specific shader warnings, such as for
  180. unused variables. You can also turn off warnings completely.
  181. Canvas Items
  182. ++++++++++++
  183. These settings are for canvas item redraw debugging.
  184. Shapes
  185. ++++++
  186. Shapes are where you can adjust the color of shapes that only appear for
  187. debugging purposes, such as collision and navigation shapes.
  188. Remote in scene dock
  189. --------------------
  190. When running a game in the editor two options appear at the top of the **Scene**
  191. dock, **Remote** and **Local**. While using **Remote** you can inspect or change
  192. the nodes' parameters in the running project.
  193. .. image:: img/overview_remote.webp
  194. .. note:: Some editor settings related to debugging can be found inside
  195. the **Editor Settings**, under the **Network > Debug** and **Debugger** sections.