delve/service/debugger/debugger_windows.go
Alessandro Arzilli 6f34add5db
proc,service/debugger: introduce TargetGroup abstraction (#3030)
Introduces a new TargetGroup abstraction that can be used to manage
multiple related targets.
No actual management of child processes is implemented here, this is
just a refactoring to make it possible to do that in the future.

Updates #2551
2022-07-14 14:14:45 -07:00

38 lines
646 B
Go

package debugger
import (
"debug/pe"
"fmt"
"os"
"os/exec"
"path/filepath"
"github.com/go-delve/delve/service/api"
)
func attachErrorMessage(pid int, err error) error {
return fmt.Errorf("could not attach to pid %d: %s", pid, err)
}
func verifyBinaryFormat(exePath string) error {
f, err := os.Open(exePath)
if err != nil {
return err
}
defer f.Close()
// Make sure the binary exists and is an executable file
if filepath.Base(exePath) == exePath {
if _, err := exec.LookPath(exePath); err != nil {
return err
}
}
exe, err := pe.NewFile(f)
if err != nil {
return api.ErrNotExecutable
}
exe.Close()
return nil
}