[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#862858: gcc-6.3.0 produces binary that gdb cannot automatically reload when it changes



Package: gcc-6
Version: 6.3.0-18
Severity: important

Hi,

I am directing this bug as relevant to gcc package as this is my best
guess so far of a possible culprit. gdb is the package which has its
functionality affected.

Consider the following trivial code:
    #include <stdio.h>
    void a()
    {
        printf("Hello, world\n");
    }
    int main()
    {
        a();
        return 0;
    }

When debugging such a program with gdb, gdb notices if the binary changes
between two runs (within the same session). However, binaries created
with gcc as in packages 6.3.0-18 (or 6.3.0-16 in testing) are not
properly reloaded:

    localhost /tmp $ gcc -W -Wall -g a.c
    localhost /tmp $ gdb -q a.out
    Reading symbols from a.out...done.
    (gdb) b a
    Breakpoint 1 at 0x6b4: file a.c, line 5.
    (gdb) r
    Starting program: /tmp/a.out

    Breakpoint 1, a () at a.c:5
    5           printf("Hello, world\n");
    (gdb) shell gcc -W -Wall -g a.c
    (gdb) r
    The program being debugged has been started already.
    Start it from the beginning? (y or n) y
    `/tmp/a.out' has changed; re-reading symbols.
    Error in re-setting breakpoint 1: Cannot access memory at address 0x55555555
46b0
    Starting program: /tmp/a.out
    Hello, world
    [Inferior 1 (process 22102) exited normally]
    (gdb) quit

Note that instructing gdb to explicitly reload the binary 
    localhost ~ $ dpkg -l gcc-6 gdb binutils | grep ^i
    ii  binutils       2.28-5       amd64        GNU assembler, linker and binary utilities
    ii  gcc-6          6.3.0-18     amd64        GNU C compiler
    ii  gdb            7.12-6       amd64        GNU Debugger

I've tried other gcc+gdb combinations.

Binary reload fails similarly in the following case:
    ubuntu 17.04 gdb 7.12.50.20170314-0ubuntu1 + gcc 6.3.0-2ubuntu1

Binary reloads fine in the following cases:
    debian testing, gdb 7.12-6 + home-compiled upstream gcc-7.1.0
    debian testing, gdb 7.12-6 + home-compiled upstream gcc-6.3.0
    debian testing, gdb 7.12-6 + gcc 5.4.1-4
    archlinux gdb 7.12.1 + gcc 6.3.1 20170306

On the gcc-6.3.0 I had, objdump -x a.out   tells, among other things:
EXEC_P, HAS_SYMS, D_PAGED
start address 0x00000000004003f0

while on the gcc-6.3.0-16 debian package, I have:
HAS_SYMS, DYNAMIC, D_PAGED
start address 0x0000000000000580


I would be happy to provide more information if needed.

Cheers,

E.




-- System Information:
Debian Release: 9.0
  APT prefers testing
  APT policy: (900, 'testing')
Architecture: amd64
 (x86_64)
Foreign Architectures: i386

Kernel: Linux 4.9.0-1-amd64 (SMP w/4 CPU cores)
Locale: LANG=C, LC_CTYPE=en_US.utf8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Init: systemd (via /run/systemd/system)

Versions of packages gcc-6 depends on:
ii  binutils      2.28-5
ii  cpp-6         6.3.0-18
ii  gcc-6-base    6.3.0-18
ii  libc6         2.24-10
ii  libcc1-0      6.3.0-18
ii  libgcc-6-dev  6.3.0-18
ii  libgcc1       1:6.3.0-18
ii  libgmp10      2:6.1.2+dfsg-1
ii  libisl15      0.18-1
ii  libmpc3       1.0.3-1+b2
ii  libmpfr4      3.1.5-1
ii  libstdc++6    6.3.0-18
ii  zlib1g        1:1.2.8.dfsg-5

Versions of packages gcc-6 recommends:
ii  libc6-dev  2.24-10

Versions of packages gcc-6 suggests:
ii  gcc-6-doc         6.3.0-1
pn  gcc-6-locales     <none>
ii  gcc-6-multilib    6.3.0-18
pn  libasan3-dbg      <none>
pn  libatomic1-dbg    <none>
pn  libcilkrts5-dbg   <none>
pn  libgcc1-dbg       <none>
pn  libgomp1-dbg      <none>
pn  libitm1-dbg       <none>
pn  liblsan0-dbg      <none>
pn  libmpx2-dbg       <none>
pn  libquadmath0-dbg  <none>
pn  libtsan0-dbg      <none>
pn  libubsan0-dbg     <none>

-- no debconf information


Reply to: