goobjfile = gdb.current_objfile() or gdb.objfiles()[0]
goobjfile.pretty_printers = []
+# A bit of hand optimization since oldnew is used for slice printing
+splitgdbversion = gdb.VERSION.split('.')
+majorgdbversion = int(splitgdbversion[0])
+
# Older gdb renders some types differently.
def oldnew(old, new):
- if (gdb.VERSION[0] == '7'):
+ if majorgdbversion < 8:
return old
+ if majorgdbversion > 8:
+ return new
+ try:
+ # Minor versions need not be actual numbers, e.g., 7.3a.
+ if int(splitgdbversion[1]) < 2:
+ return old
+ except Exception:
+ return new # All the existing gdb 8.minor versions are numbers, so if it is not a number, it is new.
return new
# G state (runtime2.go)
to inspect their contents with this pretty printer.
"""
- pattern = re.compile(oldnew(r'^struct hchan<.*>$',r'^chan '))
+ pattern = re.compile(r'^chan ')
def __init__(self, val):
self.val = val
}
}
-// checkGdbVersion ensures gdb version is supported, and returns major version
-// to allow testing conditional on gdb version.
-func checkGdbVersion(t *testing.T) int {
+func checkGdbVersion(t *testing.T) {
// Issue 11214 reports various failures with older versions of gdb.
out, err := exec.Command("gdb", "--version").CombinedOutput()
if err != nil {
t.Skipf("skipping: gdb version %d.%d too old", major, minor)
}
t.Logf("gdb version %d.%d", major, minor)
- return major
}
func checkGdbPython(t *testing.T) {
checkGdbEnvironment(t)
t.Parallel()
- gdbMajor := checkGdbVersion(t)
+ checkGdbVersion(t)
checkGdbPython(t)
dir, err := ioutil.TempDir("", "go-build")
t.Fatalf("print slicemap failed: %s", bl)
}
- if gdbMajor > 7 {
- chanIntSfx := `chan int = {99, 11}`
- if bl := strings.ReplaceAll(blocks["print chanint"], " ", " "); !strings.HasSuffix(bl, chanIntSfx) {
- t.Fatalf("print chanint failed: %s", bl)
- }
+ chanIntSfx := `chan int = {99, 11}`
+ if bl := strings.ReplaceAll(blocks["print chanint"], " ", " "); !strings.HasSuffix(bl, chanIntSfx) {
+ t.Fatalf("print chanint failed: %s", bl)
+ }
- chanStrSfx := `chan string = {"spongepants", "squarebob"}`
- if bl := strings.ReplaceAll(blocks["print chanstr"], " ", " "); !strings.HasSuffix(bl, chanStrSfx) {
- t.Fatalf("print chanstr failed: %s", bl)
- }
+ chanStrSfx := `chan string = {"spongepants", "squarebob"}`
+ if bl := strings.ReplaceAll(blocks["print chanstr"], " ", " "); !strings.HasSuffix(bl, chanStrSfx) {
+ t.Fatalf("print chanstr failed: %s", bl)
}
strVarRe := regexp.MustCompile(`^\$[0-9]+ = (0x[0-9a-f]+\s+)?"abc"$`)
checkGdbEnvironment(t)
t.Parallel()
- _ = checkGdbVersion(t)
+ checkGdbVersion(t)
dir, err := ioutil.TempDir("", "go-build")
if err != nil {
func TestGdbAutotmpTypes(t *testing.T) {
checkGdbEnvironment(t)
t.Parallel()
- _ = checkGdbVersion(t)
+ checkGdbVersion(t)
if runtime.GOOS == "aix" && testing.Short() {
t.Skip("TestGdbAutotmpTypes is too slow on aix/ppc64")
func TestGdbConst(t *testing.T) {
checkGdbEnvironment(t)
t.Parallel()
- _ = checkGdbVersion(t)
+ checkGdbVersion(t)
dir, err := ioutil.TempDir("", "go-build")
if err != nil {
func TestGdbPanic(t *testing.T) {
checkGdbEnvironment(t)
t.Parallel()
- _ = checkGdbVersion(t)
+ checkGdbVersion(t)
dir, err := ioutil.TempDir("", "go-build")
if err != nil {
}
t.Parallel()
- _ = checkGdbVersion(t)
+ checkGdbVersion(t)
dir, err := ioutil.TempDir("", "go-build")
if err != nil {