From 3a451b1d4db12d4ffb5dc5bb62a12d6606c75099 Mon Sep 17 00:00:00 2001 From: Kemal Akkoyun Date: Thu, 3 Mar 2022 09:13:26 +0100 Subject: [PATCH] Clean up Signed-off-by: Kemal Akkoyun --- Dockerfile.dev | 2 -- Makefile | 2 +- pkg/debuginfo/debuginfo.go | 21 ++++++++++----------- pkg/debuginfo/extract.go | 9 +++++---- pkg/debuginfo/find.go | 5 +++-- 5 files changed, 19 insertions(+), 20 deletions(-) diff --git a/Dockerfile.dev b/Dockerfile.dev index 39673ee0a7..4efdf5f85f 100644 --- a/Dockerfile.dev +++ b/Dockerfile.dev @@ -20,8 +20,6 @@ RUN make bpf COPY . /parca-agent RUN make build -# TODO(kakkoyun): Add Delve - RUN cp /parca-agent/dist/parca-agent /bin/parca-agent RUN mkdir -p /tmp diff --git a/Makefile b/Makefile index 2b30c4dc52..47564767c8 100644 --- a/Makefile +++ b/Makefile @@ -231,7 +231,7 @@ $(OUT_DIR)/help.txt: $(OUT_BIN) $(CMD_EMBEDMD): go install github.com/campoy/embedmd@latest -DOC_VERSION := "latest" # TODO(kakkoyun): Get the latest release after project goes public. Or leave as is? +DOC_VERSION := "latest" .PHONY: deploy/manifests deploy/manifests: $(MAKE) -C deploy VERSION=$(DOC_VERSION) manifests diff --git a/pkg/debuginfo/debuginfo.go b/pkg/debuginfo/debuginfo.go index 63de23f369..5f5eb17cb3 100644 --- a/pkg/debuginfo/debuginfo.go +++ b/pkg/debuginfo/debuginfo.go @@ -1,4 +1,4 @@ -// Copyright 2021 The Parca Authors +// Copyright (c) 2022 The Parca Authors // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at @@ -10,6 +10,7 @@ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. +// package debuginfo @@ -128,11 +129,10 @@ func (di *DebugInfo) EnsureUploaded(ctx context.Context, objFiles []*objectfile. } func (di *DebugInfo) exists(ctx context.Context, buildID, filePath string) bool { - // TODO(kakkoyun): Enable. - //if _, ok := di.existsCache.Get(buildID); ok { - // level.Debug(di.logger).Log("msg", "debug info already uploaded to server", "buildid", buildID, "path", filePath) - // return true - //} + if _, ok := di.existsCache.Get(buildID); ok { + level.Debug(di.logger).Log("msg", "debug info already uploaded to server", "buildid", buildID, "path", filePath) + return true + } exists, err := di.client.Exists(ctx, buildID) if err != nil { @@ -163,11 +163,10 @@ func (di *DebugInfo) debugInfoFilePath(ctx context.Context, buildID string, objF path string shouldCleanup bool } - // TODO(kakkoyun): Enable. - //if val, ok := di.debugInfoFileCache.Get(buildID); ok { - // res := val.(result) - // return res.path, res.shouldCleanup - //} + if val, ok := di.debugInfoFileCache.Get(buildID); ok { + res := val.(result) + return res.path, res.shouldCleanup + } dbgInfoPath, err := di.Extract(ctx, buildID, objFile.Path) if err == nil && dbgInfoPath != "" { diff --git a/pkg/debuginfo/extract.go b/pkg/debuginfo/extract.go index a1d6315ea2..db3561fa79 100644 --- a/pkg/debuginfo/extract.go +++ b/pkg/debuginfo/extract.go @@ -1,4 +1,4 @@ -// Copyright 2022 The Parca Authors +// Copyright (c) 2022 The Parca Authors // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at @@ -10,6 +10,7 @@ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. +// package debuginfo @@ -97,7 +98,7 @@ func (e *Extractor) Extract(ctx context.Context, buildID, filePath string) (stri hasSymtab, err := hasSymbols(filePath) if err != nil { level.Debug(e.logger).Log( - "msg", "failed to determine whether file has symbols", + "msg", "failed to determine whether file has symbol sections", "file", filePath, "err", err, ) } @@ -136,7 +137,7 @@ func (e *Extractor) Extract(ctx context.Context, buildID, filePath string) (stri case hasSymtab: cmd = e.objcopy(ctx, filePath, outFile, toRemove) default: - cmd = e.strip(ctx, interimDir, filePath, outFile, toRemove) + return "", errors.New("no debug information found in the binary") } const msg = "failed to extract debug information from binary" if err := e.run(cmd); err != nil { @@ -267,7 +268,7 @@ func hasSymbols(filePath string) (bool, error) { defer ef.Close() for _, section := range ef.Sections { - if section.Type == elf.SHT_SYMTAB { + if section.Type == elf.SHT_SYMTAB || section.Type == elf.SHT_DYNSYM { return true, nil } } diff --git a/pkg/debuginfo/find.go b/pkg/debuginfo/find.go index 86284f42d0..af58e850a2 100644 --- a/pkg/debuginfo/find.go +++ b/pkg/debuginfo/find.go @@ -1,4 +1,4 @@ -// Copyright 2022 The Parca Authors +// Copyright (c) 2022 The Parca Authors // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at @@ -10,6 +10,7 @@ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. +// package debuginfo @@ -87,7 +88,7 @@ func find(buildID, root string) (string, error) { file string ) // TODO(kakkoyun): Distros may have different locations for debuginfo files. - // Add support for all of them. + // Add support for all of them. Add an issue fir this. err := filepath.Walk(path.Join(root, "/usr/lib/debug"), func(path string, info os.FileInfo, err error) error { if err != nil { return err