Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
Gandem committed Jun 11, 2024
1 parent 7ee4e58 commit 7ed4617
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
5 changes: 5 additions & 0 deletions libpf/pfelf/file.go
Original file line number Diff line number Diff line change
Expand Up @@ -486,6 +486,11 @@ func (f *File) GetGoBuildID() (string, error) {
return getGoBuildIDFromNotes(data)
}

// IsExecutable returns whether the ELF is executable
func (f *File) IsExecutable() bool {
return elf.Type(f.elfHeader.Type) == elf.ET_EXEC
}

// GetBuildID returns the ELF BuildID if present
func (f *File) GetBuildID() (string, error) {
s := f.Section(".note.gnu.build-id")
Expand Down
6 changes: 5 additions & 1 deletion processmanager/processinfo.go
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,11 @@ func (pm *ProcessManager) getELFInfo(pr process.Process, mapping *process.Mappin
buildID, _ = ef.GetGoBuildID()
}

pm.reporter.ExecutableMetadata(context.TODO(), fileID, baseName, mapping.Path, buildID)
execPath := ""
if ef.IsExecutable() {
execPath = mapping.Path
}
pm.reporter.ExecutableMetadata(context.TODO(), fileID, baseName, execPath, buildID)

return info
}
Expand Down
2 changes: 1 addition & 1 deletion reporter/datadog_reporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -512,7 +512,7 @@ func (r *DatadogReporter) getPprofProfile() (profile *pprofile.Profile,
loc.Mapping = getDummyMapping(fileIDtoMapping, profile, trace.files[i])
}
execInfo, exists := r.executables.Get(trace.files[i])

Check failure on line 514 in reporter/datadog_reporter.go

View workflow job for this annotation

GitHub Actions / Lint (stable)

shadow: declaration of "execInfo" shadows declaration at line 53 (govet)
if exists {
if exists && execInfo.filePath != "" {
lastExecPath = execInfo.filePath
}
sample.Location = append(sample.Location, loc)
Expand Down

0 comments on commit 7ed4617

Please sign in to comment.