mirror of
https://github.com/golang/go
synced 2024-11-17 14:34:46 -07:00
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>
This commit is contained in:
parent
6602c86a38
commit
6d02ce8584
@ -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]
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user