From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 5216 invoked by alias); 24 Jul 2011 21:12:06 -0000 Received: (qmail 5207 invoked by uid 22791); 24 Jul 2011 21:12:05 -0000 X-SWARE-Spam-Status: No, hits=-7.0 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD,SPF_HELO_PASS X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sun, 24 Jul 2011 21:11:46 +0000 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p6OLBkoa016109 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Sun, 24 Jul 2011 17:11:46 -0400 Received: from host1.jankratochvil.net (ovpn-116-20.ams2.redhat.com [10.36.116.20]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id p6OLBiTC022103 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Sun, 24 Jul 2011 17:11:45 -0400 Received: from host1.jankratochvil.net (localhost [127.0.0.1]) by host1.jankratochvil.net (8.14.4/8.14.4) with ESMTP id p6OLBhw4002933 for ; Sun, 24 Jul 2011 23:11:43 +0200 Received: (from jkratoch@localhost) by host1.jankratochvil.net (8.14.4/8.14.4/Submit) id p6OLBgf4002931 for gdb-patches@sourceware.org; Sun, 24 Jul 2011 23:11:42 +0200 Date: Mon, 25 Jul 2011 07:19:00 -0000 From: Jan Kratochvil To: gdb-patches@sourceware.org Subject: [patch] Fix implicit pointer offsets Message-ID: <20110724211142.GA2913@host1.jankratochvil.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2011-07/txt/msg00680.txt.bz2 Hi Tom, piece->v.ptr.offset has been carefully prepared and then gracefully ignored so far. p p[0].y $5 = 92 (gdb) PASS: gdb.dwarf2/implptr.exp: sanity check element 0 p p[1].y $6 = 46 (gdb) PASS: gdb.dwarf2/implptr.exp: sanity check element 1 [...] p a->y $7 = 92 (gdb) PASS: gdb.dwarf2/implptr.exp: check element 0 for the offset p b->y -$8 = 92 -(gdb) FAIL: gdb.dwarf2/implptr.exp: check element 1 for the offset +$8 = 46 +(gdb) PASS: gdb.dwarf2/implptr.exp: check element 1 for the offset No regressions on {x86_64,x86_64-m32,i686}-fedora16pre-linux-gnu. I will check it in in some time. Thanks, Jan gdb/ 2011-07-24 Jan Kratochvil Fix implicit pointer offsets. * dwarf2loc.c (indirect_pieced_value): Comment byte_offset. Use also ptr.OFFSET. gdb/testsuite/ 2011-07-24 Jan Kratochvil Fix implicit pointer offsets. * gdb.dwarf2/implptr.c (add): New marker baz breakpoint. * gdb.dwarf2/implptr.exp ( set baz breakpoint for implptr) (continue to breakpoint: continue to baz breakpoint for implptr) (sanity check element 0, sanity check element 1) (enter the inlined function, check element 0 for the offset) (check element 1 for the offset) (continue to breakpoint: ignore the second baz breakpoint): New tests. (set foo breakpoint for implptr): Update the breakpoint number. --- a/gdb/dwarf2loc.c +++ b/gdb/dwarf2loc.c @@ -1012,6 +1012,8 @@ indirect_pieced_value (struct value *value) } frame = get_selected_frame (_("No frame selected.")); + + /* This is an offset requested by GDB, such as value subcripts. */ byte_offset = value_as_address (value); gdb_assert (piece); @@ -1023,7 +1025,7 @@ indirect_pieced_value (struct value *value) result = dwarf2_evaluate_loc_desc_full (TYPE_TARGET_TYPE (type), frame, baton.data, baton.size, baton.per_cu, - byte_offset); + piece->v.ptr.offset + byte_offset); do_cleanups (back_to); --- a/gdb/testsuite/gdb.dwarf2/implptr.c +++ b/gdb/testsuite/gdb.dwarf2/implptr.c @@ -31,7 +31,7 @@ int u[6]; static inline void add (struct S *a, struct S *b, int c) { - *a->x += *b->x; + *a->x += *b->x; /* baz breakpoint */ a->y += b->y; u[c + 0]++; a = (struct S *) 0; --- a/gdb/testsuite/gdb.dwarf2/implptr.exp +++ b/gdb/testsuite/gdb.dwarf2/implptr.exp @@ -60,11 +60,26 @@ proc implptr_test_bar {} { gdb_test "print ***l" " = 5" "print ***l in implptr:bar" } +# Test implicit pointer offset. +proc implptr_test_baz {} { + global csrcfile + set line [gdb_get_line_number "baz breakpoint" $csrcfile] + gdb_test "break implptr.c:$line" "Breakpoint 3.*" \ + "set baz breakpoint for implptr" + gdb_continue_to_breakpoint "continue to baz breakpoint for implptr" + gdb_test {p p[0].y} " = 92" "sanity check element 0" + gdb_test {p p[1].y} " = 46" "sanity check element 1" + gdb_test "step" "\r\nadd \\(.*" "enter the inlined function" + gdb_test "p a->y" " = 92" "check element 0 for the offset" + gdb_test "p b->y" " = 46" "check element 1 for the offset" + gdb_continue_to_breakpoint "ignore the second baz breakpoint" +} + # Test some values in foo. proc implptr_test_foo {} { global csrcfile set line [gdb_get_line_number "foo breakpoint" $csrcfile] - gdb_test "break implptr.c:$line" "Breakpoint 3.*" \ + gdb_test "break implptr.c:$line" "Breakpoint 4.*" \ "set foo breakpoint for implptr" gdb_continue_to_breakpoint "continue to foo breakpoint for implptr" gdb_test "print p\[0].x" " = \\(int \\*\\) " \ @@ -81,4 +96,5 @@ proc implptr_test_foo {} { } implptr_test_bar +implptr_test_baz implptr_test_foo