pahole在命名空间中不显示类

3
我正在尝试使用pahole分析一个包含命名空间内类的C++程序的内存布局。pahole只列出全局命名空间中的类。是否有选项可以列出其他类?
MWE:
namespace ns {
  class Thing {
    public:
      int y;

      Thing(int y) : y(y) { }
  };
};

class Thong {
  public:
    int z;

    Thong(int z) : z(z) { }
};

int main(void) {
  ns::Thing x(1);
  Thong a(2);
  return x.y + a.z;
}

g++ -ggdb3 test.cpp
pahole --version; pahole a.out

v1.10
class Thong {
public:

    int                        z;                    /*     0     4 */
    void Thong(class Thong *, int);


    /* size: 4, cachelines: 1, members: 1 */
    /* last cacheline: 4 bytes */
};
1个回答

4
经过查看源代码,我发现--show_private_classes选项还会打印命名空间中定义的类。
类名中的命名空间限定符被省略了(ns1::foons2::foo都被打印为foo),但对于我的用例来说已经足够了。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接