{{about|the command that runs time profiler and function trace|the performance profiler|Commands/perf|the jvm profiler|Commands/jfr|other uses of "debug"|Debug}}
{{exclusive|java}}
{{Infobox command
|name=debug
|oplevel=3
}}
Starts or stops a time profiler session. Gets more detailed information of function execution.
== Syntax ==
debug start
: Starts a new debug time profiler session.
debug stop
: Stops the active debug time profiler session.
debug function
: Used the same way as [[Commands/function|/function]] to get more detailed information of commands' execution. Could not be called directly or indirectly by {{cmd|return run}} or another {{cmd|debug function}}.
== Arguments ==
{{argument|name|function}}
: {{arg desc|je=function}}
== Result ==
{{Result table|onlyje=1}}
{{Result table|The command is incomplete, or any argument is not specified correctly.|unparseable}}
{{Result table|cmd=/debug start|A debug profiling session has already been started.|fail}}
{{Result table|cmd=/debug stop|There's no debug profiling session running.}}
{{Result table|cmd=/debug function|The specified functions or function tags do not exist.}}
{{Result table|cmd=/debug function|This command execution is caused by {{cmd|return run}} or another {{cmd|debug function}}.}}
{{Result table|cmd=|succeed}}
{{Result table}}
== Output ==
{{Output table}}
{{Output table|edition=je|On fail|N/A|0|0}}
{{Output table|cmd=/debug start|On success|N/A|1|0}}
{{Output table|cmd=/debug stop|On success|N/A|1|the average tps (ticks per second) during debug profiling}}
{{Output table|cmd=/debug function|On success|N/A|1|the total number of commands in the functions}}
{{Output table}}
== File structure ==
=== Function trace ===
When using {{cmd|debug function|link=none}}, a txt file titled '''debug-trace-yyyy-MM-dd_HH.mm.ss.txt''' is created in .minecraft/debug.
In this file,
*[C]
means the
is executed.
*[M]
means a message is returned.
*[E]
means a failure message is returned.
*[R =
means the
returns a '''brigadier return value'''.
*[C]
means the
is executed and returns a '''brigadier return value'''.
*[F]
means a function is called.
For most of commands, the '''brigadier return value''' is equal to the result value that can be stored with /execute store result
.
But for /execute ...
'''with one or more of the following subcommands''', each branch returns its success value as its '''brigadier return value''':
* ... if ...
(not at the end)
* ... unless ...
(not at the end)
* ... as
* ... at
* ... positioned as
* ... rotated as
* ... facing entity
Some commands like /return
and /function
has no brigadier return value。
=== Profile result ===
{{Outdated feature|section=1}}
When using {{cmd|debug stop|link=none}}, a txt file titled '''profile-results-yyyy-MM-dd_HH.mm.ss.txt''' is created in .minecraft/debug, which includes the result of profile dump.
=== Report ===
{{Outdated feature|section=1}}
When using {{cmd|debug report|link=none}}, a ZIP file is created with in .minecraft/debug/profiling the following structure:
x,y,z,type
.
***** '''chunks.csv''': Contains a list of chunk information in the format {{cd|x,z,level,in_memory,status,full_status,accessible_ready,ticking_ready,entity_ticking_ready,ticket,spawning,entity_count,block_entity_count}}.
***** '''entities.csv''': Contains a list of [[entities]] in the world in the format {{cd|x,y,z,uuid,type,alive,custom_name}}.
***** '''example_crash.txt''': An example crash file.
***** '''stats.txt''': Contains some stats.
** '''classpath.txt''': Contains the file paths of the external jars ''Minecraft'' uses.
** '''example_crash.txt''': An example crash file.
** '''gamerules.txt''': A plain text file containing a list of [[game rule]]s and their values (=
).
** '''stats.txt''': Contains some stats.
** '''threads.txt''': All running threads.