This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PATCH v4 3/3] Fix failure to detach if process exits while detaching on Linux
- From: Yao Qi <qiyaoltc at gmail dot com>
- To: Pedro Alves <palves at redhat dot com>
- Cc: gdb-patches at sourceware dot org
- Date: Fri, 17 Jun 2016 16:07:43 +0100
- Subject: Re: [PATCH v4 3/3] Fix failure to detach if process exits while detaching on Linux
- Authentication-results: sourceware.org; auth=none
- References: <1466119968-15171-1-git-send-email-palves at redhat dot com> <1466119968-15171-4-git-send-email-palves at redhat dot com>
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 (éå)