How to use AfxDumpStack ?

I would like to use the new stack tracing function. However when calling
the AfxDumpStack function, I only receive some "useless" information:

=== begin AfxDumpStack output ===
Loaded 'F:\Win32sdk\bin\MSPDB41.DLL', no matching symbolic information found.
Loaded 'C:\WINNT\system32\msvcrt40.dll', no matching symbolic information found.
Loaded symbols for 'C:\WINNT\system32\MSVCRT.DLL'
Loaded symbols for 'C:\WINNT\system32\MSVCIRT.DLL'
Error: 87
Error: 6 (MANY TIMES....)
77F67A6B: WINNT\System32\ntdll.dll! _NtOpenFile@24 + 15 bytes
00402C24: AES Prodata Projecten\Metrovias\logtest\Debug\logtest.exe! <no symbol>
00401948: AES Prodata Projecten\Metrovias\logtest\Debug\logtest.exe! <no symbol>
5F4374FC: WINNT\System32\MFC42D.DLL! Ordinal563 + 307 bytes
5F437C2B: WINNT\System32\MFC42D.DLL! Ordinal3657 + 628 bytes
5F43384B: WINNT\System32\MFC42D.DLL! Ordinal3658 + 36 bytes
5F42FB63: WINNT\System32\MFC42D.DLL! Ordinal3670 + 312 bytes
5F42ED65: WINNT\System32\MFC42D.DLL! Ordinal4118 + 83 bytes
5F42ECE8: WINNT\System32\MFC42D.DLL! Ordinal5076 + 46 bytes
5F42C889: WINNT\System32\MFC42D.DLL! Ordinal1045 + 237 bytes
5F42CD25: WINNT\System32\MFC42D.DLL! Ordinal1192 + 129 bytes
5F4905FD: WINNT\System32\MFC42D.DLL! Ordinal1193 + 74 bytes
77E72211: WINNT\system32\USER32.dll! _SendMessageWorker@20 + 157 bytes
77E7356C: WINNT\system32\USER32.dll! _ClientDrawState@40_684_5659@8_86alW@16 + 565 bytes
77E86E01: WINNT\system32\USER32.dll! _MDISetMenu@16 + 20 bytes
77E85F71: WINNT\system32\USER32.dll! _WaitForInputIdle@8 + 34 bytes
77E7124C: WINNT\system32\USER32.dll! _DispatchMessageWorker@8 + 115 bytes
77E754C9: WINNT\system32\USER32.dll! _CallNextHookEx@16 + 351 bytes
77E85FC2: WINNT\system32\USER32.dll! _GdiValidateHandle@4 + 2 bytes
5F432094: WINNT\System32\MFC42D.DLL! Ordinal4206 + 117 bytes
5F43381E: WINNT\System32\MFC42D.DLL! Ordinal4208 + 248 bytes
5F430C48: WINNT\System32\MFC42D.DLL! Ordinal5070 + 152 bytes
5F439343: WINNT\System32\MFC42D.DLL! Ordinal4215 + 85 bytes
5F4397AA: WINNT\System32\MFC42D.DLL! Ordinal4239 + 226 bytes
5F43229F: WINNT\System32\MFC42D.DLL! Ordinal4410 + 514 bytes
5F43469F: WINNT\System32\MFC42D.DLL! Ordinal1862 + 401 bytes
004013FA: AES Prodata Projecten\Metrovias\logtest\Debug\logtest.exe! <no symbol>
5F433623: WINNT\System32\MFC42D.DLL! Ordinal1190 + 131 bytes
004035A8: AES Prodata Projecten\Metrovias\logtest\Debug\logtest.exe! <no symbol>
004033B3: AES Prodata Projecten\Metrovias\logtest\Debug\logtest.exe! <no symbol>
77F1B9EA: WINNT\system32\KERNEL32.dll! _BasepAcquirePrivilege@8 + 310 bytes
00000000: WINNT\System32\ntdll.dll! <no symbol>
=== end AfxDumpStack() output ===

What does error 87 and the many errors 6 mean ? How can I become an interesting trace of my call stack ?
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

>>How can I become an interesting trace of my call stack ?

I think you want the Meta-Physics section of experts exchange
1) You need symbols.

2) You need the Windows NT 4.0 version of IMAGEHLP.DLL. You can copy it to Win98 and Win95 machines, if you want.

AfxDumpStack() has never been tested for backward compatibility like that; if you have an old symbol format lying around, IMAGEHLP.DLL and MSPDB60.DLL must both be capable of talking with eachother and handling the symbol format you're throwing at 'em.  That's certainly not the case for MSPDB41.DLL; that's an ancient version of the PDB helper library--but it's the one you're loading.

"Error 87" indicates that SymLoadModule() failed with an invalid parameter. "Error 6" indicates that the file SymLoadModule() tried to find couldn't be found.

Undoubtedly, these failures are at least partially because you're using the wrong version of MSPDB*.DLL.

..B ekiM

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Gregory_seifertAuthor Commented:
After testing I do have different results (error 998) so I suppose you're way is the correct to follow.

However,Thanks to Microsofts great version control in Windows NT (...) I just can't find the matching files needed.

Can you tell me where you've found the information above ? Where do the error code explenations come from ? What is the complete list of DLLs, ... needed to become the correct symbolic information ?

Gregory Seifert

> However,Thanks to Microsofts great version control
 > in Windows NT (...) I just can't find the matching files needed.

Huh?  What version control is involved here? The MSPDB60.DLL file doesn't need much version control, since the version number is baked into the file name!

Also, I don't see how disdainful comments help anybody.

 > Can you tell me where you've found the information above ?

The compatibility of AfxDumpStack is discussed in the READMEVC.HTM file that's on your product CD.

 > Where do the error code explenations come from ?

You can look for them manually in the WINERROR.H header file. Or, you can use the ErrorLook tool in the Tools menu of the Visual C++ IDE.

 > What is the complete list of DLLs, ... needed
 > to become the correct symbolic information ?

MSPDB60.DLL and IMAGEHLP.DLL from Windows NT.

..B ekiM
Gregory_seifertAuthor Commented:
It seems the explanation of my problem can be found in Microsoft documents indeed:

"AfxDumpStack Does Not Dump Readable Symbols from an MFC Application
If you issue the AfxDumpStack(AFX_STACK_DUMP_TARGET_DEFAULT) function from an MFC application and then run the debug version of the program in the debugger, you will see symbols such as:
      5F43729C: WINNT\System32\MFC42D.DLL! Ordinal563 + 307 bytes
rather than a stack trace, which is what you would expect. This will be fixed in the next version of Visual C++."

and :

"AfxDumpStack API Will Not Work until NT 5.0 Beta 2
The MFC function AfxDumpStack will work correctly only on Windows NT 5.0 Beta 2 or later. Once this OS version is released, you can get imagehlp.dll from your NT installation and use it on other OS installations to get the functionality of AfxDumpStack to work correctly."

As it concerns visual C++6 with service pack 3 already installed, I suppose I'll just have to wait (and use my own old stackdump object) ?
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.