I was debugging a given C++ code with the F11 key (Step Into mode) in order to understand the precise order in which the functions in the code were called and I realized that it would never enter inside some functions unless I set a breakpoint at some line inside the function definition.
I mean, if I call a function from the main method, and the function is defined in another .cpp I expect the F11 debugging mode to enter step by step inside the function in order to analize the variable changes. Most of the times it does but in some cases it just execute the function without stepping into it, and jumps to the next line in the main method.
Why is this happening?
Example:
This is the function F11 would never step into:
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
}
This is the main method where F11 goes step by step:
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
}
You need debugging information to enter the glutMainLoop. When no source code or no debugging info is available for glutMainLoop the debugger can’t display source code. When you want to single step this function you need to add both.
Alternatively you can enter to disassembly using Shift–F11. But I dont’t think that this will help in this case.