简体   繁体   English

在VS 2005和2010中调试VC6代码时,大多数变量未显示

[英]Most variables not displayed when debugging VC6 code in VS 2005 and 2010

Visual Studio 2010 is unable to display anything but the values of local concrete variables (ie int, bool, etc.) when debugging code that was built using Visual Studio 6. 在调试使用Visual Studio 6生成的代码时,Visual Studio 2010除了局部具体变量(即int,bool等)的值外,无法显示任何内容。

The Visual Studio 6 build is generating a pdb file, "Debug info" and "Microsoft format" are selected as suggested in response to the following question: Browse VC6 DLL variables content (DEBUG) Visual Studio 6生成正在生成pdb文件,根据对以下问题的建议,选择“调试信息”和“ Microsoft格式”: 浏览VC6 DLL变量内容(DEBUG)

For example in the following code, the only variable which I can see the value for is 'var'. 例如,在以下代码中,我可以看到的唯一变量是'var'。 By 'see' I mean that the variable appears in the "Locals" or "Auto" window with a value, I get a value in a tool tip, or that the variable name is resolved when I enter it in the Watch window. “看到”是指变量出现在“ Locals”或“ Auto”窗口中,并带有一个值,在工具提示中提供了一个值,或者在“监视”窗口中输入变量名称后便对其进行解析。

It seems I cannot see 'num' as it is an argument to the function, I can't see 'm_member' as it is a class member. 看来我看不到“ num”,因为它是函数的参数,我看不到“ m_member”,因为它是类成员。 I can't see 'stackMem' or 'heapMem' as they are not simple types. 我看不到“ stackMem”或“ heapMem”,因为它们不是简单的类型。

class MyClass
{
public:
MyClass() : m_member(0) {}
int aMethod(int num)
{
    m_member = m_member + num;
    return m_member;
}
private:
int m_member;
};

void main()
{
MyClass* heapMem = new MyClass();
MyClass stackMem;

int var = heapMem->aMethod(5);
var = stackMem.aMethod(10);
}

Is there anything I can do to better be able to debug old VC6 code in a newer debug environment like VS 2010? 我有什么办法可以更好地在像VS 2010这样的较新的调试环境中调试旧的VC6代码?

I don't remember how VC6 used to work; 我不记得VC6是如何工作的。 but in VS2005 and more recent Visual Studio editions, there are be different views (tabs/windows) available when debugging that you can dock. 但是在VS2005和更新的Visual Studio版本中,调试时可以停靠的视图(选项卡/窗口)不同。

Watch, Auto (auto variables), Locals, Callstack... 监视,自动(自动变量),局部变量,调用堆栈...

They are (should be) available from the Debug menu when you start debugging. 当您开始调试时,它们(应该)在“调试”菜单中可用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM