delve/Documentation/usage/dlv_trace.md
Archana Ravindar 89123a0000
pkg/terminal,service/debugger: Support to add a new suboption --follow-calls to trace subcommand (#3594)
* rebasing on master to implement --followcalls

* in progress changes to enable --followcalls

* rebase to master: modified function to add children to funcs array

* modify main traversal loop

* added tests to check different scenarios

* added tests to check different scenarios

* added tests to check different scenarios

* add test to check for overlapping regular expression

* modified type of strings array as a return only

* changed depth to a simple integer instead of a global map

* avoid calling traverse on recursive calls

* Added tests for various call graphs to test trace followfuncs

* Added tests for various call graphs to test trace followfuncs

* Added tests for various call graphs to test trace followfuncs

* made auxillary changes for build to go through for new option follow-calls

* Add support to print depth of the function calls as well

* Added two sample output files for checking

* Bypass morestack_noctxt in output for verification testing

* Corrected newline error by adding newlines only if the line does not match morestack_noctxt

* Added more tests

* Cleanup

* Updated documentation

* fixed error message in fmt.Errorf

* Fixed result of Errorf not used error

* Addressing review comments to fix depth reporting and other issues

* dont invoke stacktrace if tracefollowcalls is enabled, compute depth from main regex root symbol than main.main

* Addressing a part of review comments

* Added changes to allow deferred functions to be picked up for tracing

* Fix issue to avoid printing stack for a simple trace option

* Moving most tests to integration2_test.go and keeping only one in dlv_test.go

* Moving most tests to integration2_test.go and keeping only one in dlv_test.go

* Adding panic-defer test case

* Moved rest of the tests to integration2_test.go

* addressing review comments: folding Functions and FunctionsDeep, reducing branches by using depth prefix, wrap using %w and other comments

* Optimize traversal and parts of printing trace point function and modify trace output layout
and adjust tests accordingly

* Resolved error occurring due to staticcheck

* Implemented traversal algorithm using breadth first search

* Addressing review comments on the breadth first search implementation and
other comments

* Inline filterRuntimeFuncs and remove duplicate initialization
2024-06-12 12:35:48 -07:00

2.1 KiB

dlv trace

Compile and begin tracing program.

Synopsis

Trace program execution.

The trace sub command will set a tracepoint on every function matching the provided regular expression and output information when tracepoint is hit. This is useful if you do not want to begin an entire debug session, but merely want to know what functions your process is executing.

The output of the trace sub command is printed to stderr, so if you would like to only see the output of the trace operations you can redirect stdout.

dlv trace [package] regexp [flags]

Options

      --ebpf               Trace using eBPF (experimental).
  -e, --exec string        Binary file to exec and trace.
      --follow-calls int   Trace all children of the function to the required depth
  -h, --help               help for trace
      --output string      Output path for the binary.
  -p, --pid int            Pid to attach to.
  -s, --stack int          Show stack trace with given depth. (Ignored with --ebpf)
  -t, --test               Trace a test binary.
      --timestamp          Show timestamp in the output

Options inherited from parent commands

      --backend string         Backend selection (see 'dlv help backend'). (default "default")
      --build-flags string     Build flags, to be passed to the compiler. For example: --build-flags="-tags=integration -mod=vendor -cover -v"
      --check-go-version       Exits if the version of Go in use is not compatible (too old or too new) with the version of Delve. (default true)
      --disable-aslr           Disables address space randomization
      --log                    Enable debugging server logging.
      --log-dest string        Writes logs to the specified file or file descriptor (see 'dlv help log').
      --log-output string      Comma separated list of components that should produce debug output (see 'dlv help log')
  -r, --redirect stringArray   Specifies redirect rules for target process (see 'dlv help redirect')
      --wd string              Working directory for running the program.

SEE ALSO

  • dlv - Delve is a debugger for the Go programming language.