From patchwork Mon Sep 29 00:52:01 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yao Qi X-Patchwork-Id: 3015 Received: (qmail 13843 invoked by alias); 29 Sep 2014 00:56:48 -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 13701 invoked by uid 89); 29 Sep 2014 00:56:47 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.7 required=5.0 tests=AWL, BAYES_00 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, 29 Sep 2014 00:56:46 +0000 Received: from svr-orw-fem-03.mgc.mentorg.com ([147.34.97.39]) by relay1.mentorg.com with esmtp id 1XYPGd-0003Ak-9c from Yao_Qi@mentor.com for gdb-patches@sourceware.org; Sun, 28 Sep 2014 17:56:43 -0700 Received: from qiyao.dyndns.org.com (147.34.91.1) by svr-orw-fem-03.mgc.mentorg.com (147.34.97.39) with Microsoft SMTP Server id 14.3.181.6; Sun, 28 Sep 2014 17:56:42 -0700 From: Yao Qi To: Subject: [PATCH 2/2] Fix implptr-optimized-out.exp fail in thumb mode Date: Mon, 29 Sep 2014 08:52:01 +0800 Message-ID: <1411951921-16168-3-git-send-email-yao@codesourcery.com> In-Reply-To: <1411951921-16168-1-git-send-email-yao@codesourcery.com> References: <1411951921-16168-1-git-send-email-yao@codesourcery.com> MIME-Version: 1.0 X-IsSubscribed: yes Hi, I see the fail in gdb.dwarf2/implptr-optimized-out.exp in thumb mode (gdb) p p->f^M No symbol "p" in current context.^M (gdb) FAIL: gdb.dwarf2/implptr-optimized-out.exp: p p->f 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'. gdb/testsuite: 2014-09-29 Yao Qi * gdb.dwarf2/implptr-optimized-out.exp: Compile main.c to object. Calculate the offset of main_label to main. Compile the generated asm file and link the executable. (Dwarf::assemble): Get address of main by main_label - $main_label_offset. --- gdb/testsuite/gdb.dwarf2/implptr-optimized-out.exp | 39 ++++++++++++++++++++-- 1 file changed, 36 insertions(+), 3 deletions(-) diff --git a/gdb/testsuite/gdb.dwarf2/implptr-optimized-out.exp b/gdb/testsuite/gdb.dwarf2/implptr-optimized-out.exp index 649f52d..534bed0 100644 --- a/gdb/testsuite/gdb.dwarf2/implptr-optimized-out.exp +++ b/gdb/testsuite/gdb.dwarf2/implptr-optimized-out.exp @@ -22,9 +22,35 @@ if {![dwarf2_support]} { standard_testfile main.c .S set executable ${testfile} +if {[gdb_compile ${srcdir}/${subdir}/${srcfile} ${binfile}1.o \ + object {}] != ""} { + return -1 +} +# Start GDB and load object file, compute the offset from main to +# main_label which are needed in the Dwarf Assembler below. +clean_restart ${binfile}1.o + +set main_label_offset "" +set test "p main_label - main" +gdb_test_multiple $test $test { + -re ".* = ($decimal)\r\n$gdb_prompt $" { + set main_label_offset $expect_out(1,string) + } +} + +if { $main_label_offset == "" } { + # Bail out here, because we can't do the following tests if + # $main_label_offset is unknown. + return -1 +} + +gdb_exit + # Create the DWARF. set asm_file [standard_output_file $srcfile2] Dwarf::assemble $asm_file { + global main_label_offset + cu { version 3 } { compile_unit { {producer "GNU C 4.4.3"} @@ -52,8 +78,8 @@ Dwarf::assemble $asm_file { subprogram { {name main} - {low_pc main addr} - {high_pc main+0x100 addr} + {low_pc "main_label - $main_label_offset" addr} + {high_pc "main_label - $main_label_offset + 0x100" addr} {type :$int_label} {external 1 flag} } { @@ -80,10 +106,17 @@ Dwarf::assemble $asm_file { } } -if [prepare_for_testing ${testfile}.exp $executable "${asm_file} ${srcfile}" {}] { +if {[gdb_compile $asm_file ${binfile}0.o object {}] != ""} { return -1 } +if {[gdb_compile [list ${binfile}0.o ${binfile}1.o] \ + "${binfile}" executable {}] != ""} { + return -1 +} + +clean_restart ${testfile} + # DW_OP_GNU_implicit_pointer implementation requires a valid frame. if ![runto_main] { return -1