diff mbox

Fix PR breakpoints/16494: gdb.base/dprintf.exp agent-printf failures with non-Z0-supporting gdbservers

Message ID 531F1E7B.8030301@mentor.com
State Superseded
Headers show

Commit Message

Hui Zhu March 11, 2014, 2:32 p.m. UTC
After the patch that commited by Pedro, the GDB can throw error about
gdbserver doesn't support agent commands.
But the test still get this error because the it doesn't try handle the
error when send dprintf to gdbserver.
So I make this patch.

It test OK and pass regression test in x86_64-linux and powerpc-linux.

Thanks,
Hui

2014-03-11  Hui Zhu  <hui@codesourcery.com>

	PR breakpoints/16494
	* gdb.base/dprintf.exp: Add second check to make sure current
	target support breakpoints that have target side commands.
	* gdb.base/mi-dprintf.exp: Ditto.
	* lib/mi-support.exp (mi_run_cmd_full): Add handle for error.

Comments

Pedro Alves March 21, 2014, 1:11 p.m. UTC | #1
On 03/11/2014 02:32 PM, Hui Zhu wrote:
> --- a/gdb/testsuite/gdb.base/dprintf.exp
> +++ b/gdb/testsuite/gdb.base/dprintf.exp
> @@ -109,6 +109,24 @@ gdb_test_multiple "set dprintf-style age
>   }
>   
>   if $target_can_dprintf {
> +    # Second check to make sure current target support breakpoints that have target side commands

Line too long.  "make sure THE current target supportS".  Period at end of sentence.

> +    gdb_run_cmd
> +
> +    gdb_test "" "Breakpoint"
> +
> +    set msg "Send dprintf to target"
> +    gdb_test_multiple "continue" $msg {
> +	-re "Warning:.*Target doesn't support breakpoints that have target side commands.*\r\n$gdb_prompt $" {
> +	    set target_can_dprintf 0
> +	    pass "$msg - cannot do"
> +	}
> +	-re ".*$gdb_prompt $" {
> +	    pass "$msg - can do"
> +	}
> +    }

Why not simply merge this check with the existing code just
below, that does pretty much the same thing?

if $target_can_dprintf {
      gdb_run_cmd
...



>   if $target_can_dprintf {
> +    # Second check to make sure current target support breakpoints that have target side commands
> +    if {[mi_run_cmd] < 0} {
> +	set target_can_dprintf 0
> +	unsupported "send dprintf to target"
> +    }
> +}
> +
> +if $target_can_dprintf {
>       mi_run_cmd

Likewise.
diff mbox

Patch

--- a/gdb/testsuite/gdb.base/dprintf.exp
+++ b/gdb/testsuite/gdb.base/dprintf.exp
@@ -109,6 +109,24 @@  gdb_test_multiple "set dprintf-style age
  }
  
  if $target_can_dprintf {
+    # Second check to make sure current target support breakpoints that have target side commands
+    gdb_run_cmd
+
+    gdb_test "" "Breakpoint"
+
+    set msg "Send dprintf to target"
+    gdb_test_multiple "continue" $msg {
+	-re "Warning:.*Target doesn't support breakpoints that have target side commands.*\r\n$gdb_prompt $" {
+	    set target_can_dprintf 0
+	    pass "$msg - cannot do"
+	}
+	-re ".*$gdb_prompt $" {
+	    pass "$msg - can do"
+	}
+    }
+}
+
+if $target_can_dprintf {
      gdb_run_cmd
  
      gdb_test "" "Breakpoint"
@@ -120,7 +138,7 @@  if $target_can_dprintf {
      gdb_test_sequence "info breakpoints" "dprintf info 2" {
  	"\[\r\n\]Num     Type           Disp Enb Address +What"
  	"\[\r\n\]2       breakpoint"
-	"\[\r\n\]\tbreakpoint already hit 2 times"
+	"\[\r\n\]\tbreakpoint already hit 3 times"
  	"\[\r\n\]3       dprintf"
  	"\[\r\n\]\tbreakpoint already hit 2 times"
  	"\[\r\n\]        agent-printf \"At foo entry\\\\n\""
--- a/gdb/testsuite/gdb.mi/mi-dprintf.exp
+++ b/gdb/testsuite/gdb.mi/mi-dprintf.exp
@@ -140,6 +140,14 @@  gdb_expect {
  }
  
  if $target_can_dprintf {
+    # Second check to make sure current target support breakpoints that have target side commands
+    if {[mi_run_cmd] < 0} {
+	set target_can_dprintf 0
+	unsupported "send dprintf to target"
+    }
+}
+
+if $target_can_dprintf {
      mi_run_cmd
  
      mi_expect_stop ".*" ".*" ".*" ".*" ".*" "" "mi expect stop"
--- a/gdb/testsuite/lib/mi-support.exp
+++ b/gdb/testsuite/lib/mi-support.exp
@@ -893,6 +893,7 @@  proc mi_run_cmd_full {use_mi_command arg
  	    send_gdb "${run_prefix}continue\n"
  	    gdb_expect 60 {
  		-re "${run_match}\\^running\[\r\n\]+\\*running,thread-id=\"\[^\"\]+\"\r\n$mi_gdb_prompt" {}
+		-re "${run_match}\\^error.*" {return -1}
  		default {}
  	    }
  	    return 0