Tweak gdb.base/async.exp

Message ID 5391B48B.40409@codesourcery.com
State Committed
Headers

Commit Message

Yao Qi June 6, 2014, 12:31 p.m. UTC
  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.
  

Comments

Pedro Alves June 6, 2014, 12:48 p.m. UTC | #1
On 06/06/2014 01:31 PM, Yao Qi wrote:

> Yes, that is sufficient.  The patch is updated.

OK.

Thanks!
  

Patch

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"]