armdevvel / mxe-SHARED

MXE (M cross environment) for ARM32 Windows development (shared libraries)
Other
7 stars 4 forks source link

drmingw: output memory dump of a console app into its stderr stream #45

Closed treeswift closed 1 year ago

treeswift commented 1 year ago

When a console app is being used in a remote / non-GUI session and crashes, and DrMingw is registered as the default debugger, the stack dump window is displayed in the graphic session. The application has to be forcibly terminated with TASKKILL /F /IM <progname.exe> or TASKKILL /F /PID <pid>.

Nice to have: for a console app, redirect the dump to the session the application is running in.

treeswift commented 1 year ago

https://learn.microsoft.com/en-us/windows/win32/api/handleapi/nf-handleapi-duplicatehandle

treeswift commented 1 year ago

A recent DrMingw has https://github.com/armdevvel/drmingw#catchsegv

However, ARM32 CONTEXT layout needs to be supported. Forking.

treeswift commented 1 year ago

It kinda works:

Running catchsegv dirinfo on Admin@Greylorn (assuming correct PATH):
dirinfo.exe caused an Access Violation at location 010215AF in module dirinfo.exe Writing to location 00000001.

Flags=0020000f (CONTEXT_ARM|CONTROL|INTEGER|FLOATING_POINT|DEBUG_REGISTERS)

r0=00000011 r1=00000001 r2=00000144 r3=00F4F7A0
r4=00000003 r5=00000030 r6=00F4F7E0 r7=75BAB6D5
r8=75BA3DF9 r9=00000001 r10=01092988 fp=00F4F800
r12=00000000 sp=00F4F7C0 lr=6067344F pc=010215AF

AddrPC   Params
010215AF 00000011 00000001 00000144  dirinfo.exe!main+0x173  [/home/lxe/Code/mxe-shared/tmp-libfatctl-armv7-w64-mingw32/local.build_/../../../libfatctl/samples/dirinfo.cpp @ 49]
6067344F 00000011 00000001 00000144  ucrtbase.DLL!_open_osfhandle+0x14f

Assuming valid frame pointer in release code produces funny results, but at least the register dump and code line resolution work. (Build client code with -g -gdwarf-aranges -fno-omit-frame-pointer.)

treeswift commented 1 year ago

Once ARM32 support is proven to be mature, it will probably be worth upstreaming.