.PDB contains less information in RELEASE than in DEBUG?!

D

David Krmpotic

it's me again..
with quite interesting discovery :)

I was tracing an error for 3 hours instead of 3 minutes because of this
surprise.

Recently I'm compiling this project in RELEASE with Debug info turned on so
that it creates .PDB files and I can see the line numbers in stack trace.

To my surprise, release version of .pdb pointed me only to the beginning of
the method saying that Index was out of range. But there was nothing like
that there. After finding an error by other means, I tried to compile the
project in debug mode and regenerate the error. This time I saw the correct
line number. If the release version pointed me to here, I could see what's
the problem immediatelly.

how can I force release PDB to behave like debug PDB?
Release PDB only gives me approxiamate exception location!?

THANK YOU!

david
 
S

Sylvain Lafontaine

Obviously, the Release mode is not the same thing as the Debug mode;
otherwise it would be totally unnecessary.

The release mode cannot give you the exact location because the code has
been internally optimized by the compiler and things such as a "line of
code" doesn't really exist anymore.

S. L.
 
D

David Krmpotic

I know it's not the same.. but I was hoping that this would still be
possible in release.
only that asserts would be thrown out in debug and some other things.

so that's just how it is ?

ok then.. thank you !
 
A

Andrew Smith \(Infragistics\)

Perhaps try changing the 'Optimize code' option (in the projects settings)
for the release configuration to false.
 
D

David Krmpotic

You got it! indeed, when I change it to false, it shows the exact line
number.
so I guess this is a tradeoff.. or...

... does anybody have some other suggestions for having the code optimized
and still get the right line number?
 
L

Larry Brasfield

David Krmpotic said:
You got it! indeed, when I change it to false, it shows the exact line
number.
so I guess this is a tradeoff.. or...

.. does anybody have some other suggestions for having the code optimized
and still get the right line number?


I do not mean to disparage the explanation already
given about this. But I will try to clarify.

With no or very simple optimizations, there is a
one-to-one correspondence between lines of
source code and contiguous clumps of machine
code. Under such circumstances, it is meaningful
to speak of "the right line number".

There are levels of optimization, commonly
obtained by modern compilers, (including the
MS product), where there is no simple relation
between lines of source code and the clumps
of machine code. The whole idea of "stepping
thru lines of code" breaks down, becomes
inapplicable. The "right line number" does not
exist. It might be possible to assign fragments
of source code, consisting of subexpressions,
to an arbitrary (valid) instruction pointer, but
this is not done and would undoubtedly be
quite confusing if anybody actually did it.

The short answer to your question is "no".
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top