aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/runtime/runtime-gdb.py2
-rw-r--r--src/runtime/runtime-gdb_test.go59
2 files changed, 60 insertions, 1 deletions
diff --git a/src/runtime/runtime-gdb.py b/src/runtime/runtime-gdb.py
index eedac7cf44..cee025eb6c 100644
--- a/src/runtime/runtime-gdb.py
+++ b/src/runtime/runtime-gdb.py
@@ -202,7 +202,7 @@ def lookup_type(name):
except gdb.error:
pass
-_rctp_type = gdb.lookup_type("struct runtime.rtype").pointer()
+_rctp_type = gdb.lookup_type("struct reflect.rtype").pointer()
def iface_commontype(obj):
diff --git a/src/runtime/runtime-gdb_test.go b/src/runtime/runtime-gdb_test.go
new file mode 100644
index 0000000000..4a74dd372a
--- /dev/null
+++ b/src/runtime/runtime-gdb_test.go
@@ -0,0 +1,59 @@
+package runtime_test
+
+import (
+ "io/ioutil"
+ "os"
+ "os/exec"
+ "path/filepath"
+ "testing"
+)
+
+func checkGdbPython(t *testing.T) {
+ cmd := exec.Command("gdb", "-nx", "-q", "--batch", "-ex", "python import sys; print('golang gdb python support')")
+ out, err := cmd.CombinedOutput()
+
+ if err != nil {
+ t.Skipf("skipping due to issue running gdb%v", err)
+ }
+ if string(out) != "golang gdb python support\n" {
+ t.Skipf("skipping due to lack of python gdb support: %s", out)
+ }
+}
+
+const helloSource = `
+package main
+import "fmt"
+func main() {
+ fmt.Println("hi")
+}
+`
+
+func TestGdbLoadRuntimeSupport(t *testing.T) {
+
+ checkGdbPython(t)
+
+ dir, err := ioutil.TempDir("", "go-build")
+ if err != nil {
+ t.Fatalf("failed to create temp directory: %v", err)
+ }
+ defer os.RemoveAll(dir)
+
+ src := filepath.Join(dir, "main.go")
+ err = ioutil.WriteFile(src, []byte(helloSource), 0644)
+ if err != nil {
+ t.Fatalf("failed to create file: %v", err)
+ }
+
+ cmd := exec.Command("go", "build", "-o", "a.exe")
+ cmd.Dir = dir
+ out, err := cmd.CombinedOutput()
+ if err != nil {
+ t.Fatalf("building source %v\n%s", err, out)
+ }
+
+ got, _ := exec.Command("gdb", "-nx", "-q", "--batch", "-ex", "source runtime-gdb.py",
+ filepath.Join(dir, "a.exe")).CombinedOutput()
+ if string(got) != "Loading Go Runtime support.\n" {
+ t.Fatalf("%s", got)
+ }
+}