How to debug C++ Gauges ?

Please can someone point me in the right direction to figure out how to setup to debug a FSX C++ dll Gauge in VS2008.

Currently gauge runs, and is loaded in an aircraft panel, but it is not doing what I expected it to do, and I want to set some breakpoints and examine some variables etc.

(Never debugged a dll before -- fine with degugging an exe).

Geoff_D
 

n4gix

Resource contributor
From what I've been told by the nice folks at ACES, the debugger is broken in FSX... :rolleyes:
 
No, it works fine. I use VS 2008 Pro, but Express should be the same.

1) Compile your gauge in debug mode, copy to gauges (or panel folder).

2) Run up FSX.

3) In VS, select "Attach to process" from the Debug menu and select FSX.

You should be able to break, modify and continue running without a problem. (Works fine for me anyhow.) Note that your breakpoints only become active when your aircraft (and hence the dll) is loaded.

Note that some changes require a complete rebuild, i.e. new global vars, and you have to disconnect, switch aircraft in order to be able to compile and overwrite the .gau/dll file before you can reconnect and debug again.

I've found this an absolute life-saver during development.

Si
 
No, it works fine. I use VS 2008 Pro, but Express should be the same.

1) Compile your gauge in debug mode, copy to gauges (or panel folder).

2) Run up FSX.

3) In VS, select "Attach to process" from the Debug menu and select FSX.

I've found this an absolute life-saver during development.

Si
Thanks Si

I'll try that tonight. Before I was failing top start FSX first, and letting the debugger start it.

Wonder if I should be in a plane without the Gauge to be debugged when I start the debugger attached to FSX, and then switch to the plane, or if that makes no difference.
Guess I will find out tonight. :)

Thanks again

Geoff_D
 

n4gix

Resource contributor
Bill, then how do you debug YOUR C Gauges :rolleyes: :rolleyes: :rolleyes:

Geoff_D
What are bugs? :D

Seriously, I do it the "old-fashioned way..."

I have several methods that I can use. The most important one being that I develop and test only discrete routines which I've designed to be modular in nature with very tightly defined inputs and outputs.

Completely aside from which, I code on one machine and run FS on an entirely separate computer in the library. It's not possible to run the debugger across a network, and even if it were possible, with the two computers in entirely different rooms it would make it a real challenge! :D

I've tried to find the source of my information, but it's been too long ago for me to remember exactally where I read it. It may well have been in one of the 'super-secret' newsgroups ACES runs... :)
 
Last edited:
Geoff, FSX needs to be running before you can do "Attach to task" as otherwise it's simply not in the list.

I find debugging invaluable when I need to route through the pgauge structure, not to mention debugging SimConenct in gauges.

Bill, I think there used to be an issue where FS (not sure if it was FS9 or FSX RTM) would not allow a debugger to be connected to it - many programs don't. But I think I recall reading that they relented on this.

Si
 
Geoff, FSX needs to be running before you can do "Attach to task" as otherwise it's simply not in the list.

I find debugging invaluable when I need to route through the pgauge structure, not to mention debugging SimConenct in gauges.


Si
Si

Been debugging all evening -- but not happily. :(
Debugger works great -- just cannot understand what is going on, or to be more exact, why I am getting the data corruption I am seeing.

Are you, or anyone else here, familiar with "singletons" ?

Trying to run a new ESP(/FSX) example that uses a singleton, and it seems to be getting corrupted somehow.

C++ Drawing Gauges Using GDI+ http://code.msdn.microsoft.com/ESPDrawingGaugesGDI

Anyone up for a debugging challenge ? :rolleyes:

Geoff_D
 
Are you, or anyone else here, familiar with "singletons" ?
Hello,

the Singleton it's an OOP programming pattern. Patterns are building blocks for common programming tasks, and their usage was formalized by the famous (I STRONGLY suggest reading it, re-reading it and read it again, for anyone wanting to become a better C++ programmer...) book called "Design Patterns: Elements of Reusable Object-Oriented Software", written by what is usually know the "Gang of Four", here's a link:

http://www.amazon.com/Design-Patterns-Object-Oriented-Addison-Wesley-Professional/dp/0201633612

Patterns presented in this book have specific names that are useful, when discussing between developers, in order to understand exactly what we are referring to. Patterns are not related to C++, it's possible to write a Singleton (or any pattern) with any OOP language. So, a pattern is not really a language element, is more like a defined method to do something.

The Singleton pattern is a way to allow "globals" in a more elegant and object oriented way. We all have read everywere that globals are evil, but sometimes can be useful. The Singleton is just a container for globals, that allows to use data C++ (or any similar OOP language) access protection features, to at least contain the mess that globals usually do, and wrap them up in a more maintainable way.

More info here:
http://en.wikipedia.org/wiki/Singleton_pattern

The Singleton is a very simple pattern, its main feature is that, there can be only ONE instance of a variable declared as a Singleton.

This is obtained in a very clever way, by making the constructor private. The variable is instead declared using an Instance() member function that "knows" if an instance of this Singleton class has already defined or not. If it has, the function will return the instance itself. If not, it will create the first istance.

So, the net effect would be that, if a variable has been declared as a Singleton (more correctly "has been declared with a type of a class made using the Singleton pattern"), there will be one variable of that type in the whole program. The pattern itself would automatically prevent to create another instance!

This is very useful as a container for global simulation variables and anything else that shouldn't be declared more than once.

I haven't seen the ESP sample but, I've used the Singleton pattern in several projects already, like the Cloud9 MB339 and F4 Phantom and of course the F/A-18 we did for Microsoft, and it really helps to keep the code tidy and readable in places were you would need globals, but you don't want the extra associated mess that comes with them.
 
Top