Rewrite/fix cygwin1.dbg generation

Pedro Alves pedro_alves@portugalmail.pt
Sat Nov 3 17:32:00 GMT 2007


Hi guys,

As was being discussed at gdb-patches@ [1], the cygwin1.dbg
(the debug info of cygwin1.dll) file misses the section
info of the non-debug sections.  Gdb doesn't like that
so much, and issues a few annoying warnings.  Previous
versions of gdb had those warnings suppressed at all
times, but since current gdb had its dll support
rewritten, those warnings resurfaced again.

[1] http://sourceware.org/ml/gdb-patches/2007-10/msg00325.html

This patch simplifies/standardises the cygwin1.dbg generation
by using the --strip-debug/--only-keep-debug facilities of
gnu strip, which already know how to keep the section info,
and remove the contents of non-debug sections.

Old/current version:
    >objdump.exe -h oldver/cygwin1.dbg

oldver/cygwin1.dbg:     file format pei-i386

Sections:
Idx Name          Size      VMA       LMA       File off  Algn
      0 .stab         00212cd0  61280000  61280000  000001c8  2**2
                      CONTENTS, READONLY, DEBUGGING, EXCLUDE
      1 .stabstr      006b00a4  61493000  61493000  00212fc8  2**0
                      CONTENTS, READONLY, DEBUGGING, EXCLUDE
New version:

    >objdump.exe -h newver/cygwin1.dbg

newver/cygwin1.dbg:     file format pei-i386

Sections:
Idx Name          Size      VMA       LMA       File off  Algn
      0 .text         001350c4  61001000  61001000  00000000  2**4
                      ALLOC, LOAD, READONLY, CODE, DATA
      1 .autoload_text 000013d8  61137000  61137000  00000000  2**2
                      ALLOC, LOAD, CODE
      2 .data         0000b51c  61139000  61139000  00000000  2**4
                      ALLOC, LOAD, DATA
      3 .rdata        0004fb80  61145000  61145000  00000000  2**4
                      ALLOC, LOAD, READONLY, DATA
      4 .bss          00009530  61195000  61195000  00000000  2**4
                      ALLOC
      5 .edata        00008487  6119f000  6119f000  00000000  2**2
                      ALLOC, LOAD, READONLY, DATA
      6 .rsrc         00000420  611a8000  611a8000  00000000  2**2
                      ALLOC, LOAD, DATA
      7 .reloc        00013424  611a9000  611a9000  00000000  2**2
                      ALLOC, LOAD, READONLY, DATA
      8 .cygwin_dll_common 00017ae4  611bd000  611bd000  00000000  2**2
                      ALLOC, LOAD, DATA, SHARED
      9 .idata        0000b000  611d5000  611d5000  00000000  2**2
                      ALLOC, LOAD, DATA
     10 .cygheap      000a0000  611e0000  611e0000  00000000  2**2
                      ALLOC
     11 .stab         00212cd0  61280000  61280000  00000380  2**2
                      CONTENTS, READONLY, DEBUGGING, EXCLUDE
     12 .stabstr      006b00a4  61493000  61493000  00213180  2**0
                      CONTENTS, READONLY, DEBUGGING, EXCLUDE

---------------------------------------------------------

Since the .gnu_debuglink_overlay matching is now done,
this produces one difference in cygwin1.dll.  The
.gnu_debuglink section is now the last section,
after .cygheap.  This is not a problem, since
.gnu_debuglink is not mapped into memory by the OS loader.

The patch also removed __cygwin_debug_size, which
seems was a leftover from earlier experiences (?).

For reference, the old and new section info of cygwin1.dll.

    >objdump.exe -h oldver/new-cygwin1.dll

oldver/new-cygwin1.dll:     file format pei-i386

Sections:
Idx Name          Size      VMA       LMA       File off  Algn
      0 .text         001350c4  61001000  61001000  00000400  2**4
                      CONTENTS, ALLOC, LOAD, READONLY, CODE, DATA
      1 .autoload_text 000013d8  61137000  61137000  00135600  2**2
                      CONTENTS, ALLOC, LOAD, CODE
      2 .data         0000b51c  61139000  61139000  00136a00  2**4
                      CONTENTS, ALLOC, LOAD, DATA
      3 .rdata        0004fb80  61145000  61145000  00142000  2**4
                      CONTENTS, ALLOC, LOAD, READONLY, DATA
      4 .bss          00009530  61195000  61195000  00000000  2**4
                      ALLOC
      5 .edata        00008487  6119f000  6119f000  00191c00  2**2
                      CONTENTS, ALLOC, LOAD, READONLY, DATA
      6 .rsrc         00000420  611a8000  611a8000  0019a200  2**2
                      CONTENTS, ALLOC, LOAD, DATA
      7 .reloc        00013424  611a9000  611a9000  0019a800  2**2
                      CONTENTS, ALLOC, LOAD, READONLY, DATA
      8 .cygwin_dll_common 00017ae4  611bd000  611bd000  001ade00  2**2
                      CONTENTS, ALLOC, LOAD, DATA, SHARED
      9 .gnu_debuglink 00000010  611d5000  611d5000  001c5a00  2**2
                      CONTENTS, READONLY, DEBUGGING, EXCLUDE
     10 .idata        0000a000  611d6000  611d6000  001c5c00  2**2
                      CONTENTS, ALLOC, LOAD, DATA
     11 .cygheap      000a0000  611e0000  611e0000  00000000  2**2
                      ALLOC

    >objdump.exe -h newver/new-cygwin1.dll

newver/new-cygwin1.dll:     file format pei-i386

Sections:
Idx Name          Size      VMA       LMA       File off  Algn
      0 .text         001350c4  61001000  61001000  00000400  2**4
                      CONTENTS, ALLOC, LOAD, READONLY, CODE, DATA
      1 .autoload_text 000013d8  61137000  61137000  00135600  2**2
                      CONTENTS, ALLOC, LOAD, CODE
      2 .data         0000b51c  61139000  61139000  00136a00  2**4
                      CONTENTS, ALLOC, LOAD, DATA
      3 .rdata        0004fb80  61145000  61145000  00142000  2**4
                      CONTENTS, ALLOC, LOAD, READONLY, DATA
      4 .bss          00009530  61195000  61195000  00000000  2**4
                      ALLOC
      5 .edata        00008487  6119f000  6119f000  00191c00  2**2
                      CONTENTS, ALLOC, LOAD, READONLY, DATA
      6 .rsrc         00000420  611a8000  611a8000  0019a200  2**2
                      CONTENTS, ALLOC, LOAD, DATA
      7 .reloc        00013424  611a9000  611a9000  0019a800  2**2
                      CONTENTS, ALLOC, LOAD, READONLY, DATA
      8 .cygwin_dll_common 00017ae4  611bd000  611bd000  001ade00  2**2
                      CONTENTS, ALLOC, LOAD, DATA, SHARED
      9 .idata        0000b000  611d5000  611d5000  001c5a00  2**2
                      CONTENTS, ALLOC, LOAD, DATA
     10 .cygheap      000a0000  611e0000  611e0000  00000000  2**2
                      ALLOC
     11 .gnu_debuglink 00000010  61280000  61280000  001d0a00  2**2
                      CONTENTS, READONLY, DEBUGGING

The winsup testsuite shows no changes.
I've bootstrapped winsup with gcc 3.4.4 and this
new cygwin1.dll.  I can step into cygwin1.dll code just
fine with both gdb head, and with the gdb from the distro.

This change should also make it possible to debug
cygwin1.dll correctly if it wasn't loaded at its
prefered load base - although I haven't tested that.

The dllfixdbg hunk looks hard to read.  Here's what is looks
like after patching:

#!/bin/sh

# Copyright 2007 Red Hat, Inc.
#
# This file is part of Cygwin.
#
# This software is a copyrighted work licensed under the terms of the
# Cygwin license.  Please consult the file "CYGWIN_LICENSE" for
# details.
#

set -x

STRIP=$1
OBJCOPY=$2
DLL=$3
DBG=$4

${STRIP} --strip-debug ${DLL} -o stripped-${DLL}
${STRIP} --only-keep-debug ${DLL} -o ${DBG}
${OBJCOPY} --add-gnu-debuglink=${DBG} stripped-${DLL} ${DLL}
rm -f stripped-${DLL}

Is the patch OK?

Cheers,
Pedro Alves



-------------- next part --------------
A non-text attachment was scrubbed...
Name: sepdebug.diff
Type: text/x-diff
Size: 5288 bytes
Desc: not available
URL: <http://cygwin.com/pipermail/cygwin-patches/attachments/20071103/8458adde/attachment.bin>


More information about the Cygwin-patches mailing list