Fix PR breakpoints/16494: gdb.base/dprintf.exp agent-printf failures with non-Z0-supporting gdbservers
Commit Message
On 03/21/14 21:11, Pedro Alves wrote:
Thanks for your review.
> 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.
Update this part to:
# Make sure the current target support target side commands.
Update mi-dprintf.exp to:
# Make sure the current target support 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"
>> + }
>> + }
>
> 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
> ...
>
Update this part to:
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 "Breakpoint \[0-9\]+, foo .*" {
pass "1st dprintf, agent"
}
}
if $target_can_dprintf {
gdb_test "continue" "Breakpoint \[0-9\]+, foo .*" "2nd dprintf, agent"
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\]3 dprintf"
"\[\r\n\]\tbreakpoint already hit 2 times"
"\[\r\n\] agent-printf \"At foo entry\\\\n\""
"\[\r\n\]4 dprintf"
"\[\r\n\]\tbreakpoint already hit 2 times"
"\[\r\n\] agent-printf \"arg=%d, g=%d\\\\n\", arg, g"
}
}
Update mi-dprintf.exp to:
if $target_can_dprintf {
# Make sure the current target support target side commands.
if {[mi_run_cmd] < 0} {
set target_can_dprintf 0
unsupported "send dprintf to target"
}
if $target_can_dprintf {
mi_expect_stop ".*" ".*" ".*" ".*" ".*" "" "mi expect stop"
mi_send_resuming_command "exec-continue" "mi 1st dprintf continue, agent"
mi_expect_stop ".*" "foo" ".*" ".*" ".*" "" "mi 1st dprintf, agent"
mi_send_resuming_command "exec-continue" "mi 2nd dprintf continue, agent"
# The =breakpoint-modified text is a part of the "-exec-continue" output.
set msg "mi info dprintf second time"
gdb_expect {
-re "=breakpoint-modified," {
pass $msg
}
-re ".*$mi_gdb_prompt$" {
fail "$msg"
}
timeout {
fail "$msg"
}
}
mi_expect_stop ".*" "foo" ".*" ".*" ".*" "" "mi 2nd dprintf, agent"
}
}
>
>
>> 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.
>
Post new version. Please help me review it.
Best.
Hui
2014-03-23 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.
@@ -109,24 +109,36 @@ gdb_test_multiple "set dprintf-style age
}
if $target_can_dprintf {
+ # Make sure the current target support target side commands.
gdb_run_cmd
gdb_test "" "Breakpoint"
- gdb_test "continue" "Breakpoint \[0-9\]+, foo .*" "1st dprintf, agent"
+ 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 "Breakpoint \[0-9\]+, foo .*" {
+ pass "1st dprintf, agent"
+ }
+ }
- gdb_test "continue" "Breakpoint \[0-9\]+, foo .*" "2nd dprintf, agent"
+ if $target_can_dprintf {
+ gdb_test "continue" "Breakpoint \[0-9\]+, foo .*" "2nd dprintf, agent"
- 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\]3 dprintf"
- "\[\r\n\]\tbreakpoint already hit 2 times"
- "\[\r\n\] agent-printf \"At foo entry\\\\n\""
- "\[\r\n\]4 dprintf"
- "\[\r\n\]\tbreakpoint already hit 2 times"
- "\[\r\n\] agent-printf \"arg=%d, g=%d\\\\n\", arg, g"
+ 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\]3 dprintf"
+ "\[\r\n\]\tbreakpoint already hit 2 times"
+ "\[\r\n\] agent-printf \"At foo entry\\\\n\""
+ "\[\r\n\]4 dprintf"
+ "\[\r\n\]\tbreakpoint already hit 2 times"
+ "\[\r\n\] agent-printf \"arg=%d, g=%d\\\\n\", arg, g"
+ }
}
}
@@ -140,30 +140,36 @@ gdb_expect {
}
if $target_can_dprintf {
- mi_run_cmd
+ # Make sure the current target support target side commands.
+ if {[mi_run_cmd] < 0} {
+ set target_can_dprintf 0
+ unsupported "send dprintf to target"
+ }
- mi_expect_stop ".*" ".*" ".*" ".*" ".*" "" "mi expect stop"
+ if $target_can_dprintf {
+ mi_expect_stop ".*" ".*" ".*" ".*" ".*" "" "mi expect stop"
- mi_send_resuming_command "exec-continue" "mi 1st dprintf continue, agent"
- mi_expect_stop ".*" "foo" ".*" ".*" ".*" "" "mi 1st dprintf, agent"
+ mi_send_resuming_command "exec-continue" "mi 1st dprintf continue, agent"
+ mi_expect_stop ".*" "foo" ".*" ".*" ".*" "" "mi 1st dprintf, agent"
- mi_send_resuming_command "exec-continue" "mi 2nd dprintf continue, agent"
+ mi_send_resuming_command "exec-continue" "mi 2nd dprintf continue, agent"
- # The =breakpoint-modified text is a part of the "-exec-continue" output.
- set msg "mi info dprintf second time"
- gdb_expect {
- -re "=breakpoint-modified," {
- pass $msg
- }
- -re ".*$mi_gdb_prompt$" {
- fail "$msg"
- }
- timeout {
- fail "$msg"
+ # The =breakpoint-modified text is a part of the "-exec-continue" output.
+ set msg "mi info dprintf second time"
+ gdb_expect {
+ -re "=breakpoint-modified," {
+ pass $msg
+ }
+ -re ".*$mi_gdb_prompt$" {
+ fail "$msg"
+ }
+ timeout {
+ fail "$msg"
+ }
}
- }
- mi_expect_stop ".*" "foo" ".*" ".*" ".*" "" "mi 2nd dprintf, agent"
+ mi_expect_stop ".*" "foo" ".*" ".*" ".*" "" "mi 2nd dprintf, agent"
+ }
}
mi_gdb_test "set dprintf-style foobar" ".*error.*" "mi set dprintf style to an unrecognized type"
@@ -843,6 +843,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