MapFile : A tool to analyze .MAP files produced by Visual Studio and report the amount of memory being used by data and code
It really annoys me that I had to write today's code snippet. I fully expected to be able to find an existing tool that could accomplish this basic task but after literally a couple of hours of searching the Internet for something I gave up. In the end I had to write my own tiny console application and I am making it available here so nobody else feels like they have to write it again.
Also, if anyone reading this is really good at web stuff, it would be nice to have a website that would let you upload a .MAP file and then be able to immediately view the HTML content.
The data in this version is pretty complete. For some reason when I parse all of the address data found in the .MAP file it doesn't add up to the exact byte count that is in the sections summary. Maybe somebody from Microsoft can explain why that is.
The data could probably be a little better organized and it could really benefit from some hyperlinks. That said, still all of the data you need is there.
A .MAP file is an ASCII text file that can be produced by the linker phase in Visual Studio. Under Linux the GCC compiler can also produce a .MAP file but I have no idea if the two formats are compatible. For my needs I was only concerned about builds that were done with Visual Studio. This works even if you are building for XBOX as well.
A .MAP file is essentially a 'memory map' of the executable. It describes by memory address every piece of code and data in the resulting executable file.
Unfortunately it it not very human readable. The function names in the map file are 'decorated'; meaning they have been scrambled/compressed into a machine only readable format. A DLL that comes with Windows called 'dbghelp.dll' can 'undecorate' these strings into their human readable form.
The MapFile console application will read in a .MAP file and output an HTML file called 'output.html' that contains tables representing all of the code and data sections in the executable.
The tables are sorted either by object name or by function name.
An executable is broken up into various 'section's and the HTML output is likewise broken up the same way.
You might ask, why would you need this tool? Well, I suppose that is a fair question. Let's say you are targeting an Xbox-360 console machine and your executable size is 10 megabytes. That's just huge. So, you are going to want to know where all of that data coming from. Is it code and, if so, from what source files and what functions? Is it data and, if so, what kind of data is it and where is it located?
I have set up a Google Project to host this tool. You can find it at the following link:
MapFile on Google Code
Another reason you might want to download the source code to this tool is that it demonstrates how to use two of my most powerful code snippets. The first is the 'InPlaceParser', which is an extremely high speed text parser and the second is 'HtmlTable' which is a code snippet that will output nicely formated HTMLTables with headers, sorted columns, and totals.
Both code snippets are really useful.



5 Comments:
At 12:31 PM,
bubu said…
There is similar tool that extracts size information form pdb file using DIA interfaces: http://aras-p.info/projSizer.html
At 12:43 PM,
John said…
Thanks for the link. We definitely produce significantly different output. At first glance projSizer seems to do a much better job of summarizing the data than my version.
Thanks,
John
At 3:37 PM,
Dan Glastonbury said…
John,
I haven't look at your tool, but the description of it reminded me of this series of articles: http://gameangst.com/?p=320
At 10:32 AM,
JK said…
Dude, you are on a roll lately. 4 entries since the last time I checked. PhysX2OBJ is a great idea, never thought about debugging a physics scene by dumping the whole thing to a file.
At 9:00 PM,
Sergey Sikorskiy said…
A similar UI tool: http://www.sikorskiy.net/prj/amap/index.html
Post a Comment
<< Home