Skip to content

Commit

Permalink
Clean up
Browse files Browse the repository at this point in the history
Signed-off-by: Kemal Akkoyun <kakkoyun@gmail.com>
  • Loading branch information
kakkoyun committed Mar 3, 2022
1 parent d0a63dc commit 3a451b1
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 20 deletions.
2 changes: 0 additions & 2 deletions Dockerfile.dev
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion Makefile
Expand Up @@ -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
Expand Down
21 changes: 10 additions & 11 deletions 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
Expand All @@ -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

Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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 != "" {
Expand Down
9 changes: 5 additions & 4 deletions 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
Expand All @@ -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

Expand Down Expand Up @@ -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,
)
}
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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
}
}
Expand Down
5 changes: 3 additions & 2 deletions 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
Expand All @@ -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

Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 3a451b1

Please sign in to comment.