2012-01-30 31 views
8

我正在調試一個給定的C++代碼,使用F11鍵(Step Into模式),以便了解代碼中函數被調用的精確順序,並且我意識到它絕不會進入某些函數內部,除非我在函數定義的某一行設置一個斷點爲什麼Visual Studio的調試模式Step Into(F11)有時不會進入某些功能內?

我的意思是,如果我請從主方法的功能,並且該功能在另一個的.cpp I所定義期望F11調試模式由函數內部步驟以analize變量輸入步驟變化。大部分時間都是這樣,但在某些情況下,它只是執行函數而不進入它,並跳轉到主方法中的下一行。

這是怎麼發生的?

實施例:

這是函數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 
} 

回答

6

您需要調試信息才能輸入glutMainLoop。當glutMainLoop沒有源代碼或調試信息可用時,調試器無法顯示源代碼。當你想單步執行這個功能時,你需要添加兩個。

或者,您可以輸入以反彙編使用Shift - F11。但我不認爲這將有助於這種情況。

6

值得一快速檢查..

在Visual Stu DIO,去工具>選項...

點擊左側

調試,在左邊的啓用僅我的代碼(託管),如果它被選中,取消選中,點擊「OK

良好的措施,我總是退出VS和回去

+0

我沒有選中,但無論如何感謝。我的意思是我期望當F11到達'glutMainLoop()'這一行時也會進入函數顯示,但它只會在display(void)內設置一個斷點。 – 2012-01-30 15:10:35

4

當步進ŧ通過CameraMain中的代碼,您是否期望在撥打glutDisplayFunc(display);時能夠步入display

在這種情況下,它不會發生,因爲display函數是而不是在該點調用。相反,它由GLUT保存,以便從GLUT主循環中調用。您必須在display函數中設置一個斷點,以便能夠逐步完成。

+0

我希望能夠進入'glutMainLoop'顯示,但正如你所說,這是必要的一個斷點。這是爲什麼?它總是發生在循環? – 2012-01-30 15:13:58

相關問題