John, I have set up two test applications to implement the steps required to use a .map file to find a program's crash lien number. The steps I took were as your book "Debugging Applications" described:
- Obtain the crash address.
- Look for an address bigger than the crash address in the map file and note the preceding address.
- Calculate the offset.
crash_address - preferred_load_address - 0x1000 = offset
- Look for a greater offset value in the line number section of the .map file.
- Note the line number of the previous offset value.
Although the procedure successfully identifies the exact line number for a forced crash in my Win32testApp
app (i.e. char* pEmpty = NULL; *pEmpty = 'x')
it doesn't appear to be as accurate in my equivalent MFCtestApp.
In the MFC test the calculations only ever point to the entry point of the function with the crash, and not the line number itself. I suspect it has something to do with Win32's InitInstance() vs MFC's CTestApp::InitInstance(), which is in a class. This is just a hunch.
I would appreciate any ideas on how to make your procedure work with both Win32 and MFC applications. I can send you the two VC projects with their map files if more convenient (115k and 200k). Any help would be most appreciated. Thank you very much.
The technique for looking up crash addresses in MAP files works regardless of C or C++. Are you creating release builds of the two applications? Send me a private mail with the answers. If you have my book, my e-mail address is listed in the forward.