[dbghelp 4/10] Rewrite much of the symbol lookup method to work with Optimized PDB files as well

Jason Green jave27 at gmail.com
Wed Jan 23 08:14:18 CST 2008

On Jan 22, 2008 4:00 PM, Eric Pouech <eric.pouech at orange.fr> wrote:
> Jason Green a écrit :
> > Re-responses from Eric van Beurden:
> >
> >
> >> hmm I still don't get how, in a generic way symbols could overlap
> >> the only think I could come up with if when static functions get
> >> automatically inlined by the compiler, but that's rather a different
> >> story (as I'd suspect the inlined function to be a single memory range
> >> within a container => and in that case returning the shortest matching
> >> symbol should be fine is there an existing exe/pdb file available for
> >> further testings
> >>
> >
> >
> > in testing with one of our projects, i was seeing symbols lookups fail
> > 85-90% of the time with the initial versions of dbghelp.  The PDB
> > files that were being used were generated along with the release build
> > of the project (it was a C++ project as well).  On further
> > investigation i found that the lookups were failing because many
> > symbol addresses and ranges were overlapping.  This seemed to occur on
> > even unrelated objects and symbols.  I would suspect it was the result
> > of the optimizations the compiler performed.
> >
> > I was able to generate PDBs that exhibited this behaviour with every
> > test app i built under Visual Studio (v7.1 and 8.0Express); even apps
> > that were only 25 lines long.  Since it was very repeatable and the
> > project in question would always be using PDBs generated from
> > optimized release builds i decided to change the symbol lookup method
> > to take the range into account and to be able to store a sublist of
> > all symbols whose addresses fall into the same range (15-25% of the
> > lookups still failed with just the range addition).
> >
> I'm still not convinced that the fix proposed is the correct one. Do you
> have one of those examples handy so that I can have a look on it (src
> file + .exe + .pdb) ? that would be great

Re-re-responses from Eric van Beurden.  I'll send the sample app to
you off-list (and anyone else who wants a copy, just email me

I tracked down one of my sample apps that showed the overlapping
symbols issue in its PDB file.  Many of the symbols in it are either
coincident or overlapping.  In some cases the overlap occurs between a
C++ decorated name and its undecorated counterpart, but in several
cases the overlapping symbols are unrelated.  For some symbols it
could be possible that their sizes are being read incorrectly from the

The original symbol lookup method used a binary search on a symbol
list that was sorted by starting address.  The issue was that during
the search it was skipping over the correct symbol because its
starting address was the same as a previous symbol's address.  This
sent the search in the wrong direction after that and the lookup would
fail.   There was no fallback for handling the case of the symbol
being coincident with another or the symbol being within the address
space of another symbol.

The attached archive contains 4 files:
- 'emptyTest.exe': the optimized release build executable linked to
'emptyTest.pdb'.  This should crash.
- 'emptyTest.pdb': the PDB file
- 'main.cpp': the source file for the test app.  Some of the code is
unused as the app has morphed over time.
- 'emptyTest.vcproj': the VC++7.1 project file for the test app

More information about the wine-devel mailing list