"-ex", "echo END\n",
filepath.Join(dir, "a.exe"),
)
- got, _ := exec.Command("gdb", args...).CombinedOutput()
- t.Logf("gdb output: %s\n", got)
+ got, err := exec.Command("gdb", args...).CombinedOutput()
+ t.Logf("gdb output:\n%s", got)
+ if err != nil {
+ t.Fatalf("gdb exited with error: %v", err)
+ }
firstLine := bytes.SplitN(got, []byte("\n"), 2)[0]
if string(firstLine) != "Loading Go Runtime support." {
"-ex", "continue",
filepath.Join(dir, "a.exe"),
}
- got, _ := exec.Command("gdb", args...).CombinedOutput()
+ got, err := exec.Command("gdb", args...).CombinedOutput()
+ t.Logf("gdb output:\n%s", got)
+ if err != nil {
+ t.Fatalf("gdb exited with error: %v", err)
+ }
// Check that the backtrace matches the source code.
bt := []string{
s := fmt.Sprintf("#%v.*main\\.%v", i, name)
re := regexp.MustCompile(s)
if found := re.Find(got) != nil; !found {
- t.Errorf("could not find '%v' in backtrace", s)
- t.Fatalf("gdb output:\n%v", string(got))
+ t.Fatalf("could not find '%v' in backtrace", s)
}
}
}
"-ex", "info types astruct",
filepath.Join(dir, "a.exe"),
}
- got, _ := exec.Command("gdb", args...).CombinedOutput()
+ got, err := exec.Command("gdb", args...).CombinedOutput()
+ t.Logf("gdb output:\n%s", got)
+ if err != nil {
+ t.Fatalf("gdb exited with error: %v", err)
+ }
sgot := string(got)
}
for _, name := range types {
if !strings.Contains(sgot, name) {
- t.Errorf("could not find %s in 'info typrs astruct' output", name)
- t.Fatalf("gdb output:\n%v", sgot)
+ t.Fatalf("could not find %s in 'info typrs astruct' output", name)
}
}
}
"-ex", "print 'runtime._PageSize'",
filepath.Join(dir, "a.exe"),
}
- got, _ := exec.Command("gdb", args...).CombinedOutput()
+ got, err := exec.Command("gdb", args...).CombinedOutput()
+ t.Logf("gdb output:\n%s", got)
+ if err != nil {
+ t.Fatalf("gdb exited with error: %v", err)
+ }
sgot := strings.ReplaceAll(string(got), "\r\n", "\n")
- t.Logf("output %q", sgot)
-
if !strings.Contains(sgot, "\n$1 = 42\n$2 = 18446744073709551615\n$3 = -1\n$4 = 1 '\\001'\n$5 = 8192") {
t.Fatalf("output mismatch")
}
"-ex", "backtrace",
filepath.Join(dir, "a.exe"),
}
- got, _ := exec.Command("gdb", args...).CombinedOutput()
+ got, err := exec.Command("gdb", args...).CombinedOutput()
+ t.Logf("gdb output:\n%s", got)
+ if err != nil {
+ t.Fatalf("gdb exited with error: %v", err)
+ }
// Check that the backtrace matches the source code.
bt := []string{
s := fmt.Sprintf("(#.* .* in )?main\\.%v", name)
re := regexp.MustCompile(s)
if found := re.Find(got) != nil; !found {
- t.Errorf("could not find '%v' in backtrace", s)
- t.Fatalf("gdb output:\n%v", string(got))
+ t.Fatalf("could not find '%v' in backtrace", s)
}
}
}
"-ex", "continue",
filepath.Join(dir, "a.exe"),
}
- got, _ := exec.Command("gdb", args...).CombinedOutput()
+ got, err := exec.Command("gdb", args...).CombinedOutput()
+ t.Logf("gdb output:\n%s", got)
+ if err != nil {
+ t.Fatalf("gdb exited with error: %v", err)
+ }
// Check that the backtrace matches
// We check the 3 inner most frames only as they are present certainly, according to gcc_<OS>_arm64.c
s := fmt.Sprintf("#%v.*%v", i, name)
re := regexp.MustCompile(s)
if found := re.Find(got) != nil; !found {
- t.Errorf("could not find '%v' in backtrace", s)
- t.Fatalf("gdb output:\n%v", string(got))
+ t.Fatalf("could not find '%v' in backtrace", s)
}
}
}