From 6d02ce85840fb7a1a9239d02e02710a008b1657a Mon Sep 17 00:00:00 2001 From: Alessandro Arzilli Date: Fri, 17 Sep 2021 13:48:39 +0200 Subject: 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 Reviewed-by: David Chase Trust: Than McIntosh --- src/runtime/runtime-gdb.py | 9 +++++++-- 1 file 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] -- cgit v1.2.3-54-g00ecf