为什么Visual Studio的调试模式Step In(F11)有时不会进入某些函数?
Why Visual Studio's debug mode Step Into (F11) sometimes doesn't enter inside some functions?
我用F11键调试给定的C++代码(进入模式),以了解代码中函数的调用顺序,我意识到除非在函数定义的某行设置断点,否则它永远不会进入某些函数。
我的意思是,如果我从主方法调用一个函数,并且该函数是在另一个.cpp中定义的,我希望F11调试模式在函数内部逐步进入,以便分析变量的变化。大多数时候,它会执行,但在某些情况下,它只是执行函数而不介入,并跳到主方法中的下一行。
为什么会发生这种情况?
示例:
这是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
}
这是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
}
值得快速检查。。
在Visual Studio中,转到工具选项
单击左侧的调试
在左侧查找仅启用我的代码(托管)如果选中,请取消选中,然后点击"确定"
为了更好地衡量,我总是退出VS并返回
您需要调试信息才能进入glutMainLoop。当没有源代码或没有调试信息可用于glutMainLoop时,调试器无法显示源代码。当你想单步执行这个函数时,你需要同时添加这两个。
或者,您可以使用Shift-F11进入反汇编。但我认为这对这种情况没有帮助。
在执行CameraMain
中的代码时,是否希望能够在调用glutDisplayFunc(display);
时进入display
?
在这种情况下,不会发生这种情况,因为display
函数是,而不是。相反,它由GLUT保存,以便从GLUT主循环内部调用。您必须在display
函数中设置一个断点才能逐步通过它。
相关文章:
- 无法使函数公开。获取:"LNK2005"错误。如何调试链接器错误
- 如何调试Cpp程序中的析构函数
- 将C++函数从 DLL 导出为 C 时调试和发布之间的差异
- 调试 - 单步执行 (F11) 不会直接转到函数
- 如何关闭用于在程序中打印调试数据的函数
- 在h文件上内联发布版本并在cpp上实现调试版本的函数
- 使用向量的函数崩溃,调试器说访问冲突读取位置
- 正确编码和调试的命名空间中未解析的函数
- 函数在正常运行时不起作用,但在调试时起作用
- 函数无法正常工作,调试器没有帮助
- OpenGL 调试 错误回调函数的 ID 参数是什么?
- 如何定义具有依赖于符号调试的参数的函数
- 如何调试指针参数是否通过函数修改
- Qtcpserver 仅在调试器下在侦听函数上返回未知错误
- 为什么在类构造函数方法中,std::string 参数在调试时显示不同的结果?
- Vulkan API 调试函数指针类型转换错误
- G++ 切换为不包含自己的符号函数名称(和调试数据)-
- C++ 调试递归函数,它不会立即退出函数
- 单例:为什么不需要删除并且看不到析构函数调试消息
- Visual Studio函数调试