From patchwork Fri Apr 22 09:19:18 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yao Qi X-Patchwork-Id: 11853 Received: (qmail 35604 invoked by alias); 22 Apr 2016 09:19:53 -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 35591 invoked by uid 89); 22 Apr 2016 09:19:52 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.6 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 spammy=HX-Received:10.98.12.154, 2016-04-22, 20160422 X-HELO: mail-pf0-f170.google.com Received: from mail-pf0-f170.google.com (HELO mail-pf0-f170.google.com) (209.85.192.170) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Fri, 22 Apr 2016 09:19:41 +0000 Received: by mail-pf0-f170.google.com with SMTP id e128so39423580pfe.3 for ; Fri, 22 Apr 2016 02:19:41 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:subject:date:message-id; bh=BmaoPwUVSI1v9rCff+/8IrJpmPiekUXMQepZZuh8Ugc=; b=eJFszF2C/EQnTAA/Pu9f3b+Fkyu2OjkQXvphhYdJHlMDyaUmq3yv7vWN9Jf/Vv4xbc PYbebuImZhlKx4wEDbmW5WcDb9TCs3qEQkjHzEYxhg7FGVdhECWxIJq+FWxIV5UmrxYW +Yuzf5zHN/0qVuVlT52pFX5zPApqCGwte7dN/nsnCpXG1Wr+lGOvpPUl3TlU3bFHW3PT 3O1ZqIz10gBv6gByDvsDX9yb79gbxws4KHaqUIjIUVysosJgwe/zLjoNv1LpY3NemCEx 3bqW4MWT4CaaWYr4kOuFQbGzAY/lWTdV0Q9T0xBThh4umSzhPR/ZKhXGfIeRkqSQDIqv I5oQ== X-Gm-Message-State: AOPr4FUDY899bGaElJ923ugZf7N+WuCPJH4AEBjeaGsjyucbialz/Pdd6Do9PPLSzllMaw== X-Received: by 10.98.12.154 with SMTP id 26mr26958058pfm.20.1461316779560; Fri, 22 Apr 2016 02:19:39 -0700 (PDT) Received: from E107787-LIN.cambridge.arm.com (gcc1-power7.osuosl.org. [140.211.15.137]) by smtp.gmail.com with ESMTPSA id b63sm6810332pfa.48.2016.04.22.02.19.38 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 22 Apr 2016 02:19:39 -0700 (PDT) From: Yao Qi X-Google-Original-From: Yao Qi To: gdb-patches@sourceware.org Subject: [PATCH] Fix fail in gdb.base/annota1.exp and gdb.base/annota3.exp Date: Fri, 22 Apr 2016 10:19:18 +0100 Message-Id: <1461316758-18789-1-git-send-email-yao.qi@linaro.org> X-IsSubscribed: yes Hi, I am seeing the fail below on aarch64-linux with gcc 4.9.2, break main Breakpoint 1 at 0x4006e8: file binutils-gdb/gdb/testsuite/gdb.base/annota1.c, line 14.^M (gdb) FAIL: gdb.base/annota1.exp: breakpoint main the test expects the breakpoint is set on line 15. Let us look at the main function, 12 int 13 main (void) 14 { 15 int my_array[3] = { 1, 2, 3 }; /* break main */ 16 17 value = 7; 18 19 #ifdef SIGUSR1 20 signal (SIGUSR1, handle_USR1); 21 #endif (gdb) disassemble main Dump of assembler code for function main: 0x00000000004006e0 <+0>: stp x29, x30, [sp,#-48]! 0x00000000004006e4 <+4>: mov x29, sp 0x00000000004006e8 <+8>: adrp x0, 0x411000 0x00000000004006ec <+12>: add x0, x0, #0x40 the breakpoint is set on the right address after skipping prologue, but 0x00000000004006e8 is mapped to the line 14, as shown below, (gdb) maintenance info line-table objfile: /home/yao.qi/source/build-aarch64/gdb/testsuite/outputs/gdb.base/annota1/annota1 ((struct objfile *) 0x2b0e1850) compunit_symtab: ((struct compunit_symtab *) 0x2b0ded50) symtab: /home/yao.qi/source/binutils-gdb/gdb/testsuite/gdb.base/annota1.c ((struct symtab *) 0x2b0dedd0) linetable: ((struct linetable *) 0x2b12c8b0): INDEX LINE ADDRESS 0 7 0x00000000004006d0 1 8 0x00000000004006d8 2 14 0x00000000004006e0 3 14 0x00000000004006e8 4 15 0x00000000004006fc so GDB does nothing wrong. Program hits breakpoint on either line 14 or line 15 is right to me. With anther gcc (4.9.3), the line-table looks correct, and no test fail. Instead of setting breakpoint on main and assuming the line is what we get from the source, we can set breakpoint on that line. On the other hand, the test prints the values of the array and check, so we need to set breakpoint on the line setting the values of array and "next", rather than setting the breakpoint on main. gdb/testsuite: 2016-04-22 Yao Qi * gdb.base/annota1.exp: Set breakpoint on line $main_line. * gdb.base/annota3.exp: Likewise. --- gdb/testsuite/gdb.base/annota1.exp | 13 +++++++------ gdb/testsuite/gdb.base/annota3.exp | 10 +++++----- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/gdb/testsuite/gdb.base/annota1.exp b/gdb/testsuite/gdb.base/annota1.exp index 36de636..38b594c 100644 --- a/gdb/testsuite/gdb.base/annota1.exp +++ b/gdb/testsuite/gdb.base/annota1.exp @@ -46,12 +46,12 @@ clean_restart ${binfile} gdb_test_no_output "set height 0" # -# break at main +# break in main # set main_line [gdb_get_line_number "break main"] -gdb_test "break main" \ +gdb_test "break ${srcfile}:${main_line}" \ "Breakpoint.*at.* file .*$srcfile, line $main_line\\." \ "breakpoint main" @@ -293,16 +293,17 @@ gdb_test_multiple "delete 3" "delete bp 3" { } # -# break at main, after value is initialized. This is in preparation +# break in main, after value is initialized. This is in preparation # to test the annotate output for the display command. # -gdb_test_multiple "break main" "break at main" { +set test "break in main" +gdb_test_multiple "break ${srcfile}:${main_line}" $test { -re "post-prompt.*Breakpoint 4 at $hex: file ${escapedsrcfile}, line $main_line.*\032\032breakpoints-invalid.*$gdb_prompt$" { - pass "break at main" + pass $test } -re "post-prompt.*Breakpoint 4 at $hex: file .*${srcfile}, line $main_line.*\032\032breakpoints-invalid.*$gdb_prompt$" { setup_xfail "*-*-*" 1270 - fail "break at main" + fail $test } } diff --git a/gdb/testsuite/gdb.base/annota3.exp b/gdb/testsuite/gdb.base/annota3.exp index ae70414..de11c4a 100644 --- a/gdb/testsuite/gdb.base/annota3.exp +++ b/gdb/testsuite/gdb.base/annota3.exp @@ -45,12 +45,12 @@ clean_restart ${binfile} gdb_test_no_output "set height 0" # -# break at main +# break in main # set main_line [gdb_get_line_number "break main"] -gdb_test "break main" \ +gdb_test "break ${srcfile}:${main_line}" \ "Breakpoint.*at.* file .*$srcfile, line $main_line\\." \ "breakpoint main" @@ -258,11 +258,11 @@ gdb_expect_list "delete bp 3" "$gdb_prompt$" { } # -# break at main, after value is initialized. This is in preparation +# break in main, after value is initialized. This is in preparation # to test the annotate output for the display command. # -send_gdb "break main\n" -gdb_expect_list "break at main" "$gdb_prompt$" [concat { +send_gdb "break ${srcfile}:${main_line}\n" +gdb_expect_list "break in main" "$gdb_prompt$" [concat { "\r\n\032\032post-prompt\r\n" } [list \ "Breakpoint 4 at 0x\[0-9a-z\]+: file .*annota3.c, line $main_line.\r\n"]]