User:Callahanp: Difference between revisions

Jump to navigation Jump to search
Line 73: Line 73:
{| class="wikitable"
{| class="wikitable"
|-
|-
! Module !! Description !! Steps
! Module
! colspan="3" | Description & Steps
|-
|-
| src/Main/bootstrap || Bootstrap provides the top level of the stack for executing either fgviewerMain or fgMainInit.
| src/Main/bootstrap Main
|
| Bootstrap provides the top level of the stack for executing either fgviewerMain or fgMainInit.
* Enable Floating Point features with InitFPE
* Enable Floating Point features with InitFPE
* Set locale settings specific to using C or C++
* Set locale settings specific to using C or C++
* Uninstall if requested
* Uninstall if requested
|
* Initialize logging
* Initialize logging
* Initialize some static objects in OSG to prevent crashes on exit
* Initialize some static objects in OSG to prevent crashes on exit
* set the std:: terminate function
* set the std:: terminate function
|
* set the atexit function
* set the atexit function
* pass control to the viewer with fgViewerMain or initialize using '''fgMainInit'''
* pass control to the viewer with fgViewerMain or initialize using '''fgMainInit'''
* catch throwables and other fatal error conditions, providing appropriate error messages
* catch throwables and other fatal error conditions, providing appropriate error messages
|-
|-
| src/Main/Main || fgMainInit
| src/Main/Main || fgMainInit( int argc, char **argv )
|
* set logging level and enable logging
* set logging level and enable logging
* setup globals as an instance of FGGlobals.   
* setup globals as an instance of FGGlobals.   
** see  src/Main/globals.cxx constructor FGGlobals::FGGlobals()
* make sure there's a valid FG_HOME directory and set up logging there
* set the version & log the version, build type and Jenkins or Hudson build id
* seed the random number generator
* set up a few things in globals
* decide if we're using a launcher
** see below src/Main/Main.cxx Launcher for details
* set read-only mode when more than one flightgear instance is found
* load configuration data
** see src/Main/Main.cxx'''fgInitConfig'''
* initalize aircraft paths
** see: src/Main/fg_init.cxx fgInitAircraftPaths and fgInitAircraft
|
* create an instance of the addon manager
** see below src/Add-ons/AddonManager.cxx
* check that the paths are allowed when they come from an untrusted source
* create an instance of an embedded resource manager
** see below simgear::EmbeddedResourceManager createInstance
** and initFlightGearEmbeddedResources
* get the preferred language and set the locale
* initialize the windows/graphics environment
** see viewer/fg_os_osgviewer.cxx fgosinit(int* argc, char** argv)
* register fgIdleFunction
** see fgRegisterIdleHandler in Main/fg_os_common.cxx and fgIdleFUnction in Main/main.cxx
* Initialize sockets
** simgear::Socket::initSockets()
* setup alpha channel for Clouds3D
** fgOSOpenWindow(true /* request stencil buffer */);
** fgOSResetProperties();
|
* fntInit();
* globals->get_renderer()->preinit();
* ATIScreenSizeHack
* fgOutputSettings();
* disable the screensaver
* pass control off to the master event handler
** See viewer/fg_os_osgviewer.cxx fgOSMainLoop() (next)
* cleanup
** frame_signal.clear();
** fgOSCloseWindow();
** simgear::clearEffectCache();
** delete globals;
** globals = NULL;
* delete the NavCache here. This will cause the destruction of many cached objects (eg, airports, navaids, runways).
** delete flightgear::NavDataCache::instance();
* return to bootstrap.cxx Main  return result;
|-
| viewer/fg_os_osgviewer.cxx || fgOSMainLoop()
* Release the viewer's context at end of frame hint
** viewer->setReleaseContextAtEndOfFrameHint(false)
* If the viewer is not realized yet, realize it. We still see nothing in the window
** viewer->realize()
|colspan="2"| here's the loop:
* get the idle handler
** fgIdleHandler idleFunc = globals->get_renderer()->getEventHandler()->getIdleHandler();
* run the idle handler  It's not clear what this is. It's either fgMainLoop or fgIdleFunction
** (*idleFunc)()
* update the screen
** globals->get_renderer()->update();
* timestamp the frame
** viewer->frame( globals->get_sim_time_sec() );
|-
|-
| Example || Example || Example
| Main/main.cxx || fgIdleFunc
|}
* normal startup has states 0, 2, 3, 4, 5, 7, 8, 9, 10, 900 1000
* reset startup has 2000, 2005, 2007, 8, 9, 10, 900, 1000
* state 1000 sets  fgMainLoop as the idle function. a reset sets it back to fgIdleFunc
 
* state 0 checks the openGL version and sets video options
** see checkOpenGLVersion() and  fgSetVideoOptions()
 
* state 2 sets /sim/rendering/initialized true and initializes terrasync with initTerrasync()
 
* state 3 loads nav data
** fgInitNav()
 
* state 4 initalizes scenery, but there's not call here
 
* state 5
** initializes some general items with fgInitGeneral()
** adds the TimeManager
*** globals->add_new_subsystem<TimeManager>(SGSubsystemMgr::INIT)
** initializes property based commands
*** fgInitCommands(); and fgInitSceneCommands();
** registers Subsystem Commands
*** flightgear::registerSubsystemCommands(globals->get_commands());
** initializes the material manager
*** globals->set_matlib( new SGMaterialLib )
*** simgear::SGModelLib::setPanelFunc(FGPanelNode::load)
|
* state 7
** Initializes Position
*** flightgear::initPosition(); and flightgear::initTowerLocationListener();
** Initializes somethingin SGModelLib
*** simgear::SGModelLib::init(globals->get_fg_root().local8BitStr(), globals->get_props());
** initializes the time manager instantiated in state 5
***auto timeManager = globals->get_subsystem<TimeManager>(); timeManager->init();
* state 8
* Create subsystems
** fgCreateSubsystems(isReset)
* log the time spent creating subsystems
* state 9
** bind subsystems
** globals->get_subsystem_mgr()->bind();
***
* state 10
** initialize subsystems
*** SGSubsystem::InitStatus status = globals->get_subsystem_mgr()->incrementalInit();
** remains in state 10 until  SGSubsystem::INIT_DONE
* state 900
** do what needs doing after systems are initialized
*** fgPostInitSubsystems(); 
|
* state 1000
** setup OpenGl view Parameters
*** globals->get_renderer()->setupView();
** resize the window to startup size
***  globals->get_renderer()->resize(x,y)
** unsure what this does
*** WindowSystemAdapter::getWSA()->windows[0]->gc->add(new simgear::canvas::VGInitOperation() )
* increment /sim/session
* State 1000 takes a break and continues with the next call
** sglog().setStartupLoggingEnabled(false)
* turns off logging for startup
* sets sim/scenery loaded to false
* changes the idle function
** registerMainLoop();
* state 2000
** Reset the application
*** fgStartNewReset();
* state 2005 same as state 5
* state 2007 same as state 7


'''Modules on the Path to Holding Short'''
Note fgResetIdleState() sets the state to 2000 and re-registers fgIdleFunction as the idle handler.
the gdb run command gets things going in gdbgui. Just type "r"
|-
| Main/main.cxx || fgMainLoop( void )| We seem to have arrived.  We're at the hold short point.


I'm going to record a list of functions called, in the order they are called in with descriptions where appropriate.
|}
to get information about where these functions are located, I'll use the atom's project search or the step into feature of gdbgui.
'''Minor functions on the Path to Holding Short'''
If the call is along the main line of execution, it will be in Bold Face.  Paths start with directories under flightgear/src, except for /simgear which is under /simgear.  Yes there is a simgear/simgear in the path.  There's proably a reason why its not simgear/src


=====bootstrap.cxx=====
{| class="wikitable"
{| class="wikitable"
|-
|-
! Full Text of Call !! Called Function Location or Include File !! Notes
! Module !! Description !! Steps
|-  
|-
| '''command line''' || in bootstrap.cxx <br>'''main(argc, argv)''' || bootstrap.cxx contains the main functionmain.cxx does not.
| src/Main/globals || Provides a global object to contain references to objects and data needed in initializing, running and terminating flightgear
|
* Provides global access to
** the property tree
** subsystem, event, command and resource manager objects and methods
** position, current view and aircraft orientation data
** FG_ROOT and FG_HOME directory paths
** time, comm channel, waypoint, and user settings data
* uses foreach from the boost library
|-
| <boost/foreach.h> || Example ||
|-
| <algorithm> || Example || Example
|-
| std::string version(FLIGHTGEAR_VERSION) ||  ||
|-
| sg_srandom_time(); ||  ||
|-
| src/Main/Main.cxx'''fgInitConfig''' || ||
|-
|  src/Main/Main.cxx Launcher ||  ||
|-
| src/Add-ons/AddonManager.cxx  ||  addons::AddonManager::createInstance() ||
|-
| initFlightGearEmbeddedResources ||  || see file build/flightgear/src/EmbeddedResources/FlightGear-resources.cxx,automatically generated by fgrcc
|-
| viewer/fg_os_osgviewer.cxx fgosinit(int* argc, char** argv) ||  ||
|-
| Main/fg_os_common.cxx  || fgRegisterIdleHandler( & fgIdleFunction ||
|-
|-
| detectSIMD() || bootstrap.cxx || returns true if the cpu supports sse2.
| detectSIMD() || bootstrap.cxx || returns true if the cpu supports sse2.
Line 142: Line 299:
|-
|-
| crInstall(&info)<br>crUninstall() || [http://crashrpt.sourceforge.net CrashRpt.h] || #if defined(HAVE_CRASHRPT). This only happens on windows.
| crInstall(&info)<br>crUninstall() || [http://crashrpt.sourceforge.net CrashRpt.h] || #if defined(HAVE_CRASHRPT). This only happens on windows.
|}
=====Main/main.cxx=====
{| class="wikitable"
|-
! Full Text of Call !! Called Function Location or Include File !! Notes
|-
| from bootstrap.cxx <br/> '''fgMainInit'''( int argc, char **argv ) || '''Main/main.cxx''' || all the arguments from the command line are still there
|-
| sglog().setLogLevels( SG_ALL, SG_INFO )<br>sglog().setStartupLoggingEnabled(true); || /simgear/debug/logstream.cxx || Pretty obvious what this does. || '''What does sglog() actually return?'''
|-
| new '''FGGlobals'''; || Main/FGGlobals.cxx || FGGlobals is a bucket for subsystem pointers and properties representing the sim's state.  It's constructor populates the values, including  the locale, the root node of the property tree, the subsystem, event, command and resource managers. It also adds resource providers for Aircraft, he Aircraft Directory and Add-ons. || Question: What is it that makes globals = new FGGlobals a global object.  Here it's a local variable isn't it? Wouldn't it go out of scope in things fgMainInit calls?
{{WIP}}
|}
=====Main/FGGlobals.cxx=====
{| class="wikitable"
|-
! Full Text of Call !! Called Function Location or Include File !! Notes
|-
| new '''FGRenderer''' || Main/globals.cxx<br/>Viewer/renderer.cxx || || Why is the definition in globals.cxx and in renderer.cxx
|-
| new '''SGSubsystemMgr''' || Main/globals.cxx<br/>Main/subsystemFactory.cxx<br/>simgear/structure/subsystem_Mgr.cxx || What makes a component a candidate for inclusion under the subsystem manager?
|-
| new '''SGEventMgr''' || Main/globals.cxx<br/>simgear/structure/event_mgr.cxx ||
|-
| '''SGCommandMgr'''::instance() || Main/fg_commands.cxx<br/>imgear/structure/commands.cxx <br><br>see also:<br>Main/subsystemFactory.cxx<br>Scripting/NasalSys.cxx for NasalCommand ||
|-
| SGPropertyNode* root = new '''SGPropertyNode'''<br/>  props = SGPropertyNode_ptr(root);|| all of simgear/props || Widely Used || How much of the property Node system does one need to understand?
|-
| locale = new FGLocale(props); || ||
|-
| auto resMgr = simgear::'''ResourceManager'''::instance()|| simgear/misc/ResourceManager.cxx || ||Review: auto and what does the resource manager do?
|-
| new '''AircraftResourceProvider'''() || Local Function ||
|-
| new '''CurrentAircraftDirProvider'''()|| Local Function ||
|-
| new flightgear::addons::'''ResourceProvider'''() || ||
|-
| init_properties()||local function || adds property tree nodes for position/, current-view/ and orientation/
|-
|
sim_time_sec( 0.0 )<br/>
fg_root( "" )<br/>
fg_home( "" )<br/>
time_params( NULL )<br/>
channel_options_list( NULL )<br/>
initial_waypoints( NULL )<br/>
channellist( NULL )<br/>
haveUserSettings(false)
| FGGlobals class initializations || things to be set later
|}
=====Main/fg_init.cxx=====
{{WIP}}
{| class="wikitable"
|-
! Full Text of Call !! Called Function Location or Include File !! Notes
|-
| '''fgInitConfig''' || locally defined ||
* sets up FG_HOME in the property tree, making sure it exists
* sets developer-mode when appropriate
* Read global defaults into globals->get_props() from $FG_ROOT/defaults
|-
| || ||
|-
| || ||
|-
| || ||
|-
|-
| || ||
sglog().setLogLevels( SG_ALL, SG_INFO )<br>sglog().setStartupLoggingEnabled(true); || /simgear/debug/logstream.cxx || Pretty obvious what this does. || '''What does sglog() actually return?'''
|}
|}


980

edits

Navigation menu