From patchwork Fri Oct 30 05:09:54 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kevin Buettner X-Patchwork-Id: 9484 Received: (qmail 39646 invoked by alias); 30 Oct 2015 05:10:00 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 39552 invoked by uid 89); 30 Oct 2015 05:09:59 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-4.1 required=5.0 tests=AWL, BAYES_00, RP_MATCHES_RCVD, SPF_HELO_PASS autolearn=ham version=3.3.2 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Fri, 30 Oct 2015 05:09:58 +0000 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (Postfix) with ESMTPS id CCA838E37C for ; Fri, 30 Oct 2015 05:09:56 +0000 (UTC) Received: from pinnacle.lan (ovpn-113-191.phx2.redhat.com [10.3.113.191]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t9U59uKc022404 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA256 bits=256 verify=NO) for ; Fri, 30 Oct 2015 01:09:56 -0400 Date: Thu, 29 Oct 2015 22:09:54 -0700 From: Kevin Buettner To: gdb-patches@sourceware.org Subject: [PATCH] gdb.dwarf2: Don't hardcode certain constants in Dwarf::assemble constructs Message-ID: <20151029220954.3964b354@pinnacle.lan> MIME-Version: 1.0 X-IsSubscribed: yes Two tests in gdb.dwarf2, data-loc.exp and dynarr-ptr.exp assume that sizeof(int) is 4. This patch looks up the integer size and uses this constant for DW_AT_byte_size, DW_AT_lower_bound, and DW_AT_upper_bound. I discovered this problem while looking at test results for this msp430 multilib: msp430-sim/-msim/-mcpu=msp430x/-mlarge/-mdata-region=either/-mcode-region=either It fixes the following set of failures: FAIL: gdb.dwarf2/dynarr-ptr.exp: print foo.three_ptr.all'first FAIL: gdb.dwarf2/dynarr-ptr.exp: print foo.three_ptr'first FAIL: gdb.dwarf2/dynarr-ptr.exp: print foo.three_ptr_tdef.all'first FAIL: gdb.dwarf2/dynarr-ptr.exp: print foo.three_ptr_tdef'first FAIL: gdb.dwarf2/dynarr-ptr.exp: print foo.five_ptr.all'first FAIL: gdb.dwarf2/dynarr-ptr.exp: print foo.five_ptr'first FAIL: gdb.dwarf2/dynarr-ptr.exp: print foo.five_ptr_tdef.all'first FAIL: gdb.dwarf2/dynarr-ptr.exp: print foo.five_ptr_tdef'first FAIL: gdb.dwarf2/data-loc.exp: print foo.three FAIL: gdb.dwarf2/data-loc.exp: print foo.three(1) FAIL: gdb.dwarf2/data-loc.exp: print foo.three(2) FAIL: gdb.dwarf2/data-loc.exp: print foo.three(3) FAIL: gdb.dwarf2/data-loc.exp: print foo.three_tdef FAIL: gdb.dwarf2/data-loc.exp: print foo.three_tdef(1) FAIL: gdb.dwarf2/data-loc.exp: print foo.three_tdef(2) FAIL: gdb.dwarf2/data-loc.exp: print foo.three_tdef(3) FAIL: gdb.dwarf2/data-loc.exp: print foo.five FAIL: gdb.dwarf2/data-loc.exp: print foo.five(2) FAIL: gdb.dwarf2/data-loc.exp: print foo.five(3) FAIL: gdb.dwarf2/data-loc.exp: print foo.five(4) FAIL: gdb.dwarf2/data-loc.exp: print foo.five(5) FAIL: gdb.dwarf2/data-loc.exp: print foo.five(6) FAIL: gdb.dwarf2/data-loc.exp: print foo.five_tdef FAIL: gdb.dwarf2/data-loc.exp: print foo.five_tdef(2) FAIL: gdb.dwarf2/data-loc.exp: print foo.five_tdef(3) FAIL: gdb.dwarf2/data-loc.exp: print foo.five_tdef(4) FAIL: gdb.dwarf2/data-loc.exp: print foo.five_tdef(5) FAIL: gdb.dwarf2/data-loc.exp: print foo.five_tdef(6) FAIL: gdb.dwarf2/data-loc.exp: print foo__three FAIL: gdb.dwarf2/data-loc.exp: print foo__three_tdef FAIL: gdb.dwarf2/data-loc.exp: print foo__five FAIL: gdb.dwarf2/data-loc.exp: print foo__five_tdef As I recall, there are still (other) problems with msp430 multilibs which don't use -mlarge. gdb/testsuite/ChangeLog: * gdb.dwarf2/data-loc.exp (Dwarf::assemble): Don't hardcode value associated with DW_AT_byte_size. * gdb.dwarf2/dynarr-ptr.exp (Dwarf::assemble): Don't hardcode constants for DW_AT_lower_bound, and DW_AT_upper_bound. --- gdb/testsuite/gdb.dwarf2/data-loc.exp | 3 ++- gdb/testsuite/gdb.dwarf2/dynarr-ptr.exp | 7 ++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/gdb/testsuite/gdb.dwarf2/data-loc.exp b/gdb/testsuite/gdb.dwarf2/data-loc.exp index 4802a0a..305d004 100644 --- a/gdb/testsuite/gdb.dwarf2/data-loc.exp +++ b/gdb/testsuite/gdb.dwarf2/data-loc.exp @@ -45,9 +45,10 @@ Dwarf::assemble $asm_file { {DW_AT_comp_dir /tmp} } { declare_labels integer_label array_label array_ptr_label + set int_size [get_sizeof "int" 4] integer_label: DW_TAG_base_type { - {DW_AT_byte_size 4 DW_FORM_sdata} + {DW_AT_byte_size $int_size DW_FORM_sdata} {DW_AT_encoding @DW_ATE_signed} {DW_AT_name integer} } diff --git a/gdb/testsuite/gdb.dwarf2/dynarr-ptr.exp b/gdb/testsuite/gdb.dwarf2/dynarr-ptr.exp index d0a74be..0ad09f2 100644 --- a/gdb/testsuite/gdb.dwarf2/dynarr-ptr.exp +++ b/gdb/testsuite/gdb.dwarf2/dynarr-ptr.exp @@ -47,6 +47,7 @@ Dwarf::assemble $asm_file { declare_labels integer_label array_label array_ptr_label \ array_typedef_label set ptr_size [get_sizeof "void *" 96] + set int_size [get_sizeof "int" 4] integer_label: DW_TAG_base_type { {DW_AT_byte_size 4 DW_FORM_sdata} @@ -63,15 +64,15 @@ Dwarf::assemble $asm_file { {DW_AT_type :$integer_label} {DW_AT_lower_bound { DW_OP_push_object_address - DW_OP_lit8 + DW_OP_const1u [expr {2 * $int_size}] DW_OP_minus - DW_OP_deref_size 4 + DW_OP_deref_size $int_size } SPECIAL_expr} {DW_AT_upper_bound { DW_OP_push_object_address DW_OP_lit4 DW_OP_minus - DW_OP_deref_size 4 + DW_OP_deref_size $int_size } SPECIAL_expr} } }