From c3b79ebad069d9805076a432b475d5cdffa0db8b Mon Sep 17 00:00:00 2001 From: BEN GHORBEL Oussama Date: Tue, 31 Dec 2024 16:04:37 +0100 Subject: [PATCH] [#58] Update README.md --- cmd/builder/README.md | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/cmd/builder/README.md b/cmd/builder/README.md index bdb97243661..425f8590b62 100644 --- a/cmd/builder/README.md +++ b/cmd/builder/README.md @@ -110,7 +110,20 @@ Use `ocb --help` to learn about which flags are available. ## Debug -To keep the debug symbols in the resulting OpenTelemetry Collector binary, set the configuration property `debug_compilation` to true. +### Debug symbols + +By default, the LDflags are set to -s -w, which strips debugging symbols to produce a smaller OpenTelemetry Collector binary. To retain debugging symbols and DWARF debugging data in the binary, override the LDflags as shown: + +```console +ocb --ldflags=" " --config=builder-config.yaml. +``` + +### Debugging with Delve + +To ensure the code being executed matches the written code exactly, debugging symbols must be preserved, and compiler inlining and optimizations disabled. You can achieve this in two ways: + +1. Set the configuration property `debug_compilation` to true. +2. Manually override the ldflags and gcflags `ocb --ldflags=" " --gcflags="all=-N -l" --config=builder-config.yaml.` Then install `go-delve` and run OpenTelemetry Collector with `dlv` command as the following example: