From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 27012 invoked by alias); 6 Jun 2014 12:33:11 -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 27003 invoked by uid 89); 6 Jun 2014 12:33:10 -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; Fri, 06 Jun 2014 12:33:07 +0000 Received: from svr-orw-exc-10.mgc.mentorg.com ([147.34.98.58]) by relay1.mentorg.com with esmtp id 1WstKR-0007X3-6B from Yao_Qi@mentor.com ; Fri, 06 Jun 2014 05:33:03 -0700 Received: from SVR-ORW-FEM-06.mgc.mentorg.com ([147.34.97.120]) by SVR-ORW-EXC-10.mgc.mentorg.com with Microsoft SMTPSVC(6.0.3790.4675); Fri, 6 Jun 2014 05:33:03 -0700 Received: from qiyao.dyndns.org (147.34.91.1) by SVR-ORW-FEM-06.mgc.mentorg.com (147.34.97.120) with Microsoft SMTP Server id 14.2.247.3; Fri, 6 Jun 2014 05:33:02 -0700 Message-ID: <5391B48B.40409@codesourcery.com> Date: Fri, 06 Jun 2014 12:33:00 -0000 From: Yao Qi User-Agent: Mozilla/5.0 (X11; Linux i686; rv:24.0) Gecko/20100101 Thunderbird/24.4.0 MIME-Version: 1.0 To: Pedro Alves , Subject: Re: [PATCH] Tweak gdb.base/async.exp References: <1402040654-11738-1-git-send-email-yao@codesourcery.com> <539194B5.7090501@redhat.com> In-Reply-To: <539194B5.7090501@redhat.com> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8bit X-IsSubscribed: yes X-SW-Source: 2014-06/txt/msg00319.txt.bz2 On 06/06/2014 06:15 PM, Pedro Alves wrote: > Note: "nexti" is supposed to skip function calls, but the test > isn't actually testing that works. It'd be nice if it > did. E.g., we'd add: > > for (i = 0; i < 2; i++) > foo (); > > and "stepi" the first loop iteration looking for the > first address that has a "backtrace" with two frames. The > "call/jmp" instruction that nexti& should step over would > be the address the program was stopped before the last > stepi. We'd run to the address again (for the second iteration), > and do a "nexti&", making sure we land on the next > instruction, after the call returns. > > But TBC, since the test doesn't do this today, it's fine to > fix it assuming nexti is just like stepi. With in mind ... Yes, we should cover nexti and stepi for function call. However, I don't have extra cycles on that at this moment, because I am triaging new fails since 7.7 release on arm targets. We can revisit it after 7.8 release. > >> > +# We may nexti into the same source line or into the next source line. >> > +# In the former case, the current PC is printed out. We match either >> > +# of them. >> > +test_background "nexti&" "" ".*( 0x0*$next_insn_addr|y = 3).*" > I'd rather always only check by address. It's simpler and it'd > prevent a bug where we should still end on the same line, like > on ARM, but nexti steps too much and only stops on the > next line. > > I think we just need to do: > > - x = 5; x = 5; > + x = 5; x = 5; x = 5; > > in the C file? 'x' is volatile, so that'd always makes us land > in the middle of the line. > Yes, that is sufficient. The patch is updated. -- Yao (齐尧) Subject: [PATCH] Tweak gdb.base/async.exp I see two fails in async.exp on arm-none-eabi target: nexti&^M (gdb) 0x000001ba 14 x = 5; x = 5;^M completed.^M FAIL: gdb.base/async.exp: nexti& finish&^M Run till exit from #0 0x000001ba in foo () at /scratch/yqi/arm-none-eabi-lite/src/gdb-trunk/gdb/testsuite/gdb.base/async.c:14^M (gdb) 0x000001e6 in main () at /scratch/yqi/arm-none-eabi-lite/src/gdb-trunk/gdb/testsuite/gdb.base/async.c:32^M 32 y = foo ();^M Value returned is $1 = 8^M completed.^M FAIL: gdb.base/async.exp: finish& The corresponding test is "test_background "nexti&" "" ".*y = 3.*"", and it assumes that GDB "nexti" into the next source line. It is wrong on arm. After "nexti", it still stops at the same source line, and it fails. When gdb does "finish", if the PC is in the middle of a source line, the PC address is printed too. See stack.c:print_frame, if (opts.addressprint) if (!sal.symtab || frame_show_address (frame, sal) || print_what == LOC_AND_ADDRESS) { annotate_frame_address (); if (pc_p) ui_out_field_core_addr (uiout, "addr", gdbarch, pc); else ui_out_field_string (uiout, "addr", ""); annotate_frame_address_end (); ui_out_text (uiout, " in "); } frame_show_address checks whether PC is the middle of a source line. Since after "nexti", the inferior stops at the middle of a source line, when we do "finish" the PC address is displayed. In sum, GDB works well, but test case needs update. This patch is to add a statement at the same line to make sure "nexti" doesn't go to the new line, match the next instruction address in the output and match the hex address the output of "finish". gdb/testsuite: 2014-06-06 Yao Qi * gdb.base/async.c (foo): Add one statement. * gdb.base/async.exp: Get the next instruction address and match the output of "nexti" by instruction address. Match the hex address in the output of "finish". --- gdb/testsuite/gdb.base/async.c | 2 +- gdb/testsuite/gdb.base/async.exp | 16 ++++++++++++++-- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/gdb/testsuite/gdb.base/async.c b/gdb/testsuite/gdb.base/async.c index 76ce8be..649e9e6 100644 --- a/gdb/testsuite/gdb.base/async.c +++ b/gdb/testsuite/gdb.base/async.c @@ -11,7 +11,7 @@ foo () int y; volatile int x; - x = 5; x = 5; + x = 5; x = 5; x = 5; y = 3; return x + y; diff --git a/gdb/testsuite/gdb.base/async.exp b/gdb/testsuite/gdb.base/async.exp index 0f99b01..cce8b5b 100644 --- a/gdb/testsuite/gdb.base/async.exp +++ b/gdb/testsuite/gdb.base/async.exp @@ -75,10 +75,22 @@ test_background "step&" "" " foo \\(\\) at .*async.c.*x = 5.*" "step& #2" test_background "stepi&" "" ".*$hex.*x = 5.*" -test_background "nexti&" "" ".*y = 3.*" +# Get the next instruction address. +set next_insn_addr "" +set test "get next insn" +gdb_test_multiple {x/2i $pc} "$test" { + -re "=> $hex .* 0x(\[0-9a-f\]*) .*$gdb_prompt $" { + set next_insn_addr $expect_out(1,string) + pass "$test" + } +} + +# We nexti into the same source line. The current PC is printed out. +test_background "nexti&" "" ".* 0x0*$next_insn_addr.* x = 5; .*" +# PC is in the middle of a source line, so the PC address is displayed. test_background "finish&" \ - "Run till exit from #0 foo \\(\\) at.*async.c.*\r\n" \ + "Run till exit from #0 $hex in foo \\(\\) at.*async.c.*\r\n" \ ".*$hex in main \\(\\) at.*async.c.*y = foo \\(\\).*Value returned is.*= 8.*" set jump_here [gdb_get_line_number "jump here"] -- 1.9.0