"Optimised Debug" in Visual Studio 2003 ?

  • Thread starter Thread starter John Smith
  • Start date Start date
J

John Smith

Sorry if this is the wrong forum...

Does anyone know what the difference is between a debug build and an
optimised debug build in Visual Studio 2003?
 
Hi John,
debug build: will contain debug info, but code is not optimized
debug optimized build: same as above, but code is optimized

To understand the difference between the two, you might want to compile
the sample code I attached (sample.cs) with and without the optimization
turned on.

Then you can compare the IL and notice the differences (not a lot because
this is a very simple code, but it give you an idea). To generate the IL,
you
can you ildasm.exe (provided with VS 2003). You should be able to see that
the optimizer replaced the "if-else" statement with a "switch-case"
statement
(well, if you look carefully :-).

Another way to compare the differences is probably to step into the code
and bring up the "Disassembly" window...

Hope it helps!

-Matteo

--------------------
 
Yes but what is the need for optmized debug?

since debugger always incurs substancial overhead and the implied assumption
is that efficiency/optimization is necessarily not an issue. If you hold
this statement to be correct then what possible use could optimized debug
serve?

I guess I need a real world example of why you would want to run with this
option considering that if there is a problem in the assembly and you have
built a debug assembly to fish out the issue, you are definitely not
interested in optimizing since the release version will take care of that.

regards
 
Alvin said:
Yes but what is the need for optmized debug?

since debugger always incurs substancial overhead and the implied assumption
is that efficiency/optimization is necessarily not an issue. If you hold
this statement to be correct then what possible use could optimized debug
serve?

I guess I need a real world example of why you would want to run with this
option considering that if there is a problem in the assembly and you have
built a debug assembly to fish out the issue, you are definitely not
interested in optimizing since the release version will take care of that.

regards

Two reasons that I can think off the top of my head:

1) you distribute optimized builds to customers, and you want
corresponding debug symbols so you can do post-mortem debugging for
problems they might encounter;

2) the dreaded (but fortunately rare) situation where the optimized
build behaves differently than the non-optimized.
 
Yes that's true. I did that a lot in C++. But since I moved to the web I had
totally forgotten about it. I guess pushing code to a server instead of to a
client's desktop has screwed with my fundamentals.
 
Back
Top