From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 5051 invoked by alias); 15 Sep 2014 12:29:25 -0000 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 Received: (qmail 5040 invoked by uid 89); 15 Sep 2014 12:29:24 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-0.3 required=5.0 tests=AWL,BAYES_50 autolearn=ham version=3.3.2 X-HELO: relay1.mentorg.com Received: from relay1.mentorg.com (HELO relay1.mentorg.com) (192.94.38.131) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 15 Sep 2014 12:29:22 +0000 Received: from svr-orw-fem-02x.mgc.mentorg.com ([147.34.96.206] helo=SVR-ORW-FEM-02.mgc.mentorg.com) by relay1.mentorg.com with esmtp id 1XTVPD-0000Zm-GF from Yao_Qi@mentor.com for gdb-patches@sourceware.org; Mon, 15 Sep 2014 05:29:19 -0700 Received: from GreenOnly (147.34.91.1) by svr-orw-fem-02.mgc.mentorg.com (147.34.96.168) with Microsoft SMTP Server id 14.3.181.6; Mon, 15 Sep 2014 05:29:18 -0700 From: Yao Qi To: Subject: Re: [PATCH] Fix gdb.dwarf2/dwz.exp for thumb mode References: <1409706936-11220-1-git-send-email-yao@codesourcery.com> <87k356lfa8.fsf@codesourcery.com> Date: Mon, 15 Sep 2014 12:29:00 -0000 In-Reply-To: <87k356lfa8.fsf@codesourcery.com> (Yao Qi's message of "Sun, 14 Sep 2014 17:31:11 +0800") Message-ID: <87r3zd2hr3.fsf@codesourcery.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-IsSubscribed: yes X-SW-Source: 2014-09/txt/msg00497.txt.bz2 Yao Qi writes: > -if { $main_length =3D=3D "" } { > +set main_label_offset "" > +set test "p main_label" > +gdb_test_multiple $test $test { > + -re ".* =3D {.*} $hex .*\r\n$gdb_prompt $" { > + set main_label_offset $expect_out(1,string) > + } > +} Here is the V3 of this patch, to address Andreas's comments about getting the offset of main_label to main. --=20 Yao (=E9=BD=90=E5=B0=A7) From: Yao Qi Date: Sat, 13 Sep 2014 14:51:04 +0800 Subject: [PATCH] Fix gdb.dwarf2/dwz.exp for thumb mode We see the fail in gdb.dwarf2/dwz.exp in thumb mode, p the_int^M $2 =3D 99^M (gdb) FAIL: gdb.dwarf2/dwz.exp: p the_int In thumb mode, the lsb of references to 'main' in the assembly (produced by dwarf assember) is set, so the generated debug information is incorrect. in this patch, we add a label main_label inside function main. Linker doesn't set its lsb in thumb mode, and we can get function main's address by 'main_label - $main_label_offset'. This label isn't moved out of function main in both gcc and clang. gdb/testsuite: 2014-09-15 Yao Qi * gdb.dwarf2/main.c (main): New lable main_label. * gdb.dwarf2/dwz.exp: Get the offset of main_label to main. Return early if $main_label_offset is unknown. Get address of main by "main_label - $main_label_offset". diff --git a/gdb/testsuite/gdb.dwarf2/dwz.exp b/gdb/testsuite/gdb.dwarf2/dw= z.exp index 9175f9e..3cf4e4f 100644 --- a/gdb/testsuite/gdb.dwarf2/dwz.exp +++ b/gdb/testsuite/gdb.dwarf2/dwz.exp @@ -27,8 +27,9 @@ if {[gdb_compile ${srcdir}/${subdir}/${srcfile} ${binfil= e}1.o \ return -1 } =20 -# Start GDB and load object file, compute the function length which is -# needed in the Dwarf Assembler below. +# Start GDB and load object file, compute the function length and the +# offset from main to main_label which are needed in the Dwarf Assembler +# below. clean_restart ${testfile}1.o =20 set main_length "" @@ -59,9 +60,17 @@ gdb_test_multiple $test $test { } } =20 -if { $main_length =3D=3D "" } { +set main_label_offset "" +set test "p main_label - main" +gdb_test_multiple $test $test { + -re ".* =3D ($decimal)\r\n$gdb_prompt $" { + set main_label_offset $expect_out(1,string) + } +} + +if { $main_length =3D=3D "" || $main_label_offset =3D=3D "" } { # Bail out here, because we can't do the following tests if - # $main_length is unknown. + # $main_length or $main_label_offset is unknown. return -1 } =20 @@ -71,7 +80,7 @@ gdb_exit set asm_file [standard_output_file $srcfile2] Dwarf::assemble $asm_file { declare_labels partial_label int_label int_label2 - global main_length + global main_length main_label_offset =20 extern main =20 @@ -79,8 +88,8 @@ Dwarf::assemble $asm_file { partial_label: partial_unit {} { subprogram { {name main} - {low_pc main addr} - {high_pc "main + $main_length" addr} + {low_pc "main_label - $main_label_offset" addr} + {high_pc "main_label - $main_label_offset + $main_length" addr} } } } diff --git a/gdb/testsuite/gdb.dwarf2/main.c b/gdb/testsuite/gdb.dwarf2/mai= n.c index 3ddd194..e6d4715 100644 --- a/gdb/testsuite/gdb.dwarf2/main.c +++ b/gdb/testsuite/gdb.dwarf2/main.c @@ -20,5 +20,6 @@ int main() { + asm ("main_label: .globl main_label"); return 0; }