Debugging FlightGear

FG-MSVC6 - FG-MSVC7 - UFO - ATLAS ( At 1 - At 2 - At 3 ) - OTHERS - Favourites - Home

Although I have done this before, this is a run through the FlightGear code, in 'Debug' configuration, trying to more understand the flow of the application, and the action taken in certain functions ... read on, and you will see what I mean, I hope ... ;=))

Like all CONSOLE application, the OS application loader calls the 'main(...)' function, in bootstrap.cxx ... this is not where the actual 'application code' starts ... aside from the C/C++ code that forms the 'command line' into a list of pointers, to be able to call main( int argc, char * * argv ), there will be numerous setups and allocations to be done, that the compiler/linker built into a 'table' ... if you 'try-hard' it is possible to view this code also ... but normally the IDE debugger will 'start' you at main() ...

The first piece of 'puzzling' code is -
// Enable floating-point exceptions for Windows
#if defined( _MSC_VER ) && defined( DEBUG )
// Christian, we should document what this does
_control87( _EM_INEXACT, _MCW_EM );

This page shows my 'exploration' of this topic, but since it is NEVER compiled, I will forget it for now ... and suggest the code should be removed ... moving on ...

The next item of interest, is the fact that FG is run entirely within a 'try {  } catch { }' context -
try {
 fgMainInit(argc, argv);
} catch (sg_throwable &t) { // We must use cerr ..
 cerr << "Fatal error: " << t.getFormattedMessage()  << "\n (received from " << t.getOrigin() << ')' << endl;
} catch (...) {
 cerr << "Unknown exception in the main loop. Aborting..." << endl;
 perror("Possible cause");
return 0;

The actions, setting an 'atexit' to fgExitCleanup(), then calling fgMainInit(argc,argv), from which it will NEVER return, except if an 'exception' is encountered ... so setting a breakpoint on the 'return 0;' may never be reached ... I put a trap in fgExitCleanup, and 'experiment' with an 'exits' ... because I had read somewhere in GL (glut), that, in some circumstances ... but clicking on the big red upper right X, and I was at my 'trap' ... tracing it back into the caller, I 'see' that I am one of 'many' calls to be done 'on-exit' ...

So the initialization is in fgMainInit() ... let's go there ... as to be expected, it is a mass of 'initialisation', here reduced to simple table of event, parameters, and comment ... I thought 'seeing' it as a table would sow some things ...

Note C

FG-MSVC6 - FG-MSVC7 - UFO - ATLAS ( At 1 - At 2 - At 3 ) - OTHERS - Favourites - Home