delve/pkg/proc/debuginfod/debuginfod.go
Morten Linderud 8c392d2fdf
Implement source listing from debuginfo (#2885)
* service: Implement BuildID

Parse the BuildID of executables and provides it over the RPC
service.

Signed-off-by: Morten Linderud <morten@linderud.pw>

* command: Support debuinfod for file listing

Signed-off-by: Morten Linderud <morten@linderud.pw>

* debuginfod: create debuginfod package for common code

We remove the duplicated code and provide our a new debuginfod package.

Signed-off-by: Morten Linderud <morten@linderud.pw>

* starlark: Workaround for 'build_i_d'

Signed-off-by: Morten Linderud <morten@linderud.pw>

* command: Ensure we only overwrite path when one has been found

Signed-off-by: Morten Linderud <morten@linderud.pw>

* bininfo: Inline parseBuildID

Signed-off-by: Morten Linderud <morten@linderud.pw>
2022-01-30 13:39:30 -08:00

29 lines
587 B
Go

package debuginfod
import (
"os/exec"
"strings"
)
const debuginfodFind = "debuginfod-find"
func execFind(args ...string) (string, error) {
if _, err := exec.LookPath(debuginfodFind); err != nil {
return "", err
}
cmd := exec.Command(debuginfodFind, args...)
out, err := cmd.CombinedOutput()
if err != nil {
return "", err
}
return strings.TrimSpace(string(out)), err
}
func GetSource(buildid, filename string) (string, error) {
return execFind("source", buildid, filename)
}
func GetDebuginfo(buildid string) (string, error) {
return execFind("debuginfo", buildid)
}