SDK Question How do I get started debugging Atlantis?

chalcrow

Donator
Donator
Joined
Nov 30, 2016
Messages
12
Reaction score
0
Points
0
I'm trying to debug the Atlantis sample for the first time. I've added breakpoints in places I'd expect to be hit, for example on ln195 of Atlantis.cpp which seems to create the Space Shuttle Main Engine - I'd expect it to be hit when I first launch the Atlantis sample:

Code:
// --------------------------------------------------------------
// Initialise the thrusters for the shuttle main engines
// --------------------------------------------------------------
void Atlantis::CreateSSME()
{
	// Not connected to a propellant resource - they connect to the ET's tank as long
	// as it is attached (checked in clbkPreStep)
	th_main[0] = CreateThruster (THRUSTREF_SSME0, THRUSTGIMBAL_LAUNCH, ORBITER_MAIN_THRUST, NULL, ORBITER_MAIN_ISP0, ORBITER_MAIN_ISP1); // breakpoint on this line

I'm then running the solution in Visual Studio by clicking the green 'run' arrow, which successfully runs Orbiter. I then run the 'Launch into sunrise' scenario for Atlantis, however none of my breakpoints are hit. I've searched for a main() function across the solution but there isn't one.

I'm trying to make some tweaks to the Atlantis sample, to change how the simulator behaves, and ultimately to tweak the launch autopilot, as I'm using Orbiter to learn some concepts of spacecraft launch stability control.

How do I start debugging? And also if anyone can advise on a starting point for being able to understand how the code works and how I can understand it enough to achieve what I'm trying to do, that would be fantastic. I've been looking for SDK tutorials online but haven't been able to find much.
 

GLS

Well-known member
Orbiter Contributor
Addon Developer
Joined
Mar 22, 2008
Messages
5,965
Reaction score
2,991
Points
188
Website
github.com
The way I do debugging is by launching the Orbiter process (normally), and then before starting a scenario I go to "Debug >> Attach to process" in VS and select orbiter.exe from the list. VS then changes to debug mode and now I start the scenario and the breakpoints should work as advertised.

Btw: modules don't have a main() function. It all starts with ovcInit() in which you create your vessel class.
 

chalcrow

Donator
Donator
Joined
Nov 30, 2016
Messages
12
Reaction score
0
Points
0
GLS thanks for the hint. I'm attaching to process and I've added a breakpoint on the 1st line of ovcInit() in Atlantis.cpp - still no luck. I'll play around by rebuilding and looking at the scenarios and see if I can figure it out, however if you have any advice or ideas please let me know. It's the 'launch into sunrise' scenario that I'm starting.

I'll follow the code through from ovcInit() to figure out how things work in Orbiter, as much as I can.
 

Urwumpe

Not funny anymore
Addon Developer
Donator
Joined
Feb 6, 2008
Messages
37,673
Reaction score
2,402
Points
203
Location
Wolfsburg
Preferred Pronouns
Sire
Remember to build the module in debug configuration. Also, did you make sure the module in build into the modules folder of your debug installation of Orbiter?
 

chalcrow

Donator
Donator
Joined
Nov 30, 2016
Messages
12
Reaction score
0
Points
0
Thanks Urwumpe. I've selected debug from the options at the top of VS (see attached image)Capture.JPG

I'm not sure what you mean by 'debug installation of Orbiter'. I'm compiling the sample direct from the samples folder of my only Orbiter installation. I'm managing the code as a git repo. Is there a different way you would recommend to develop the sample?

Also where do I find the modules folder?
 

Face

Well-known member
Orbiter Contributor
Addon Developer
Beta Tester
Joined
Mar 18, 2008
Messages
4,404
Reaction score
581
Points
153
Location
Vienna
I'm not sure what you mean by 'debug installation of Orbiter'. I'm compiling the sample direct from the samples folder of my only Orbiter installation. I'm managing the code as a git repo. Is there a different way you would recommend to develop the sample?

Also where do I find the modules folder?

The idea is that the VS projects are configured to build the binaries directly into the modules folder of the Orbiter installation you use to debug (i.e. the one you have your samples folder in). The modules folder is in your Orbiter root directory.

For debugging samples, you usually configure the main project of a VS solution to start the Orbiter executable on debug. This means that on initiating a debug run, the main project is built, the executable is started, and the debugger gets attached to that executable. Orbiter will load vessel modules from the modules folder, and if your project(s) puts the binaries directly in that folder, the debugger will also find the debug symbols (*.pdb) there, so the breakpoints should work.
 

chalcrow

Donator
Donator
Joined
Nov 30, 2016
Messages
12
Reaction score
0
Points
0
Thanks Face. My *.pdb files appear to be in C:\Orbiter2016\Orbitersdk\samples\Atlantis\Debug (I can see that the *.pdb files in there were created recently), while the C:\Orbiter2016\Modules folder contains the following dlls:

Atlantis
Atlantis_SRB
Atlantis_Tank

The 'Date modified' on those .dll's is 2016.

you usually configure the main project of a VS solution to start the Orbiter executable on debug

... do you mean that I should right-click on the 'Atlantis' project and 'Set as Startup Project'? If I right-click the 'Atlantis' project and select 'Properties', I have Configuration Properties > Debugging > Command > $(OrbiterDir)\Orbiter.exe (this looks correct - my $(OrbiterDir) is configured correctly in the property sheets).

If I right-click the 'Atlantis' project and select 'Properties', I also have Configuration Properties > Debugging > Attach. If I set this to 'yes', then launch Orbiter normally and hit the Green 'run' button in VS, it still doesn't do anything.

---------- Post added at 11:48 AM ---------- Previous post was at 11:45 AM ----------

I tried right clicking the 'Atlantis' project then 'Set as startup project' > rebuild > run. Still nothing
 

Urwumpe

Not funny anymore
Addon Developer
Donator
Joined
Feb 6, 2008
Messages
37,673
Reaction score
2,402
Points
203
Location
Wolfsburg
Preferred Pronouns
Sire
Well, the most common cause, when a breakpoint should be triggered, but is not, is simply that the wrong binary is executed. In that case, you should make sure that Orbiter loads your new version of the DLL, not the old one.

And yes, setting a breakpoint requires to recompile a DLL. Its not like in script languages like Python or Lua.
 

Face

Well-known member
Orbiter Contributor
Addon Developer
Beta Tester
Joined
Mar 18, 2008
Messages
4,404
Reaction score
581
Points
153
Location
Vienna
Thanks Face. My *.pdb files appear to be in C:\Orbiter2016\Orbitersdk\samples\Atlantis\Debug (I can see that the *.pdb files in there were created recently), while the C:\Orbiter2016\Modules folder contains the following dlls:

Atlantis
Atlantis_SRB
Atlantis_Tank

The 'Date modified' on those .dll's is 2016.

There is your problem. It seems like the Atlantis projects do not build into the modules folder. If you manually copy the binaries from the samples debug folders into the modules folder, then run the startup project without recompile, the breakpoint should hit.

Unfortunately I did not have time to check the bundled Atlantis project for myself (again), but I hope to do so on the weekend. Perhaps I can then get back to you with more information.
 
Top