diff mbox

[testsuite] further robustify gdb.base/bp-permanent.exp

Message ID 55B9A29E.4040305@codesourcery.com
State New
Headers show

Commit Message

Sandra Loosemore July 30, 2015, 4:05 a.m. UTC
When I was testing the Nios II R2 patch I posted earlier today, I saw a 
lot of failures from gdb.base/bp-permanent.exp.  Upon investigation, I 
realized that this was a due to a quirk of the simulator we have 
available.  Apparently, its execution engine maintains its own view of 
the .text section and breakpoints set through the debug interface are 
not visible to the running program.  This means that the setup function 
in the program is stashing away a copy of the original NOP instruction 
at the breakpoint location, rather than the breakpoint instruction 
inserted by GDB, and when the .exp file thinks it is writing a permanent 
breakpoint in fact it is just telling the target to write a NOP to a 
location that already contains one.  :-S

Anyway, it is clear that if the program runs to termination instead of 
stopping where GDB expects, none of the remaining tests are going to do 
anything useful, so we might just as well report that the test is 
unsupported and return.

OK to commit?

-Sandra

Comments

Pedro Alves Aug. 3, 2015, 1:21 p.m. UTC | #1
On 07/30/2015 05:05 AM, Sandra Loosemore wrote:
> When I was testing the Nios II R2 patch I posted earlier today, I saw a 
> lot of failures from gdb.base/bp-permanent.exp.  Upon investigation, I 
> realized that this was a due to a quirk of the simulator we have 
> available.  Apparently, its execution engine maintains its own view of 
> the .text section and breakpoints set through the debug interface are 
> not visible to the running program.  This means that the setup function 
> in the program is stashing away a copy of the original NOP instruction 
> at the breakpoint location, rather than the breakpoint instruction 
> inserted by GDB, and when the .exp file thinks it is writing a permanent 
> breakpoint in fact it is just telling the target to write a NOP to a 
> location that already contains one.  :-S
> 
> Anyway, it is clear that if the program runs to termination instead of 
> stopping where GDB expects, none of the remaining tests are going to do 
> anything useful, so we might just as well report that the test is 
> unsupported and return.
> 
> OK to commit?

> +	set test "permanent breakpoint causes random signal"
> +	gdb_test_multiple "continue" $test {
> +	    -re "exited normally.*$gdb_prompt $" {
> +	        unsupported "failed to stop at permanent breakpoint"
> +		return
> +	    }
> +	    -re "Program received signal SIGTRAP.*" {

This needs to end with "$gdb_prompt $" too.

OK with that change.

> +	    	pass $test
> +	    }
> +	}
>  
>  	# Now set a breakpoint on top, thus creating a permanent breakpoint.
>  	gdb_breakpoint "$line_bp"
> 


Thanks,
Pedro Alves
diff mbox

Patch

diff --git a/gdb/testsuite/gdb.base/bp-permanent.exp b/gdb/testsuite/gdb.base/bp-permanent.exp
index cbdbc75..44609ed 100644
--- a/gdb/testsuite/gdb.base/bp-permanent.exp
+++ b/gdb/testsuite/gdb.base/bp-permanent.exp
@@ -123,8 +123,21 @@  proc test {always_inserted sw_watchpoint} {
     with_test_prefix "basics" {
 	# Run to the permanent breakpoint, just to make sure we've inserted it
 	# correctly.
-	gdb_test "continue" "Program received signal SIGTRAP.*" \
-	    "permanent breakpoint causes random signal"
+	# If the target fails to stop, the remainder of the test will not work
+	# so just return.  This can happen on some simulator targets where
+	# the running program doesn't see breakpoints that are visible to
+	# the execution engine, or where writes to the .text section are
+	# quietly ignored.
+	set test "permanent breakpoint causes random signal"
+	gdb_test_multiple "continue" $test {
+	    -re "exited normally.*$gdb_prompt $" {
+	        unsupported "failed to stop at permanent breakpoint"
+		return
+	    }
+	    -re "Program received signal SIGTRAP.*" {
+	    	pass $test
+	    }
+	}
 
 	# Now set a breakpoint on top, thus creating a permanent breakpoint.
 	gdb_breakpoint "$line_bp"