8

I would like to create a simple .MAP file listing addresses and symbol names from a PDB file. My natural inclination was to look for a tool named "pdb2map", but most of the results I get for that appear to refer to a sample program from the CD included with Debugging Applications for Microsoft .NET and Microsoft Windows, which unfortunately is not also posted on the 'net.

Anyone know a good tool for this? Thanks.

SamB
  • 9,039
  • 5
  • 49
  • 56
  • Is there any reason you can't just recompile the code and have the compiler generate a map file? – shf301 Mar 16 '10 at 01:15
  • Well, there are a couple of cases where that doesn't help: (a) you don't have access to the requisite source code, because it's actually a library you want the MAP file for (b) you have a textual crash report (perhaps from a user) and want to see where the crash was – SamB Mar 31 '10 at 16:44

3 Answers3

16

If you have both the application.exe and the application.pdb files, put them in the same directory and run:

dumpbin /map application.exe > application.map

dumpbin comes with Visual Studio and probably with other tools as well.

Alex O
  • 1,429
  • 2
  • 13
  • 20
  • Interesting. This appears to be an undocumented feature. http://msdn.microsoft.com/en-us/library/756as972(v=VS.90).aspx – PaulH Jan 11 '12 at 20:04
  • @PaulH If it helps, Geoff Chappell's site has [a page on it](http://www.geoffchappell.com/studies/msvc/link/dump/options/map.htm?tx=12,27,35,37,46,50&ts=0,3852). It would appear that the biggest issue from the lack of documentation is that if the exe has an Optimisation MAP (or "OMAP"), the map may be inaccurate in at least some (older) versions (this may not apply to more recent versions, I haven't been able to find any more recent unofficial documentation). – Justin Time - Reinstate Monica May 28 '16 at 04:18
3

It seems that this file will do the trick:

http://www.ecs.syr.edu/faculty/fawcett/handouts/testingseminar/Chapter12And14_CodeAndDocs/PDB2MAP.cpp

yurymik
  • 2,194
  • 20
  • 14
  • Couldn't find it anywhere in binary form and no ready to compile source also, so here is my really quick and dirty package. It could be of help for someone. It was scraped from the aforementioned site - it is not written by me, I only compiled it and made some changes in order to be compilable (VS2010 necessary). Here it is: [source+bin](http://nedko.bg/pdb2map-bin+sources.zip) – Nedko Sep 04 '14 at 13:48
2

pdb2map was also discussed in a BugSlayer article in MSDN magazine. Unfortunately, the code archive for the online version of the article has been removed.

John Robbins, the author, has a blog and may be willing to post the code if you request it.

BTW, the book is well worth getting.

Michael Burr
  • 333,147
  • 50
  • 533
  • 760
  • 1
    Sam, take a look at http://www.wintellect.com/Contact.aspx The comments about contacting them indicate they probably wouldn't mind being contacted. Any book by Robbins, Richter or Pietrek are highly recommended. – Stephen Kellett Mar 29 '10 at 19:23
  • @SamB: I think the Wintellect contact info Stephen Kellett pointed to will probably work best, but it's possible that his email address from when he wrote the BugSlayer columns in MSDN Magazine might still work (though I'd honestly be a bit surprised): slayer@microsoft.com – Michael Burr Mar 29 '10 at 19:53