diff options
author | David Chase <drchase@google.com> | 2020-06-02 17:53:47 -0400 |
---|---|---|
committer | David Chase <drchase@google.com> | 2020-06-03 16:27:49 +0000 |
commit | 3949cae4410aa05bc76ccab598ad63618b10416e (patch) | |
tree | 712fd8ec2763a4caeb47ea4a23febb4cc27eca4a /src/runtime/runtime-gdb.py | |
parent | 9e56bcb9fe23bbd75d8896e845a9129251d4fca5 (diff) | |
download | go-3949cae4410aa05bc76ccab598ad63618b10416e.tar.gz go-3949cae4410aa05bc76ccab598ad63618b10416e.zip |
runtime: repair gdb printing fix for 7.12, 8.{1,2,3}.1, 9.2
Hand-verified for listed gdb versions. Gdb (apparently)
changed the way it names certain Go types, and this change
broke the pretty-printer-activating code in runtime-gdb.py
runtime-gdb_test.go now checks channel, map, string, and slice
printing unconditionally (i.e., no opt-out for old versions).
Updates #39368.
Change-Id: I98d72e1291c66bd40d970990e1a377ff2ed0c5d2
Reviewed-on: https://go-review.googlesource.com/c/go/+/236164
Run-TryBot: David Chase <drchase@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Diffstat (limited to 'src/runtime/runtime-gdb.py')
-rw-r--r-- | src/runtime/runtime-gdb.py | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/src/runtime/runtime-gdb.py b/src/runtime/runtime-gdb.py index b883d87f2d..7b5ba71832 100644 --- a/src/runtime/runtime-gdb.py +++ b/src/runtime/runtime-gdb.py @@ -28,10 +28,22 @@ if sys.version > '3': 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) @@ -202,7 +214,7 @@ class ChanTypePrinter: 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 |