aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlessandro Arzilli <alessandro.arzilli@gmail.com>2021-09-17 13:48:39 +0200
committerDavid Chase <drchase@google.com>2021-09-17 15:07:28 +0000
commit6d02ce85840fb7a1a9239d02e02710a008b1657a (patch)
tree5be0488e32dd238e1ac01daa23235b1187c440d5
parent6602c86a38ff0d8889257e908489162de38ebbd8 (diff)
downloadgo-6d02ce85840fb7a1a9239d02e02710a008b1657a.tar.gz
go-6d02ce85840fb7a1a9239d02e02710a008b1657a.zip
runtime: fix prettyprinting of parametric types in gdb
golang.org/cl/344929 broke the minimal functionality that the python pretty printer for GDB had, this change restores it to its status prior to that CL. Change-Id: I4c7141d4ff726d224a074ecc533d0f896fc0052c Reviewed-on: https://go-review.googlesource.com/c/go/+/350529 TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: David Chase <drchase@google.com> Trust: Than McIntosh <thanm@google.com>
-rw-r--r--src/runtime/runtime-gdb.py9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/runtime/runtime-gdb.py b/src/runtime/runtime-gdb.py
index 8d96dfb609..5bb605cc37 100644
--- a/src/runtime/runtime-gdb.py
+++ b/src/runtime/runtime-gdb.py
@@ -219,6 +219,9 @@ class ChanTypePrinter:
yield ('[{0}]'.format(i), (ptr + j).dereference())
+def paramtypematch(t, pattern):
+ return t.code == gdb.TYPE_CODE_TYPEDEF and str(t).startswith(".param") and pattern.match(str(t.target()))
+
#
# Register all the *Printer classes above.
#
@@ -228,6 +231,8 @@ def makematcher(klass):
try:
if klass.pattern.match(str(val.type)):
return klass(val)
+ elif paramtypematch(val.type, klass.pattern):
+ return klass(val.cast(val.type.target()))
except Exception:
pass
return matcher
@@ -387,7 +392,7 @@ class GoLenFunc(gdb.Function):
def invoke(self, obj):
typename = str(obj.type)
for klass, fld in self.how:
- if klass.pattern.match(typename):
+ if klass.pattern.match(typename) or paramtypematch(obj.type, klass.pattern):
return obj[fld]
@@ -402,7 +407,7 @@ class GoCapFunc(gdb.Function):
def invoke(self, obj):
typename = str(obj.type)
for klass, fld in self.how:
- if klass.pattern.match(typename):
+ if klass.pattern.match(typename) or paramtypematch(obj.type, klass.pattern):
return obj[fld]