
This flag allows users on UNIX systems to set the tty for the program being debugged by Delve. This is useful for debugging command line applications which need access to their own TTY, and also for controlling the output of the debugged programs so that IDEs may open a dedicated terminal to show the output for the process.
40 lines
1.0 KiB
Go
40 lines
1.0 KiB
Go
package proc_test
|
|
|
|
import (
|
|
"os"
|
|
"os/exec"
|
|
"path/filepath"
|
|
"testing"
|
|
|
|
"github.com/go-delve/delve/pkg/proc/native"
|
|
protest "github.com/go-delve/delve/pkg/proc/test"
|
|
)
|
|
|
|
func TestLoadingExternalDebugInfo(t *testing.T) {
|
|
fixture := protest.BuildFixture("locationsprog", 0)
|
|
defer os.Remove(fixture.Path)
|
|
stripAndCopyDebugInfo(fixture, t)
|
|
p, err := native.Launch(append([]string{fixture.Path}, ""), "", false, []string{filepath.Dir(fixture.Path)}, "")
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
p.Detach(true)
|
|
}
|
|
|
|
func stripAndCopyDebugInfo(f protest.Fixture, t *testing.T) {
|
|
name := filepath.Base(f.Path)
|
|
// Copy the debug information to an external file.
|
|
copyCmd := exec.Command("objcopy", "--only-keep-debug", name, name+".debug")
|
|
copyCmd.Dir = filepath.Dir(f.Path)
|
|
if err := copyCmd.Run(); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
|
|
// Strip the original binary of the debug information.
|
|
stripCmd := exec.Command("strip", "--strip-debug", "--strip-unneeded", name)
|
|
stripCmd.Dir = filepath.Dir(f.Path)
|
|
if err := stripCmd.Run(); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
}
|