Swift的LLDB:通用类型的自定义类型摘要

问题描述 投票:1回答:1

使用LLDB,我可以为类型添加自定义摘要:

(lldb) type summary add -s "This is a Foo" Baz.Foo

但是,对于具有两个或多个泛型的泛型类型,我无法执行此操作。

给出具有两个或多个泛型的类型为Foo的模块Baz:

struct Foo<Bar: Numeric, Bar2: Numeric> {}

我已经尝试过以下方法;都没有成功:

  • type summary add -s "This is a Foo" Baz.Foo
  • type summary add -s "This is a Foo" Baz.Foo<A, B>
  • type summary add -s "This is a Foo" Baz.Foo<Float, Float>
  • type summary add -s "This is a Foo" Baz.Foo<Bar, Bar2>
  • type summary add -s "This is a Foo" Baz.Foo<Float>

在所有情况下,都是打印标准描述而不是自定义描述。

因此,如何在不为BarBar2指定具体类型的情况下为具有两个或多个泛型的泛型类型添加自定义摘要?

swift lldb
1个回答
1
投票

使用--regex / -x标志来模式化Swift中的通用类型或C ++中的模板类型。

type summary add -s "This is a Foo" -x "^Baz\.Foo<.+,.+>$"

通过运行type summary list -l swift,您可以看到许多示例。这是Dictionary的显示方式:

^Swift\.Dictionary<.+,.+>$:  (show children) (hide value) (skip references) Swift.Dictionary summary provider
© www.soinside.com 2019 - 2024. All rights reserved.