-
Notifications
You must be signed in to change notification settings - Fork 245
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
pyroscope.java: bump async-profiler binaries (#2341)
- Loading branch information
Showing
18 changed files
with
208 additions
and
230 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
//go:build darwin | ||
|
||
package asprof | ||
|
||
import ( | ||
_ "embed" | ||
"path/filepath" | ||
) | ||
|
||
//go:embed async-profiler-3.0-fa937db-macos.zip | ||
var embeddedArchiveData []byte | ||
|
||
// bin/asprof | ||
// lib/libasyncProfiler.dylib | ||
|
||
var embeddedArchiveVersion = 300 | ||
|
||
var EmbeddedArchive = Archive{data: embeddedArchiveData, version: embeddedArchiveVersion, format: ArchiveFormatZip} | ||
|
||
func (d *Distribution) LibPath() string { | ||
return filepath.Join(d.extractedDir, "lib/libasyncProfiler.dylib") | ||
} | ||
|
||
func (p *Profiler) CopyLib(dist *Distribution, pid int) error { | ||
return nil | ||
} | ||
|
||
func ProcessPath(path string, pid int) string { | ||
return path | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
//go:build linux && (amd64 || arm64) | ||
|
||
package asprof | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
"strconv" | ||
"strings" | ||
"path/filepath" | ||
) | ||
|
||
var embeddedArchiveVersion = 300 | ||
|
||
var EmbeddedArchive = Archive{data: embeddedArchiveData, version: embeddedArchiveVersion, format: ArchiveFormatTarGz} | ||
|
||
func (d *Distribution) LibPath() string { | ||
return filepath.Join(d.extractedDir, "lib/libasyncProfiler.so") | ||
} | ||
|
||
func (p *Profiler) CopyLib(dist *Distribution, pid int) error { | ||
fsMutex.Lock() | ||
defer fsMutex.Unlock() | ||
libData, err := os.ReadFile(dist.LibPath()) | ||
if err != nil { | ||
return err | ||
} | ||
launcherData, err := os.ReadFile(dist.LauncherPath()) | ||
if err != nil { | ||
return err | ||
} | ||
procRoot := ProcessPath("/", pid) | ||
procRootFile, err := os.Open(procRoot) | ||
if err != nil { | ||
return fmt.Errorf("failed to open proc root %s: %w", procRoot, err) | ||
} | ||
defer procRootFile.Close() | ||
dstLibPath := strings.TrimPrefix(dist.LibPath(), "/") | ||
dstLauncherPath := strings.TrimPrefix(dist.LauncherPath(), "/") | ||
if err = writeFile(procRootFile, dstLibPath, libData, false); err != nil { | ||
return err | ||
} | ||
// this is to create a bin directory, we don't actually need to write anything there, and we don't execute the launcher there | ||
if err = writeFile(procRootFile, dstLauncherPath, launcherData, false); err != nil { | ||
return err | ||
} | ||
return nil | ||
} | ||
|
||
func ProcessPath(path string, pid int) string { | ||
f := procFile{path, pid} | ||
return f.procRootPath() | ||
} | ||
|
||
type procFile struct { | ||
path string | ||
pid int | ||
} | ||
|
||
func (f *procFile) procRootPath() string { | ||
return filepath.Join("/proc", strconv.Itoa(f.pid), "root", f.path) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.