Skip to content

Commit

Permalink
Integrate object file
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 2, 2022
1 parent fcad50c commit 081486b
Show file tree
Hide file tree
Showing 20 changed files with 693 additions and 629 deletions.
4 changes: 2 additions & 2 deletions Makefile
Expand Up @@ -90,7 +90,7 @@ $(OUT_BIN_DEBUG_INFO): $(DOCKER_BUILDER) | $(OUT_DIR)
$(call docker_builder_make,$@ VERSION=$(VERSION))
endif

lint:
lint: check-license
$(go_env) golangci-lint run

bpf_compile_tools = $(CMD_LLC) $(CMD_CLANG)
Expand Down Expand Up @@ -240,7 +240,7 @@ README.md: $(CMD_EMBEDMD) $(OUT_DIR)/help.txt deploy/manifests
$(CMD_EMBEDMD) -w README.md

.PHONY: format
format: go/fmt check-license
format: go/fmt

.PHONY: c/fmt
c/fmt:
Expand Down
4 changes: 3 additions & 1 deletion cmd/parca-agent/main.go
Expand Up @@ -51,6 +51,7 @@ import (
"github.com/parca-dev/parca-agent/pkg/discovery"
"github.com/parca-dev/parca-agent/pkg/ksym"
"github.com/parca-dev/parca-agent/pkg/logger"
"github.com/parca-dev/parca-agent/pkg/objectfile"
"github.com/parca-dev/parca-agent/pkg/target"
"github.com/parca-dev/parca-agent/pkg/template"
)
Expand Down Expand Up @@ -135,6 +136,7 @@ func main() {
}

ksymCache := ksym.NewKsymCache(logger)
objCache := objectfile.NewCache()

var (
configs discovery.Configs
Expand All @@ -159,7 +161,7 @@ func main() {
}

externalLabels := getExternalLabels(flags.ExternalLabel, flags.Node)
tm := target.NewManager(logger, reg, externalLabels, ksymCache, profileListener, debugInfoClient, flags.ProfilingDuration, flags.TempDir)
tm := target.NewManager(logger, reg, ksymCache, objCache, profileListener, debugInfoClient, flags.ProfilingDuration, externalLabels, flags.TempDir)

mux.Handle("/metrics", promhttp.HandlerFor(reg, promhttp.HandlerOpts{}))
mux.HandleFunc("/debug/pprof/", pprof.Index)
Expand Down
4 changes: 2 additions & 2 deletions pkg/containerutils/containerd/containerd.go
Expand Up @@ -92,10 +92,10 @@ func (c *Client) PIDFromContainerID(containerID string) (int, error) {
return -1, fmt.Errorf("container status reply from runtime doesn't contain 'info'")
}

containerdInspect := struct{ Pid int }{}
containerdInspect := struct{ PID int }{}
if err := json.Unmarshal([]byte(info), &containerdInspect); err != nil {
return -1, err
}

return containerdInspect.Pid, nil
return containerdInspect.PID, nil
}
37 changes: 37 additions & 0 deletions pkg/debuginfo/cache.go
@@ -0,0 +1,37 @@
// Copyright 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
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// 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

import (
"github.com/parca-dev/parca-agent/pkg/objectfile"
)

type cache struct {
files map[string]*debugInfoFile
}

func newCache() *cache {
return &cache{
files: make(map[string]*debugInfoFile),
}
}

func (c *cache) debugInfoFile(objFile *objectfile.ObjectFile) *debugInfoFile {
if dbgFile, ok := c.files[objFile.BuildID]; ok {
return dbgFile
}
dbgInfoFile := debugInfoFile{ObjectFile: objFile}
c.files[objFile.BuildID] = &dbgInfoFile
return &dbgInfoFile
}

0 comments on commit 081486b

Please sign in to comment.