github.com/neilgarb/delve@v1.9.2-nobreaks/Documentation/cli/README.md (about)

     1  # Configuration and Command History
     2  
     3  If `$XDG_CONFIG_HOME` is set, then configuration and command history files are located in `$XDG_CONFIG_HOME/dlv`. Otherwise, they are located in `$HOME/.config/dlv` on Linux and `$HOME/.dlv` on other systems.
     4  
     5  The configuration file `config.yml` contains all the configurable options and their default values. The command history is stored in `.dbg_history`.
     6  
     7  # Commands
     8  
     9  ## Running the program
    10  
    11  Command | Description
    12  --------|------------
    13  [call](#call) | Resumes process, injecting a function call (EXPERIMENTAL!!!)
    14  [continue](#continue) | Run until breakpoint or program termination.
    15  [next](#next) | Step over to next source line.
    16  [rebuild](#rebuild) | Rebuild the target executable and restarts it. It does not work if the executable was not built by delve.
    17  [restart](#restart) | Restart process.
    18  [rev](#rev) | Reverses the execution of the target program for the command specified.
    19  [rewind](#rewind) | Run backwards until breakpoint or start of recorded history.
    20  [step](#step) | Single step through program.
    21  [step-instruction](#step-instruction) | Single step a single cpu instruction.
    22  [stepout](#stepout) | Step out of the current function.
    23  
    24  
    25  ## Manipulating breakpoints
    26  
    27  Command | Description
    28  --------|------------
    29  [break](#break) | Sets a breakpoint.
    30  [breakpoints](#breakpoints) | Print out info for active breakpoints.
    31  [clear](#clear) | Deletes breakpoint.
    32  [clearall](#clearall) | Deletes multiple breakpoints.
    33  [condition](#condition) | Set breakpoint condition.
    34  [on](#on) | Executes a command when a breakpoint is hit.
    35  [toggle](#toggle) | Toggles on or off a breakpoint.
    36  [trace](#trace) | Set tracepoint.
    37  [watch](#watch) | Set watchpoint.
    38  
    39  
    40  ## Viewing program variables and memory
    41  
    42  Command | Description
    43  --------|------------
    44  [args](#args) | Print function arguments.
    45  [display](#display) | Print value of an expression every time the program stops.
    46  [examinemem](#examinemem) | Examine raw memory at the given address.
    47  [locals](#locals) | Print local variables.
    48  [print](#print) | Evaluate an expression.
    49  [regs](#regs) | Print contents of CPU registers.
    50  [set](#set) | Changes the value of a variable.
    51  [vars](#vars) | Print package variables.
    52  [whatis](#whatis) | Prints type of an expression.
    53  
    54  
    55  ## Listing and switching between threads and goroutines
    56  
    57  Command | Description
    58  --------|------------
    59  [goroutine](#goroutine) | Shows or changes current goroutine
    60  [goroutines](#goroutines) | List program goroutines.
    61  [thread](#thread) | Switch to the specified thread.
    62  [threads](#threads) | Print out info for every traced thread.
    63  
    64  
    65  ## Viewing the call stack and selecting frames
    66  
    67  Command | Description
    68  --------|------------
    69  [deferred](#deferred) | Executes command in the context of a deferred call.
    70  [down](#down) | Move the current frame down.
    71  [frame](#frame) | Set the current frame, or execute command on a different frame.
    72  [stack](#stack) | Print stack trace.
    73  [up](#up) | Move the current frame up.
    74  
    75  
    76  ## Other commands
    77  
    78  Command | Description
    79  --------|------------
    80  [check](#check) | Creates a checkpoint at the current position.
    81  [checkpoints](#checkpoints) | Print out info for existing checkpoints.
    82  [clear-checkpoint](#clear-checkpoint) | Deletes checkpoint.
    83  [config](#config) | Changes configuration parameters.
    84  [disassemble](#disassemble) | Disassembler.
    85  [dump](#dump) | Creates a core dump from the current process state
    86  [edit](#edit) | Open where you are in $DELVE_EDITOR or $EDITOR
    87  [exit](#exit) | Exit the debugger.
    88  [funcs](#funcs) | Print list of functions.
    89  [help](#help) | Prints the help message.
    90  [libraries](#libraries) | List loaded dynamic libraries
    91  [list](#list) | Show source code.
    92  [source](#source) | Executes a file containing a list of delve commands
    93  [sources](#sources) | Print list of source files.
    94  [transcript](#transcript) | Appends command output to a file.
    95  [types](#types) | Print list of types
    96  
    97  ## args
    98  Print function arguments.
    99  
   100  	[goroutine <n>] [frame <m>] args [-v] [<regex>]
   101  
   102  If regex is specified only function arguments with a name matching it will be returned. If -v is specified more information about each function argument will be shown.
   103  
   104  
   105  ## break
   106  Sets a breakpoint.
   107  
   108  	break [name] [locspec]
   109  
   110  See [Documentation/cli/locspec.md](//github.com/go-delve/delve/tree/master/Documentation/cli/locspec.md) for the syntax of locspec. If locspec is omitted a breakpoint will be set on the current line.
   111  
   112  See also: "help on", "help cond" and "help clear"
   113  
   114  Aliases: b
   115  
   116  ## breakpoints
   117  Print out info for active breakpoints.
   118  	
   119  	breakpoints [-a]
   120  
   121  Specifying -a prints all physical breakpoint, including internal breakpoints.
   122  
   123  Aliases: bp
   124  
   125  ## call
   126  Resumes process, injecting a function call (EXPERIMENTAL!!!)
   127  	
   128  	call [-unsafe] <function call expression>
   129  	
   130  Current limitations:
   131  - only pointers to stack-allocated objects can be passed as argument.
   132  - only some automatic type conversions are supported.
   133  - functions can only be called on running goroutines that are not
   134    executing the runtime.
   135  - the current goroutine needs to have at least 256 bytes of free space on
   136    the stack.
   137  - functions can only be called when the goroutine is stopped at a safe
   138    point.
   139  - calling a function will resume execution of all goroutines.
   140  - only supported on linux's native backend.
   141  
   142  
   143  
   144  ## check
   145  Creates a checkpoint at the current position.
   146  
   147  	checkpoint [note]
   148  
   149  The "note" is arbitrary text that can be used to identify the checkpoint, if it is not specified it defaults to the current filename:line position.
   150  
   151  Aliases: checkpoint
   152  
   153  ## checkpoints
   154  Print out info for existing checkpoints.
   155  
   156  
   157  ## clear
   158  Deletes breakpoint.
   159  
   160  	clear <breakpoint name or id>
   161  
   162  
   163  ## clear-checkpoint
   164  Deletes checkpoint.
   165  
   166  	clear-checkpoint <id>
   167  
   168  Aliases: clearcheck
   169  
   170  ## clearall
   171  Deletes multiple breakpoints.
   172  
   173  	clearall [<locspec>]
   174  
   175  If called with the locspec argument it will delete all the breakpoints matching the locspec. If locspec is omitted all breakpoints are deleted.
   176  
   177  
   178  ## condition
   179  Set breakpoint condition.
   180  
   181  	condition <breakpoint name or id> <boolean expression>.
   182  	condition -hitcount <breakpoint name or id> <operator> <argument>.
   183  	condition -clear <breakpoint name or id>.
   184  
   185  Specifies that the breakpoint, tracepoint or watchpoint should break only if the boolean expression is true.
   186  
   187  See Documentation/cli/expr.md for a description of supported expressions.
   188  
   189  With the -hitcount option a condition on the breakpoint hit count can be set, the following operators are supported
   190  
   191  	condition -hitcount bp > n
   192  	condition -hitcount bp >= n
   193  	condition -hitcount bp < n
   194  	condition -hitcount bp <= n
   195  	condition -hitcount bp == n
   196  	condition -hitcount bp != n
   197  	condition -hitcount bp % n
   198  
   199  With the -clear option a condtion on the breakpoint can removed.
   200  	
   201  The '% n' form means we should stop at the breakpoint when the hitcount is a multiple of n.
   202  
   203  Examples:
   204  
   205  	cond 2 i == 10				breakpoint 2 will stop when variable i equals 10
   206  	cond name runtime.curg.goid == 5	breakpoint 'name' will stop only on goroutine 5
   207  	cond -clear 2				the condition on breakpoint 2 will be removed
   208  
   209  
   210  Aliases: cond
   211  
   212  ## config
   213  Changes configuration parameters.
   214  
   215  	config -list
   216  
   217  Show all configuration parameters.
   218  
   219  	config -save
   220  
   221  Saves the configuration file to disk, overwriting the current configuration file.
   222  
   223  	config <parameter> <value>
   224  
   225  Changes the value of a configuration parameter.
   226  
   227  	config substitute-path <from> <to>
   228  	config substitute-path <from>
   229  
   230  Adds or removes a path substitution rule.
   231  
   232  	config alias <command> <alias>
   233  	config alias <alias>
   234  
   235  Defines <alias> as an alias to <command> or removes an alias.
   236  
   237  
   238  ## continue
   239  Run until breakpoint or program termination.
   240  
   241  	continue [<locspec>]
   242  
   243  Optional locspec argument allows you to continue until a specific location is reached. The program will halt if a breakpoint is hit before reaching the specified location.
   244  
   245  For example:
   246  
   247  	continue main.main
   248  	continue encoding/json.Marshal
   249  
   250  
   251  Aliases: c
   252  
   253  ## deferred
   254  Executes command in the context of a deferred call.
   255  
   256  	deferred <n> <command>
   257  
   258  Executes the specified command (print, args, locals) in the context of the n-th deferred call in the current frame.
   259  
   260  
   261  ## disassemble
   262  Disassembler.
   263  
   264  	[goroutine <n>] [frame <m>] disassemble [-a <start> <end>] [-l <locspec>]
   265  
   266  If no argument is specified the function being executed in the selected stack frame will be executed.
   267  
   268  	-a <start> <end>	disassembles the specified address range
   269  	-l <locspec>		disassembles the specified function
   270  
   271  Aliases: disass
   272  
   273  ## display
   274  Print value of an expression every time the program stops.
   275  
   276  	display -a [%format] <expression>
   277  	display -d <number>
   278  
   279  The '-a' option adds an expression to the list of expression printed every time the program stops. The '-d' option removes the specified expression from the list.
   280  
   281  If display is called without arguments it will print the value of all expression in the list.
   282  
   283  
   284  ## down
   285  Move the current frame down.
   286  
   287  	down [<m>]
   288  	down [<m>] <command>
   289  
   290  Move the current frame down by <m>. The second form runs the command on the given frame.
   291  
   292  
   293  ## dump
   294  Creates a core dump from the current process state
   295  
   296  	dump <output file>
   297  
   298  The core dump is always written in ELF, even on systems (windows, macOS) where this is not customary. For environments other than linux/amd64 threads and registers are dumped in a format that only Delve can read back.
   299  
   300  
   301  ## edit
   302  Open where you are in $DELVE_EDITOR or $EDITOR
   303  
   304  	edit [locspec]
   305  	
   306  If locspec is omitted edit will open the current source file in the editor, otherwise it will open the specified location.
   307  
   308  Aliases: ed
   309  
   310  ## examinemem
   311  Examine raw memory at the given address.
   312  
   313  Examine memory:
   314  
   315  	examinemem [-fmt <format>] [-count|-len <count>] [-size <size>] <address>
   316  	examinemem [-fmt <format>] [-count|-len <count>] [-size <size>] -x <expression>
   317  
   318  Format represents the data format and the value is one of this list (default hex): bin(binary), oct(octal), dec(decimal), hex(hexadecimal), addr(address).
   319  Length is the number of bytes (default 1) and must be less than or equal to 1000.
   320  Address is the memory location of the target to examine. Please note '-len' is deprecated by '-count and -size'.
   321  Expression can be an integer expression or pointer value of the memory location to examine.
   322  
   323  For example:
   324  
   325      x -fmt hex -count 20 -size 1 0xc00008af38
   326      x -fmt hex -count 20 -size 1 -x 0xc00008af38 + 8
   327      x -fmt hex -count 20 -size 1 -x &myVar
   328      x -fmt hex -count 20 -size 1 -x myPtrVar
   329  
   330  Aliases: x
   331  
   332  ## exit
   333  Exit the debugger.
   334  		
   335  	exit [-c]
   336  	
   337  When connected to a headless instance started with the --accept-multiclient, pass -c to resume the execution of the target process before disconnecting.
   338  
   339  Aliases: quit q
   340  
   341  ## frame
   342  Set the current frame, or execute command on a different frame.
   343  
   344  	frame <m>
   345  	frame <m> <command>
   346  
   347  The first form sets frame used by subsequent commands such as "print" or "set".
   348  The second form runs the command on the given frame.
   349  
   350  
   351  ## funcs
   352  Print list of functions.
   353  
   354  	funcs [<regex>]
   355  
   356  If regex is specified only the functions matching it will be returned.
   357  
   358  
   359  ## goroutine
   360  Shows or changes current goroutine
   361  
   362  	goroutine
   363  	goroutine <id>
   364  	goroutine <id> <command>
   365  
   366  Called without arguments it will show information about the current goroutine.
   367  Called with a single argument it will switch to the specified goroutine.
   368  Called with more arguments it will execute a command on the specified goroutine.
   369  
   370  Aliases: gr
   371  
   372  ## goroutines
   373  List program goroutines.
   374  
   375  	goroutines [-u|-r|-g|-s] [-t [depth]] [-l] [-with loc expr] [-without loc expr] [-group argument]
   376  
   377  Print out info for every goroutine. The flag controls what information is shown along with each goroutine:
   378  
   379  	-u	displays location of topmost stackframe in user code (default)
   380  	-r	displays location of topmost stackframe (including frames inside private runtime functions)
   381  	-g	displays location of go instruction that created the goroutine
   382  	-s	displays location of the start function
   383  	-t	displays goroutine's stacktrace (an optional depth value can be specified, default: 10)
   384  	-l	displays goroutine's labels
   385  
   386  If no flag is specified the default is -u, i.e. the first frame within the first 30 frames that is not executing a runtime private function.
   387  
   388  FILTERING
   389  
   390  If -with or -without are specified only goroutines that match the given condition are returned.
   391  
   392  To only display goroutines where the specified location contains (or does not contain, for -without and -wo) expr as a substring, use:
   393  
   394  	goroutines -with (userloc|curloc|goloc|startloc) expr
   395  	goroutines -w (userloc|curloc|goloc|startloc) expr
   396  	goroutines -without (userloc|curloc|goloc|startloc) expr
   397  	goroutines -wo (userloc|curloc|goloc|startloc) expr
   398  	
   399  To only display goroutines that have (or do not have) the specified label key and value, use:
   400  	
   401  
   402  	goroutines -with label key=value
   403  	goroutines -without label key=value
   404  	
   405  To only display goroutines that have (or do not have) the specified label key, use:
   406  
   407  	goroutines -with label key
   408  	goroutines -without label key
   409  	
   410  To only display goroutines that are running (or are not running) on a OS thread, use:
   411  
   412  
   413  	goroutines -with running
   414  	goroutines -without running
   415  	
   416  To only display user (or runtime) goroutines, use:
   417  
   418  	goroutines -with user
   419  	goroutines -without user
   420  
   421  GROUPING
   422  
   423  	goroutines -group (userloc|curloc|goloc|startloc|running|user)
   424  
   425  Groups goroutines by the given location, running status or user classification, up to 5 goroutines per group will be displayed as well as the total number of goroutines in the group.
   426  
   427  	goroutines -group label key
   428  
   429  Groups goroutines by the value of the label with the specified key.
   430  
   431  
   432  Aliases: grs
   433  
   434  ## help
   435  Prints the help message.
   436  
   437  	help [command]
   438  
   439  Type "help" followed by the name of a command for more information about it.
   440  
   441  Aliases: h
   442  
   443  ## libraries
   444  List loaded dynamic libraries
   445  
   446  
   447  ## list
   448  Show source code.
   449  
   450  	[goroutine <n>] [frame <m>] list [<locspec>]
   451  
   452  Show source around current point or provided locspec.
   453  
   454  For example:
   455  
   456  	frame 1 list 69
   457  	list testvariables.go:10000
   458  	list main.main:30
   459  	list 40
   460  
   461  Aliases: ls l
   462  
   463  ## locals
   464  Print local variables.
   465  
   466  	[goroutine <n>] [frame <m>] locals [-v] [<regex>]
   467  
   468  The name of variables that are shadowed in the current scope will be shown in parenthesis.
   469  
   470  If regex is specified only local variables with a name matching it will be returned. If -v is specified more information about each local variable will be shown.
   471  
   472  
   473  ## next
   474  Step over to next source line.
   475  
   476  	next [count]
   477  
   478  Optional [count] argument allows you to skip multiple lines.
   479  
   480  
   481  Aliases: n
   482  
   483  ## on
   484  Executes a command when a breakpoint is hit.
   485  
   486  	on <breakpoint name or id> <command>
   487  	on <breakpoint name or id> -edit
   488  	
   489  
   490  Supported commands: print, stack, goroutine, trace and cond. 
   491  To convert a breakpoint into a tracepoint use:
   492  	
   493  	on <breakpoint name or id> trace
   494  
   495  The command 'on <bp> cond <cond-arguments>' is equivalent to 'cond <bp> <cond-arguments>'.
   496  
   497  The command 'on x -edit' can be used to edit the list of commands executed when the breakpoint is hit.
   498  
   499  
   500  ## print
   501  Evaluate an expression.
   502  
   503  	[goroutine <n>] [frame <m>] print [%format] <expression>
   504  
   505  See Documentation/cli/expr.md for a description of supported expressions.
   506  
   507  The optional format argument is a format specifier, like the ones used by the fmt package. For example "print %x v" will print v as an hexadecimal number.
   508  
   509  Aliases: p
   510  
   511  ## rebuild
   512  Rebuild the target executable and restarts it. It does not work if the executable was not built by delve.
   513  
   514  
   515  ## regs
   516  Print contents of CPU registers.
   517  
   518  	regs [-a]
   519  
   520  Argument -a shows more registers. Individual registers can also be displayed by 'print' and 'display'. See Documentation/cli/expr.md.
   521  
   522  
   523  ## restart
   524  Restart process.
   525  
   526  For recorded targets the command takes the following forms:
   527  
   528  	restart					resets to the start of the recording
   529  	restart [checkpoint]			resets the recording to the given checkpoint
   530  	restart -r [newargv...]	[redirects...]	re-records the target process
   531  	
   532  For live targets the command takes the following forms:
   533  
   534  	restart [newargv...] [redirects...]	restarts the process
   535  
   536  If newargv is omitted the process is restarted (or re-recorded) with the same argument vector.
   537  If -noargs is specified instead, the argument vector is cleared.
   538  
   539  A list of file redirections can be specified after the new argument list to override the redirections defined using the '--redirect' command line option. A syntax similar to Unix shells is used:
   540  
   541  	<input.txt	redirects the standard input of the target process from input.txt
   542  	>output.txt	redirects the standard output of the target process to output.txt
   543  	2>error.txt	redirects the standard error of the target process to error.txt
   544  
   545  
   546  Aliases: r
   547  
   548  ## rev
   549  Reverses the execution of the target program for the command specified.
   550  Currently, only the rev step-instruction command is supported.
   551  
   552  
   553  ## rewind
   554  Run backwards until breakpoint or start of recorded history.
   555  
   556  Aliases: rw
   557  
   558  ## set
   559  Changes the value of a variable.
   560  
   561  	[goroutine <n>] [frame <m>] set <variable> = <value>
   562  
   563  See Documentation/cli/expr.md for a description of supported expressions. Only numerical variables and pointers can be changed.
   564  
   565  
   566  ## source
   567  Executes a file containing a list of delve commands
   568  
   569  	source <path>
   570  	
   571  If path ends with the .star extension it will be interpreted as a starlark script. See [Documentation/cli/starlark.md](//github.com/go-delve/delve/tree/master/Documentation/cli/starlark.md) for the syntax.
   572  
   573  If path is a single '-' character an interactive starlark interpreter will start instead. Type 'exit' to exit.
   574  
   575  
   576  ## sources
   577  Print list of source files.
   578  
   579  	sources [<regex>]
   580  
   581  If regex is specified only the source files matching it will be returned.
   582  
   583  
   584  ## stack
   585  Print stack trace.
   586  
   587  	[goroutine <n>] [frame <m>] stack [<depth>] [-full] [-offsets] [-defer] [-a <n>] [-adepth <depth>] [-mode <mode>]
   588  
   589  	-full		every stackframe is decorated with the value of its local variables and arguments.
   590  	-offsets	prints frame offset of each frame.
   591  	-defer		prints deferred function call stack for each frame.
   592  	-a <n>		prints stacktrace of n ancestors of the selected goroutine (target process must have tracebackancestors enabled)
   593  	-adepth <depth>	configures depth of ancestor stacktrace
   594  	-mode <mode>	specifies the stacktrace mode, possible values are:
   595  			normal	- attempts to automatically switch between cgo frames and go frames
   596  			simple	- disables automatic switch between cgo and go
   597  			fromg	- starts from the registers stored in the runtime.g struct
   598  
   599  
   600  Aliases: bt
   601  
   602  ## step
   603  Single step through program.
   604  
   605  Aliases: s
   606  
   607  ## step-instruction
   608  Single step a single cpu instruction.
   609  
   610  Aliases: si
   611  
   612  ## stepout
   613  Step out of the current function.
   614  
   615  Aliases: so
   616  
   617  ## thread
   618  Switch to the specified thread.
   619  
   620  	thread <id>
   621  
   622  Aliases: tr
   623  
   624  ## threads
   625  Print out info for every traced thread.
   626  
   627  
   628  ## toggle
   629  Toggles on or off a breakpoint.
   630  
   631  toggle <breakpoint name or id>
   632  
   633  
   634  ## trace
   635  Set tracepoint.
   636  
   637  	trace [name] [locspec]
   638  
   639  A tracepoint is a breakpoint that does not stop the execution of the program, instead when the tracepoint is hit a notification is displayed. See [Documentation/cli/locspec.md](//github.com/go-delve/delve/tree/master/Documentation/cli/locspec.md) for the syntax of locspec. If locspec is omitted a tracepoint will be set on the current line.
   640  
   641  See also: "help on", "help cond" and "help clear"
   642  
   643  Aliases: t
   644  
   645  ## transcript
   646  Appends command output to a file.
   647  
   648  	transcript [-t] [-x] <output file>
   649  	transcript -off
   650  
   651  Output of Delve's command is appended to the specified output file. If '-t' is specified and the output file exists it is truncated. If '-x' is specified output to stdout is suppressed instead.
   652  
   653  Using the -off option disables the transcript.
   654  
   655  
   656  ## types
   657  Print list of types
   658  
   659  	types [<regex>]
   660  
   661  If regex is specified only the types matching it will be returned.
   662  
   663  
   664  ## up
   665  Move the current frame up.
   666  
   667  	up [<m>]
   668  	up [<m>] <command>
   669  
   670  Move the current frame up by <m>. The second form runs the command on the given frame.
   671  
   672  
   673  ## vars
   674  Print package variables.
   675  
   676  	vars [-v] [<regex>]
   677  
   678  If regex is specified only package variables with a name matching it will be returned. If -v is specified more information about each package variable will be shown.
   679  
   680  
   681  ## watch
   682  Set watchpoint.
   683  	
   684  	watch [-r|-w|-rw] <expr>
   685  	
   686  	-r	stops when the memory location is read
   687  	-w	stops when the memory location is written
   688  	-rw	stops when the memory location is read or written
   689  
   690  The memory location is specified with the same expression language used by 'print', for example:
   691  
   692  	watch v
   693  
   694  will watch the address of variable 'v'.
   695  
   696  Note that writes that do not change the value of the watched memory address might not be reported.
   697  
   698  See also: "help print".
   699  
   700  
   701  ## whatis
   702  Prints type of an expression.
   703  
   704  	whatis <expression>
   705  
   706