proc: Find executable should follow symbol links.
On linux platform, we simply treated `/proc/$pid/exe` as the executable of targeting process when doing `dlv attach`. The `/proc/$pid/exe` is a symbol link of the real executable file. Delve couldn't find the corrsponding external debug file based on the symbol link: ``` could not attach to pid $pid: could not open debug info ``` The fix is to evaluate the symbol links to the actual executable path.
This commit is contained in:
parent
37bee98a88
commit
3e04ad0fad
@ -119,7 +119,12 @@ func Attach(pid int, debugInfoDirs []string) (*proc.Target, error) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
tgt, err := dbp.initialize(findExecutable("", dbp.pid), debugInfoDirs)
|
||||
execPath, err := findExecutable(pid)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
tgt, err := dbp.initialize(execPath, debugInfoDirs)
|
||||
if err != nil {
|
||||
dbp.Detach(false)
|
||||
return nil, err
|
||||
@ -249,11 +254,9 @@ func (dbp *nativeProcess) updateThreadList() error {
|
||||
return linutil.ElfUpdateSharedObjects(dbp)
|
||||
}
|
||||
|
||||
func findExecutable(path string, pid int) string {
|
||||
if path == "" {
|
||||
path = fmt.Sprintf("/proc/%d/exe", pid)
|
||||
}
|
||||
return path
|
||||
func findExecutable(pid int) (string, error) {
|
||||
path := fmt.Sprintf("/proc/%d/exe", pid)
|
||||
return filepath.EvalSymlinks(path)
|
||||
}
|
||||
|
||||
func (dbp *nativeProcess) trapWait(pid int) (*nativeThread, error) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user