Re: [PATCH v4 3/3] Fix failure to detach if process exits while detaching on Linux

Yao Qi
2016-06-17T15:07:59Z

Pedro Alves <palves@redhat.com> writes:

> +# If testing single-process, simply detach from the process.
> +#
> +# If testing multi-process, first detach from the child, then detach
> +# from the parent and confirm that the parent exits, thus unsuring

s/unsuring/ensuring/ ?

> +# we've detached from the child successfully, as the parent hangs in
> +# its waitpid call otherwise.
> +#
> +# If connected with "target remote", make sure gdbserver exits.
> +#
> +# CMD indicates what to do with the parent after detaching the child.
> +# Can be either "detach" to detach, or "continue", to continue to
> +# exit. If "continue", then CONTINUE_RE is the regexp to expect.
> +# Defaults to normal exit output.
> +#
> +proc do_detach {multi_process cmd {continue_re ""}} {
> + global decimal
> + global server_spawn_id
> +
> + if {$continue_re == ""} {
> + set continue_re "exited normally.*"
> + }
> +
> + set is_remote [expr {[target_info exists gdb_protocol]
> + && [target_info gdb_protocol] == "remote"}]
> +
> + if {$multi_process} {
> + gdb_test "detach" "Detaching from .*, process $decimal" \
> + "detach child"
> +
> + gdb_test "inferior 1" "\[Switching to inferior $decimal\].*" \
> + "switch to parent"
> +
> + if {$cmd == "detach"} {
> + # Make sure that detach works and that the parent process
> + # exits cleanly.
> + detach_and_expect_exit "detach parent"
> + } elseif {$cmd == "continue"} {
> + # Make sure that continuing works and that the parent process
> + # exits cleanly.
> + gdb_test "continue" $continue_re
> + } else {
> + perror "unhandled command: $mode: $cmd"

no variable "mode".

> + }
> + } else {
> + if $is_remote {
> + set extra "\r\nEnding remote debugging\."
> + } else {
> + set extra ""
> + }
> + if {$cmd == "detach"} {
> + gdb_test "detach" "Detaching from .*, process $decimal$extra"
> + } elseif {$cmd == "continue"} {
> + gdb_test "continue" $continue_re
> + } else {
> + perror "unhandled command: $mode: $cmd"
> + }
> + }
> +

--
Yao (齐尧)