指向表的指针导致符号无法加载

发布于 2024-12-05 04:31:28 字数 1140 浏览 0 评论 0原文

我的程序中有几个大表,我正在尝试编写一个类来为这些表提供通用接口。每个表都位于其自己的头文件中,并包含一个 const double 数组和几个描述表布局的变量。所有表格都包含在我的预编译标头中。

我的类只有一个初始化函数,它确定要使用哪个表,然后将其成员变量设置为适当的值,并将其双指针设置为数组的第一个元素。我有一些#defines 来确定要使用哪一组表,然后有一个枚举传递到初始化函数中以确定要使用给定集中的哪个表。所以我的初始化函数如下所示:

void CMyClass::initialize(enum mode)
{
#ifdef VERSION1
    switch (mode)
    {
        case mode1:
        m_Data = &tableVersion1Mode1[0];
        //set member variables
        break;

        case mode2:
        m_Data = &tableVersion1Mode2[0];
        //set member variables
        break;

        case mode3:
        m_Data = &tableVersion1Mode3[0];
        //set member variables
        break;
    }
#endif

#ifdef VERSION2
    switch(mode)
    {
        //same thing
    }
#endif

//etc etc
}

问题是在某些情况下,该程序的调试符号未加载,并且没有命中断点。我已将问题范围缩小到此类中的双指针,因为我只需注释掉该成员变量即可,问题就消失了。但我对它的行为完全感到困惑。

如果我在每种情况下将指针设置为不同的表(如上所示),则不会加载任何符号。

如果我注释掉其中一个指针分配,无论哪一个,符号都会被加载并且一切正常。

如果我将指针设置为任意两种或全部三种情况的同一数组,则符号将被加载并且一切正常。

我对这个主题做了一些研究,我知道如果符号没有被加载,那么它可能是 .pdb 文件的问题。我尝试手动加载 .pdb,但它说它不匹配。但如果我在可执行文件和 .pdb 上运行 ChkMatch.exe,它会说它们匹配。那么到底是怎么回事呢?

I have several large tables in my program, and I'm trying to write a class to provide a generic interface with these tables. Each table is in its own header file, and contains a const double array and several variables that describe the layout of the table. All of the tables are included in my precompiled header.

My class only has an initialize function where it determines which table to use, and then sets its member variables to the appropriate values, and sets its double pointer to the first element of the array. I have some #defines that determine which set of tables to use, and then an enum that I pass into the initialize function to determine which table in the given set to use. So my initialize function looks like:

void CMyClass::initialize(enum mode)
{
#ifdef VERSION1
    switch (mode)
    {
        case mode1:
        m_Data = &tableVersion1Mode1[0];
        //set member variables
        break;

        case mode2:
        m_Data = &tableVersion1Mode2[0];
        //set member variables
        break;

        case mode3:
        m_Data = &tableVersion1Mode3[0];
        //set member variables
        break;
    }
#endif

#ifdef VERSION2
    switch(mode)
    {
        //same thing
    }
#endif

//etc etc
}

The problem is that under some situations, the debug symbols for this program aren't loaded and none of the breakpoints are being hit. I've narrowed the problem down to the double pointer in this class, since I can just comment out this member variable and the problem goes away. But I'm completely baffled by its behavior.

If I set the pointer to a different table in each case, like above, then no symbols are loaded.

If I comment out one of the pointer assignments, regardless of which, the symbols are loaded and everything works fine.

If I set the pointer to the same array for any two or all three cases, then the symbols are loaded and everything works fine.

I did some research on the subject, and I know that if the symbols aren't being loaded then it's probably an issue with the .pdb files. I've tried manually loading the .pdb, and it says that it doesn't match. But if I run ChkMatch.exe on the executable and the .pdb, it says they match. So what's going on?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文