From Fedora Project Wiki

MinGW MiniDebugInfo

Summary

Analogously to the MiniDebugInfo change for native packages, install minimal debuginfos by default also for MinGW packages.

Owner

  • Name: Sandro Mani
  • Email: <manisandro@gmail.com>
  • Release notes owner:

Current status

  • Targeted release: Fedora 28
  • Last updated: 2017-09-05
  • Tracker bug: <will be assigned by the Wrangler>

Detailed Description

Currently the debuginfo data of MinGW binaries is completely stripped from the binary and placed in the respective .debuginfo file. This change proposes keeping the PE symbols in the binary, similarly to what was done for native binaries.

The change basically involves changing mingw-find-debuginfo.sh as follows:

diff --git a/mingw-filesystem/mingw-find-debuginfo.sh b/mingw-filesystem/mingw-find-debuginfo.sh
index de6dee1..261385f 100755
--- a/mingw-filesystem/mingw-find-debuginfo.sh
+++ b/mingw-filesystem/mingw-find-debuginfo.sh
@@ -25,7 +25,10 @@ do
        echo extracting debug info from $f
        mingw-objcopy --only-keep-debug $f $f.debug || :
        pushd `dirname $f`
-       mingw-objcopy --add-gnu-debuglink=`basename $f.debug` --strip-unneeded `basename $f` || :
+       keep_symbols=`mktemp`
+  mingw-nm $f.debug --format=sysv --defined-only | awk -F \| '{ if ($4 ~ "Function") print $1 }' | sort > "$keep_symbols"
+       mingw-objcopy --add-gnu-debuglink=`basename $f.debug` --strip-unneeded `basename $f` --keep-symbols="$keep_symbols" || :
+       rm -f "$keep_symbols"
        popd
 done

A test with some packages in this COPR repo shows that the price is a size increase of in average 17%:

Binary Stripped size Size with symbols Relative size change
libgio-2.0-0.dll 1412 1656 117.28%
libglib-2.0-0.dll 1092 1184 108.42%
libgmodule-2.0-0.dll 28 32 114.29%
libgobject-2.0-0.dll 312 352 112.82%
libgiomm-2.4-1.dll 1284 1732 134.89%
libglibmm-2.4-1.dll 432 588 136.11%
Qt5Concurrent.dll 36 44 122.22%
Qt5Core.dll 4884 5508 112.78%
Qt5DBus.dll 548 652 118.99%
Qt5Gui.dll 4408 5208 118.15%
Qt5Network.dll 1568 1892 120.66%
Qt5OpenGL.dll 328 404 123.17%
Qt5PrintSupport.dll 376 448 119.15%
Qt5Sql.dll 268 312 116.42%
Qt5Test.dll 252 284 112.70%
Qt5Widgets.dll 5716 6768 118.40%
Qt5Xml.dll 216 268 124.07%


Benefit to Fedora

Make it easier to debug Windows applications cross-compiled from Fedora, in particular:

  • A convenient way to manage crash reporting is to ship gdb with the application, and in case of a crash, attach it to the dying process, collect a stacktrace, and ask the user to send it to the developer. For the developer it helps plenty if the stacktrace already contained symbol names, instead of being number-only.
  • If you need to live-debug a deployed system, it is not always easy to obtain the correct debuginfo packages and install them along the binaries.


Scope

  • Proposal owners:
    • Change mingw-binutils toalso install a generic mingw-nm, which will be used by mingw-find-debuginfo.sh
    • Change mingw-find-debuginfo.sh as outlined above
    • Rebuild all mingw packages
  • Other developers: N/A (not a System Wide Change)
  • Release engineering: #7005 (a check of an impact with Release Engineering is needed)
  • Policies and guidelines: N/A (not a System Wide Change)
  • Trademark approval: N/A (not needed for this Change)

Upgrade/compatibility impact

N/A (not a System Wide Change)

How To Test

  • Wait for the packages rebuilt with the new mingw-find-debuginfo.sh to land, or use the test packages in this COPR repo.
  • Make a Windows application using the binaries with minidebug infos crash
  • The stacktrace should contain function names, i.e.
#0  0x000000000040157d in foo() ()
#1  0x00000000004015b5 in main () 

as opposed to being number only:

#0  0x000000000040157d in ?? ()
#1  0x00000000004015b5 in ?? ()
#2  0x00000000004013f7 in ?? ()
#3  0x000000000040152b in ?? ()
#4  0x0000000076af652d in KERNEL32!BaseThreadInitThunk ()
   from C:\Windows\system32\kernel32.dll
#5  0x0000000076d2c521 in ntdll!RtlUserThreadStart ()
   from C:\Windows\SYSTEM32\ntdll.dll
#6  0x0000000000000000 in ?? ()
Backtrace stopped: previous frame inner to this frame (corrupt stack?)


User Experience

N/A (not a System Wide Change)

Dependencies

N/A (not a System Wide Change)

Contingency Plan

  • Contingency mechanism: N/A (not a System Wide Change)
  • Contingency deadline: N/A (not a System Wide Change)
  • Blocks release? N/A (not a System Wide Change), Yes/No
  • Blocks product? none

Documentation

N/A (not a System Wide Change)

Release Notes

MinGW binaries contain symbol names by default for easier debugging.