From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 26027 invoked by alias); 11 Mar 2011 06:19:14 -0000 Received: (qmail 26000 invoked by uid 22791); 11 Mar 2011 06:19:13 -0000 X-SWARE-Spam-Status: No, hits=-51.3 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from localhost (HELO sourceware.org) (127.0.0.1) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 11 Mar 2011 06:19:09 +0000 From: "ppluzhnikov at google dot com" To: gdb-prs@sourceware.org Subject: [Bug breakpoints/12568] New: GDB inserts breakpoint on constructor at location 0 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gdb X-Bugzilla-Component: breakpoints X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: ppluzhnikov at google dot com X-Bugzilla-Status: NEW X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: unassigned at sourceware dot org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Changed-Fields: Message-ID: X-Bugzilla-URL: http://sourceware.org/bugzilla/ Auto-Submitted: auto-generated Content-Type: text/plain; charset="UTF-8" MIME-Version: 1.0 Date: Fri, 11 Mar 2011 06:19:00 -0000 Mailing-List: contact gdb-prs-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-prs-owner@sourceware.org X-SW-Source: 2011-q1/txt/msg00187.txt.bz2 http://sourceware.org/bugzilla/show_bug.cgi?id=12568 Summary: GDB inserts breakpoint on constructor at location 0 Product: gdb Version: unknown Status: NEW Severity: normal Priority: P2 Component: breakpoints AssignedTo: unassigned@sourceware.org ReportedBy: ppluzhnikov@google.com When using virtual inheritance, GCC emits in-charge (C1) and not-in-charge (C2) constructors, at the same source file:line One of these ctors could be garbage-collected by the linker, causing its line table to start at location 0. GDB does not ignore that line table, sets a breakpoint on 0, then gets: Cannot insert breakpoint 1. Error accessing memory address 0x0: Input/output error. The problem reproduces with GDB 7.2.50.20110311-cvs and GCC g++ (Ubuntu 4.4.3-4ubuntu5) 4.4.3 The problem does *not* reproduce with g++ (GCC) 4.6.0 20110219 (experimental), because in that version C1 ctor calls C2, preventing C2 from being GCd by the linker. Repro steps: /// --- foo.c struct Foo { Foo(int z) { x = z; } int x; }; struct Bar: virtual public Foo { Bar(int x) : Foo(x) { } }; int main(int argc, char *argv[]) { Foo f(42); return f.x + argc; } // Calls C2 ctor, but is GCd by linker void deadfn() { Bar b(12); } /// --- foo.c g++ -g foo.c -fno-inline -ffunction-sections -Wl,--gc-sections nm a.out | grep Foo 0000000000400622 W _ZN3FooC1Ei ### Note: only C1 constructor present! gdb ./a.out GNU gdb (GDB) 7.2.50.20110311-cvs Copyright (C) 2011 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Type "show copying" and "show warranty" for details. This GDB was configured as "x86_64-unknown-linux-gnu". For bug reporting instructions, please see: ... Reading symbols from /tmp/a.out...done. (gdb) b Foo::Foo Breakpoint 1 at 0x0: file foo.c, line 3. (3 locations) (gdb) info b Num Type Disp Enb Address What 1 breakpoint keep y 1.1 y 0x0000000000000000 foo.c:3 1.2 y 0x000000000000000b foo.c:3 1.3 y 0x000000000040062d in Foo::Foo(int) at foo.c:3 (gdb) r Warning: Cannot insert breakpoint 1. Error accessing memory address 0x0: Input/output error. Cannot insert breakpoint 1. Error accessing memory address 0xb: Input/output error. (gdb) q -- Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are on the CC list for the bug.