【问题标题】:LLDB Data Formatter for References用于参考的 LLDB 数据格式化程序
【发布时间】:2018-07-22 03:03:05
【问题描述】:

我目前正在为我自己的类型开发数据格式化程序。但是,我在打印参考文献时遇到了一些问题。

#include <iostream>

class Circle
{
  protected:
    double R;
    double a;
    double b;

  public:
    Circle():R(1), a(0), b(0)
    {
    }
};

int main()
{
  Circle A;
  Circle & B = A;

  return 0;
}

我使用type summary add 自定义我自己的数据格式化程序

(lldb) type summary add -s "The circle is (R = ${var.R}, a = ${var.a}, b = ${var.b})" Circle

现在对于非引用来说效果很好,例如

(lldb) frame variable A
(Circle) A = The circle is (R = 1, a = 0, b = 0)

但是,对于参考,

(lldb) frame variable B
(Circle &const) B = 0x00007fffffffd200 The circle is (R = 1, a = 0, b = 0): {
  R = 1
  a = 0
  b = 0
}

不需要“:”后面的内容。

我应该如何处理引用?我知道可以使用--skip-references 来禁用引用的输出,但我希望我可以像通常的类型一样格式化引用。

【问题讨论】:

    标签: python c++ xcode lldb


    【解决方案1】:

    这是一个错误。摘要格式化程序有一个选项: --expand 应该控制我们是只显示摘要,还是显示摘要和正在打印的值的子项。如果在添加摘要时添加 --expand,您会看到结构版本现在也打印子元素。看起来该设置被忽略了引用。

    请向 bugs.llvm.org 提交错误

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-09-14
      • 1970-01-01
      • 2022-01-21
      • 2019-12-27
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多