jrfonseca / drmingw

Postmortem debugging tools for MinGW.
GNU Lesser General Public License v2.1
273 stars 53 forks source link

Does not demangle MinGW 4.8 C++ names #23

Closed strixcode closed 8 years ago

strixcode commented 8 years ago

I use DrMinGW 0.7.5 (32) with an app compiled with MinGW 4.8.2. It works good but doesn't demangle C++ (Qt) names, ex:

6E1EBA87 0091C698 6E26612C 0029FD0C QtCore4.dll!ZN21QEventDispatcherWin3213processEventsE6QFlagsIN10QEventLoop17ProcessEventsFlagEE 6E1C457E 0029FD0C 00000014 00000004 QtCore4.dll!ZN10QEventLoop13processEventsE6QFlagsINS_17ProcessEventsFlagEE 6E1C4859 0029FD44 00000000 0091AA81 QtCore4.dll!ZN10QEventLoop4execE6QFlagsINS_17ProcessEventsFlagEE 6E1C93A1 0000000C 00918A9C 00000014 QtCore4.dll!ZN16QCoreApplication4execEv

I think the problem is in mgwhelp.c:

DWORD WINAPI
MgwUnDecorateSymbolName(PCSTR DecoratedName, PSTR UnDecoratedName, DWORD UndecoratedLength, DWORD Flags)
{
   assert(DecoratedName != NULL);

    if (DecoratedName[0] == '_' && DecoratedName[1] == 'Z') {

I think the condition should be changed to:

if ((DecoratedName[0] == '_' && DecoratedName[1] == 'Z') || (DecoratedName[0] == 'Z' && DecoratedName[1] == 'N')) {
jrfonseca commented 8 years ago

I think it's a bit more sutble than that.

I suspect that, the Qt*.dll binaries had their debug info stripped, and that the debug symbols aren't found, so DrMinGW is falling back to COFF symbols in the .dlls, and those symbols don't have '_' prefix...

strixcode commented 8 years ago

It works with the modified if condition and also works if the condition is removed and __cxa_demangle is called for all names.

jrfonseca commented 8 years ago

Could you point me to where I can download this particular QtCore4.dll so I can repro locally?

strixcode commented 8 years ago

This is Qt 4.8.7 MinGW edition http://download.qt.io/official_releases/qt/4.8/4.8.7/qt-opensource-windows-x86-mingw482-4.8.7.exe

jrfonseca commented 8 years ago

Thanks.

The problem is indeed more subtle:

I pushed a bunch of fixes to this. It should work well now.

strixcode commented 8 years ago

Thank you very much. This is essential fix for all Qt apps. Will you release version 0.7.6 with this change now?

jrfonseca commented 8 years ago

Will you release version 0.7.6 with this change now?

Done.