mirror of
https://github.com/go-delve/delve.git
synced 2025-10-29 09:46:56 +08:00
proc,service: return build informations for each package
Adds an API call that returns a list of packages contained in the program and the files that were used to build them, and also a best guess at which filesystem directory contained the package when it was built. This can be used by IDEs to map file paths if the debugging environment doesn't match the build environment exactly.
This commit is contained in:
committed by
Alessandro Arzilli
parent
0e0d689246
commit
a8606afb0b
@ -1337,6 +1337,35 @@ func (d *Debugger) GetVersion(out *api.GetVersionOut) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// ListPackagesBuildInfo returns the list of packages used by the program along with
|
||||
// the directory where each package was compiled and optionally the list of
|
||||
// files constituting the package.
|
||||
func (d *Debugger) ListPackagesBuildInfo(includeFiles bool) []api.PackageBuildInfo {
|
||||
d.processMutex.Lock()
|
||||
defer d.processMutex.Unlock()
|
||||
pkgs := d.target.BinInfo().ListPackagesBuildInfo(includeFiles)
|
||||
r := make([]api.PackageBuildInfo, 0, len(pkgs))
|
||||
for _, pkg := range pkgs {
|
||||
var files []string
|
||||
|
||||
if len(pkg.Files) > 0 {
|
||||
files = make([]string, 0, len(pkg.Files))
|
||||
for file := range pkg.Files {
|
||||
files = append(files, file)
|
||||
}
|
||||
}
|
||||
|
||||
sort.Strings(files)
|
||||
|
||||
r = append(r, api.PackageBuildInfo{
|
||||
ImportPath: pkg.ImportPath,
|
||||
DirectoryPath: pkg.DirectoryPath,
|
||||
Files: files,
|
||||
})
|
||||
}
|
||||
return r
|
||||
}
|
||||
|
||||
func go11DecodeErrorCheck(err error) error {
|
||||
if _, isdecodeerr := err.(dwarf.DecodeError); !isdecodeerr {
|
||||
return err
|
||||
|
||||
Reference in New Issue
Block a user