Feedback requested / dwarf4

Eric Pouech eric.pouech at gmail.com
Thu Nov 4 03:08:06 CDT 2021


Background
----------
Wine has been using dwarf2 debug format for years, and hasn't updated to
dwarf4 yet (gcc and most of distros switched more than 10 years ago).
As gcc & distros have switched to dwarf5 for 6 months to a year, it's time
to catch up.

Status
------
As of today, support for reading and managing dwarf4 debug info is included
in dbghelp (as well as dwarf2 and dwarf3) and is available through winedbg.
However, by default all Wine components are still compiled with dwarf2.
Since most system shared libraries are now shipped with dwarf5, it means
that no modules with dwarf4 debug information are crunched.

Need for help
-------------
Before enabling dwarf4 as wine's default debug format, feedback is
requested on all those changes.

How can you help:
1) Setup the dwarf4 debug format for wine compilation using:
> ./configure CFLAGS="-gdwarf-4 -O2" CROSSCFLAGS="-gdwarf-4 -O2"
> make -B

The two options to configure are needed to configure both the compiler for
ELF parts, and the cross compiler for PE parts.
And you need to recompile everything to generate correct debug information.

2) Report any strange / unexpected behavior
Given the magnitude of change, I'd be surprised if everything would be
perfect. So, your contribution here for testing and
shaking would be much appreciated.

Improvements (dwarf4 over dwarf2)
------------

Here's a typical debugging session (wine compiles 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.

Note that the same improvements are also available with winedbg in gdb
proxy mode:
- same lack of values on parameters/local variables in dwarf-2
- provides (in this example) the same information as winedbg/dbghelp does

There are quite a couple of other things available with dwarf4 (split .dwo
files, inlined functions...).

----------

Thanks in advance


-- 
Eric Pouech
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.winehq.org/pipermail/wine-devel/attachments/20211104/487c1b50/attachment-0001.htm>


More information about the wine-devel mailing list