pahole 不显示命名空间中的类

pahole doesn't show classes in namespaces

本文关键字:命名空间 显示 pahole      更新时间:2023-10-16

我正在尝试使用pahole来分析C++程序的内存布局,该程序在命名空间中有一些类。 pahole 仅列出全局命名空间中的类。是否有选项也可以列出其他类?

女工程师:

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 */
};

在源代码中查找后,我发现--show_private_classes选项还打印命名空间中定义的类。

命名空间限定符从类名中删除(ns1::foons2::foo都打印为仅foo),但对于我的用例来说已经足够了。