c++visual-studiodllpdb-filesminidump

Stacktrace of self created Minidump-File can't be used correctly, when the Exception occurred in foreign source code


I can't analyse a Stack Trace of my self created Minidump-File when the exception occurred in a foreign source code.

Stack Trace

The Stack Trace than looks like:

    [Frames may be missing, no binary loaded for ForeignLib1.dll]   Annotated Frame
    >   ForeignLib1.dll!00000000454fc028    Unknown No symbols loaded.

But should look like:

    ForeignLib1.dll!00000000454d1fe8    Unknown No symbols loaded.
    >   MyDll.dll!get_modeldoc  C++ Symbols loaded.
    ...(about 75 further Entries)
    ForeignExecutable.exe!000000014000f973  Unknown No symbols loaded.
    kernel32.dll!00007ffbae331fe4   Unknown Non-user code. Symbol loading disabled by Include/Exclude setting.
    ntdll.dll!00007ffbaf07f061  Unknown Non-user code. Symbol loading disabled by Include/Exclude setting.

My Application is a DLL, which is loaded in a foreign Executable. I can't get a PDB-File of this Executable, so I can't load the Symbols of the ForeignLib1.dll Library...

Minidump

I created the Minidump with the following Flags:

MINIDUMP_TYPE mdt = (MINIDUMP_TYPE)(
    MiniDumpWithDataSegs |
    MiniDumpWithHandleData |
    MiniDumpWithFullMemoryInfo |
    MiniDumpWithThreadInfo |
    MiniDumpWithUnloadedModules |
    MiniDumpWithCodeSegs
    );

And the CallbackRoutine includes the following Types:

IncludeModuleCallback
IncludeThreadCallback
ModuleCallback //(MyDll.dll and all ForeignLib-Dlls)
ThreadCallback
ThreadExCallback

The DMP-File is created with MiniDumpWriteDump(...)

// generate the crash dump
BOOL result = MiniDumpWriteDump( hProc, procID, hFile,
                                 mdt, sehPtr, NULL, &mci );

Example

When the Exception occurs in my source-code, then I can analyse the Stack Trace by loading my PDB-File:

//MySource.cpp
int a = 0;
int b = 5 / a; // Exception, but Stack Trace can be analysed in DMP-File.

But When the Exception occurs in a foreign source-code, which is called by my source-code, I only see the foreign-dll in the Stack Trace:

//MySource2.cpp
foreignModul->EnumDocuments2( nullptr ); // Exception, Stack Trace can't be analysed in DMP-File!!

Question

How can I write a DMP-File with a correct Stack Trace or how can I analyse the Stack Trace when the exception occurred in foreign source-code?


Solution

  • I found the solution by myself. If you have the exact ForeinLib1.dll (Binary equal) from the Minidump, it's possible to analyse the Stack Trace in Visual Studio:

    1. Right-Click on the unloaded DLL and select "Load Symbols" VS-Screenshot Load Symbols

    2. Select the DLL-File (It must be Binary Equal to the one from the Minidump) in the File-Browse-Dialog.

    3. Visual Studio asks for the PDB-File in a new File-Browse-Dialog. Just cancel this. VS-Screenshot Cancel PDB Selection

    4. Visual Studio now needs some time to analyse the DLL-File (about 2 Minutes for a 50mb File).

    5. The Stack Trace is now complete, or you must load the next "unloaded" DLL-File.