epcs = s
dsym := ctxt.Syms.Lookup(dwarf.InfoPrefix+s.Name, int(s.Version))
- dsym.Attr |= AttrHidden
+ dsym.Attr |= AttrHidden | AttrReachable
dsym.Type = obj.SDWARFINFO
for _, r := range dsym.R {
if r.Type == obj.R_DWARFREF && r.Sym.Size == 0 {
import (
"bytes"
"fmt"
+ "go/build"
"internal/testenv"
"io/ioutil"
"os"
}
const helloSource = `
-package main
import "fmt"
var gslice []string
func main() {
`
func TestGdbPython(t *testing.T) {
+ testGdbPython(t, false)
+}
+
+func TestGdbPythonCgo(t *testing.T) {
+ testGdbPython(t, true)
+}
+
+func testGdbPython(t *testing.T, cgo bool) {
if runtime.GOARCH == "mips64" {
testenv.SkipFlaky(t, 18173)
}
+ if cgo && !build.Default.CgoEnabled {
+ t.Skip("skipping because cgo is not enabled")
+ }
t.Parallel()
checkGdbEnvironment(t)
}
defer os.RemoveAll(dir)
+ var buf bytes.Buffer
+ buf.WriteString("package main\n")
+ if cgo {
+ buf.WriteString(`import "C"` + "\n")
+ }
+ buf.WriteString(helloSource)
+
src := filepath.Join(dir, "main.go")
- err = ioutil.WriteFile(src, []byte(helloSource), 0644)
+ err = ioutil.WriteFile(src, buf.Bytes(), 0644)
if err != nil {
t.Fatalf("failed to create file: %v", err)
}