Debug symbols in GDB backtraces

Questions about Wine on Linux
Locked
twighk
Level 1
Level 1
Posts: 6
Joined: Fri May 22, 2020 9:45 am

Debug symbols in GDB backtraces

Post by twighk »

Hi,

How do i get debug symbols in gdb backtraces in newer versions of wine (works in 3.6, but not 4.0.4, 5.5, or from gitrepo)?

Example code: simple.cpp

Code: Select all

#include <windows.h>
#include <stdio.h>

void fTwo() { DebugBreak(); }
void fOne() { fTwo(); }

BOOL WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd)
{
    fOne();
    return 0;
}
Compiled with :

Code: Select all

./../wine/tools/winegcc/wineg++ -MD -ggdb3 -Og -fdiagnostics-color -mwindows -mno-cygwin -isystem ./../wine/include -isystem ./../wine/include/msvcrt  -c simple.cpp -o build/simple.cpp.o
./../wine/tools/winegcc/wineg++ -L./../wine/dlls  -ggdb3 -Og -fdiagnostics-color -mwindows -mno-cygwin -isystem ./../wine/include -isystem ./../wine/include/msvcrt  ./build/simple.cpp.o    -o ./bin/simple --winebuild ./../wine/tools/winebuild/winebuild
where ./../wine is the wine git repository

Run with :

Code: Select all

WINEDEBUG=warn+all gdb --args ./../wine/loader/wine64 ./bin/simple.exe.so
But produces the backtrace:

Code: Select all

Program received signal SIGTRAP, Trace/breakpoint trap.
0x000000007bcb3d59 in ?? ()
(gdb) bt
#0  0x000000007bcb3d59 in ?? ()
#1  0x00007ffff07ea167 in ?? ()
#2  0x0000000000000000 in ?? ()
twighk
Level 1
Level 1
Posts: 6
Joined: Fri May 22, 2020 9:45 am

Re: Debug symbols in GDB backtraces

Post by twighk »

changing the debug flags when compiling from:

Code: Select all

-ggdb3
to:

Code: Select all

-g -gdwarf-2
as suggested:
https://wiki.winehq.org/Winedbg
doesn't seem to make a difference. The backtrace is still missing information.
twighk
Level 1
Level 1
Posts: 6
Joined: Fri May 22, 2020 9:45 am

Re: Debug symbols in GDB backtraces

Post by twighk »

Trying to run the program using the winedbg:

Code: Select all

../wine/loader/wine64 ../wine/programs/winedbg/winedbg.exe.so bin/simple.exe.so
gives:

Code: Select all

couldn't load main module (0)
0x000000007bcb3d59: ret
Running with the --gdb flag:

Code: Select all

../wine/loader/wine64 ../wine/programs/winedbg/winedbg.exe.so --gdb bin/simple.exe.so
gives:

Code: Select all

0x000000007bcb3d59 in ?? ()
Wine-gdb> bt
#0  0x000000007bcb3d59 in ?? ()
#1  0x000000007b44a93c in ?? ()
#2  0x0000000000012c28 in ?? ()
#3  0xffffffffffffffff in ?? ()
#4  0x0000000000000000 in ?? ()
Wine-gdb> c
Continuing.

Program received signal SIGTRAP, Trace/breakpoint trap.
0x000000007bcb3d59 in ?? ()
Wine-gdb> bt
#0  0x000000007bcb3d59 in ?? ()
#1  0x00007fa75594c167 in ?? ()
#2  0x0000000000000000 in ?? ()
Wine-gdb>
Where #0 in the second backtrace is the same address as when using pure gdb.
twighk
Level 1
Level 1
Posts: 6
Joined: Fri May 22, 2020 9:45 am

Re: Debug symbols in GDB backtraces

Post by twighk »

It seems not to be related to the building of the executable, but the wine64 executable used.

Using ubuntu's wine-development (3.6-1) package gives backtraces, but building wine 3.6 from source does not.

Code: Select all

$ ./wine/loader/wine64 --version
wine-3.6
$ file wine/loader/wine64
wine/loader/wine64: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 3.2.0, BuildID[sha1]=50cfe4d47300d28213154a9eb63fc6226c3d58a8, with debug_info, not stripped

$ /usr/bin/../lib/wine-development/wine64 --version
wine-3.6 (Ubuntu 3.6-1)
$ file /usr/bin/../lib/wine-development/wine64
/usr/bin/../lib/wine-development/wine64: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 3.2.0, BuildID[sha1]=8577817b48d01e24e2adc0812ef07b908cc70634, stripped
twighk
Level 1
Level 1
Posts: 6
Joined: Fri May 22, 2020 9:45 am

Re: Debug symbols in GDB backtraces

Post by twighk »

Turns out you can get backtraces in the compiled 3.6 using the binary:

Code: Select all

./../wine/loader/wine64-installed
instead of:

Code: Select all

./../wine/loader/wine64
i.e.:

Code: Select all

LD_LIBRARY_PATH=./../wine/libs/wine/:$LD_LIBRARY_PATH WINEDEBUG=warn+all gdb --args ./../wine/loader/wine64-installed ./bin/simple.exe.so
twighk
Level 1
Level 1
Posts: 6
Joined: Fri May 22, 2020 9:45 am

Re: Debug symbols in GDB backtraces

Post by twighk »

Compiling from source tagged with Wine-version:
  • Works on: wine-5.8, wine-5.5, wine-5.1, wine-4.18
  • Doesn't work on: wine-5.9
, seems to just be broken in wine-5.9, as wine-5.8 is good.
Locked