WinDbg !heap command not working due to missing sy

2019-04-09 22:56发布

问题:

I am trying to use WinDbg debug my .NET application with C++ unmanaged memory allocations.

When I try to run the !heap command, I get the following error message:

0:022> !heap
*** ERROR: Symbol file could not be found.  Defaulted to export symbols for C:\Windows\system32\KERNEL32.dll - 
*************************************************************************
***                                                                   ***
***                                                                   ***
***    Your debugger is not using the correct symbols                 ***
***                                                                   ***
***    In order for this command to work properly, your symbol path   ***
***    must point to .pdb files that have full type information.      ***
***                                                                   ***
***    Certain .pdb files (such as the public OS symbols) do not      ***
***    contain the required information.  Contact the group that      ***
***    provided you with these symbols if you need this command to    ***
***    work.                                                          ***
***                                                                   ***
***    Type referenced: ntdll!_HEAP_ENTRY                             ***
***                                                                   ***
*************************************************************************
Invalid type information

How can I fix this error?

回答1:

Use the following commands to fix your symbol path:

.symfix
.reload


回答2:

Configure a symbol server. Follow there steps:

  1. Create a local directory for downloaded symbols. I'll use "C:\Symbols".
  2. Select "Symbol File Path..." from the "File" menu.
  3. Enter "SRV*C:\Symbols*http://msdl.microsoft.com/download/symbols" and press "OK".
  4. Try again. Initially there'll be a delay while the symbols are download. In future the local copies (step 1) will be used.

See here for more details.



回答3:

You need to set the symbols for your application and also have it point to windows symbol server. For windows symbol server you can do what Steve says.

"SRV*C:\Symbols*http://msdl.microsoft.com/download/symbols"

After that, set !sym noisy which will do symbol loading in verbose mode.

Do .reload and this lets you know which symbols are needed but not found.

If you already know the location of pdbs for your application make the symbol path point to that and repeat the steps above to make sure all required symbols are loaaded.