为什么Visual Studio的调试模式Step Into(F11)有时不进入某些功能?

Jav*_*ock 10 c++ visual-studio-2008 visual-studio-debugging

我正在使用F11键(Step Into模式)调试给定的C++代码,以便了解调用代码中函数的精确顺序,并且我意识到它永远不会进入某些函数,除非我在某些行设置断点在函数定义中.

我的意思是,如果我从main方法调用一个函数,并且该函数在另一个.cpp中定义,我希望F11调试模式在函数内部逐步进入,以便分析变量的变化.它大部分时间都有,但在某些情况下它只是执行函数而不进入它,并跳转到main方法中的下一行.

为什么会这样?

例:

这是F11永远不会介入的功能:

void VirtualCamera::display (void) {
    glClearColor(0.0f, 0.0f, 0.0f, 1.0f); // Clear the background of the window
    glClear(GL_COLOR_BUFFER_BIT); //Clear the colour buffer (more buffers later on)
    glLoadIdentity(); // Load the Identity Matrix to reset our drawing locations

    glTranslatef(0.0f, 0.0f, -5.0f);
    renderPrimitive(); // Render the primitive

    glFlush(); // Flush the OpenGL buffers to the window
}
Run Code Online (Sandbox Code Playgroud)

这是F11循序渐进的主要方法:

void VirtualCamera::CameraMain(int argc, char **argv){
    glutInit(&argc, argv); // Initialize GLUT
    glutInitDisplayMode (GLUT_SINGLE); 
    glutInitWindowSize (500, 500); // Set the width and height of the window
    glutInitWindowPosition (100, 100); // Set the position of the window
    glutCreateWindow ("OpenGL Window"); // Set the title for the window

    glutDisplayFunc(display); // Tell GLUT to use the method "display" for rendering
    glutReshapeFunc(reshape);

    glutMainLoop(); // Enter GLUT's main loop   
}
Run Code Online (Sandbox Code Playgroud)

cur*_*isk 7

值得快速检查..

在Visual Studio中,转到" 工具" >" 选项"...

单击左侧的" 调试 "

在左边查看Enable Just my Code(Managed)如果选中,取消选中它,点击" OK "

为了更好的衡量,我总是退出VS并返回


har*_*per 6

您需要调试信息才能输入glutMainLoop.当没有源代码或没有可用于glutMainLoop的调试信息时,调试器无法显示源代码.如果要单步执行此功能,则需要同时添加两者.

或者,您可以使用Shift- 进入反汇编F11.但我不认为这会对这种情况有所帮助.