Hi all,
Since yesterday, dwarf4 debug format support is included in dbghelp.
background ---------- Wine has been using dwarf2 for years, and hasn't updated to dwarf4 (gcc and most of distros switched more than 10 years ago). As distros have been switching to dwarf5 for 6 months to a year now, it's time to be back on track.
status ------ As of today, support for reading and managing dwarf4 debug info is included in dbghelp (as well as dwarf2 and dwarf3). However, by default Wine is still compiled with dwarf2.
need for help ------------- Before enabling dwa, feedback is requested on dwarf4. How can you help: Setup the dwarf4 debug format for wine compilation using:
./configure CFLAGS="-gdwarf-4 -O2" CROSSCFLAGS="-gdwarf-4 -O2" make -B
We need to configure both gcc for ELF compilation, and the cross compiler (hence the two options to configure). And we need to recompile everything.
improvements ------------
Here's a typical debugging session (compiled with dwarf2):
[eric:~/work/output-wine/wine64]$ ./wine programs/winedbg/winedbg.exe.so notepad WineDbg starting on pid 0100 RtlDefaultNpAcl () at Z:\home\eric\work\wine\dlls\ntdll\sec.c:1731 0x000000007bc50679 RtlDefaultNpAcl+0x2b9 [Z:\home\eric\work\wine\dlls\ntdll\sec.c:1731] in ntdll: ret 1731 } Wine-dbg>b CreateWindowExW Breakpoint 1 at 0x000000006eb91448 CreateWindowExW [Z:\home\eric\work\wine\dlls\user32\win.c:1913] in user32 Wine-dbg>c Stopped on breakpoint 1 at 0x000000006eb91448 CreateWindowExW [Z:\home\eric\work\wine\dlls\user32\win.c:1913] in user32 CreateWindowExW () at Z:\home\eric\work\wine\dlls\user32\win.c:1913 1913 { Wine-dbg>bt Backtrace: =>0 0x000000006eb91448 CreateWindowExW(exStyle=<is not available>, className=<is not available>, windowName=<is not available>, style=<is not available>, x=<is not available>, y=<is not available>, width=<is not available>, height=<is not available>, parent=<is not available>, menu=<is not available>, instance=<is no t available>, data=<is not available>) [Z:\home\eric\work\wine\dlls\user32\win.c:1913] in user32 (0x0000000000000559) 1 0x0000000000405008 WinMain+0x3a7(hInstance=0x400000, prev=<is not available>, cmdline=<is not available>, show=0x1) [Z:\home\eric\work\wine\programs\notepad\main.c:792] in notepad (0x0000000000000559) 2 0x0000000000406326 main+0xa5(argc=<is not available>, argv=<is not available>) [Z:\home\eric\work\wine\dlls\msvcrt\crt_winmain.c:53] in notepad (0x0000000000000000) 3 0x0000000000406155 mainCRTStartup+0x64() [Z:\home\eric\work\wine\dlls\msvcrt\crt_main.c:58] in notepad (0x0000000000000000) 4 0x000000007b62c679 BaseThreadInitThunk+0x8(unknown=<is not available>, entry=<is not available>, arg=<is not available>) [Z:\home\eric\work\wine\dlls\kernel32\thread.c:61] in kernel32 (0x0000000000000000) 5 0x000000007bc56c73 RtlUserThreadStart+0x82(entry=0x4060f0, arg=0x3f0000) [Z:\home\eric\work\wine\dlls\ntdll\thread.c:241] in ntdll (0x0000000000000000) Wine-dbg>
Note that most of variables in stack trace are not useful.
With Wine recompiled with dwarf 4 support, you get: [eric:~/work/output-wine/winedw4-64]$ ./wine programs/winedbg/winedbg.exe.so notepad WineDbg starting on pid 0104 0100:fixme:dbghelp_dwarf:compute_location Only supporting one breg (rcx/330 -> r14/342) RtlDefaultNpAcl () at Z:\home\eric\work\wine\dlls\ntdll\sec.c:1731 0x000000007bc50679 RtlDefaultNpAcl+0x2b9 [Z:\home\eric\work\wine\dlls\ntdll\sec.c:1731] in ntdll: ret 1731 } Wine-dbg>b CreateWindowExW 0100:fixme:dbghelp_dwarf:dwarf2_read_range no entry found 0100:fixme:dbghelp_dwarf:dwarf2_read_range no entry found 0100:fixme:dbghelp_dwarf:compute_location Only supporting one breg (r8/336 -> r10/338) 0100:fixme:dbghelp_dwarf:compute_location Only supporting one breg (rdx/331 -> rcx/330) 0100:fixme:dbghelp_dwarf:compute_location Only supporting one breg (r10/338 -> r8/336) 0100:fixme:dbghelp_dwarf:compute_location Only supporting one breg (rbx/329 -> r12/340) 0100:fixme:dbghelp_dwarf:dwarf2_read_range no entry found Breakpoint 1 at 0x000000006eb91448 CreateWindowExW [Z:\home\eric\work\wine\dlls\user32\win.c:1913] in user32 Wine-dbg>c Stopped on breakpoint 1 at 0x000000006eb91448 CreateWindowExW [Z:\home\eric\work\wine\dlls\user32\win.c:1913] in user32 CreateWindowExW () at Z:\home\eric\work\wine\dlls\user32\win.c:1913 1913 { Wine-dbg>bt Backtrace: =>0 0x000000006eb91448 CreateWindowExW(exStyle=0, className="Notepad", windowName="Notepad", style=0xcf0000, x=0x1, y=0x25, width=0x558, height=0x402, parent=(nil), menu=(nil), instance=0x400000, data=0x0(nil)) [Z:\home\eric\work\wine\dlls\user32\win.c:1913] in user32 (0x0000000000000559) 1 0x0000000000405008 WinMain+0x3a7(hInstance=0x400000, prev=<is not available>, cmdline=<is not available>, show=0x1) [Z:\home\eric\work\wine\programs\notepad\main.c:792] in notepad (0x0000000000000559) 2 0x0000000000406326 main+0xa5(argc=<is not available>, argv=<is not available>) [Z:\home\eric\work\wine\dlls\msvcrt\crt_winmain.c:53] in notepad (0x0000000000000000) 3 0x0000000000406155 mainCRTStartup+0x64() [Z:\home\eric\work\wine\dlls\msvcrt\crt_main.c:58] in notepad (0x0000000000000000) 4 0x000000007b62c679 BaseThreadInitThunk+0x8(unknown=<is not available>, entry=<is not available>, arg=<is not available>) [Z:\home\eric\work\wine\dlls\kernel32\thread.c:61] in kernel32 (0x0000000000000000) 5 0x000000007bc56c73 RtlUserThreadStart+0x82(entry=0x4060f0, arg=0x3f0000) [Z:\home\eric\work\wine\dlls\ntdll\thread.c:241] in ntdll (0x0000000000000000) Wine-dbg>
and a much nicer backtrace regarding parameters.
When using winedbg's gdb proxy mode: - same lack of values on parameters/local variables in dwarf-2 - provides (in this example) the same information as winedbg