This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PATCH 5/5] Test attaching to a program that constantly spawns short-lived threads
- From: Yao Qi <yao at codesourcery dot com>
- To: Pedro Alves <palves at redhat dot com>
- Cc: <gdb-patches at sourceware dot org>
- Date: Wed, 17 Dec 2014 19:10:16 +0800
- Subject: Re: [PATCH 5/5] Test attaching to a program that constantly spawns short-lived threads
- Authentication-results: sourceware.org; auth=none
- References: <1418748834-27545-1-git-send-email-palves at redhat dot com> <1418748834-27545-6-git-send-email-palves at redhat dot com>
Pedro Alves <palves@redhat.com> writes:
> +if [is_remote target] then {
> + return 0
> +}
We should check
"![isnative] || [is_remote host] || [target_info exists use_gdb_stub]" instead?
> +
> +standard_testfile
> +
> +# The test proper. See description above.
> +
> +proc test {} {
> + global binfile
> + global gdb_prompt
> + global decimal
> +
> + clean_restart ${binfile}
> +
> + set testpid [spawn_wait_for_attach $binfile]
> +
> + set attempts 10
> + for {set attempt 1} { $attempt <= $attempts } { incr attempt } {
> + with_test_prefix "iter $attempt" {
> + set attached 0
> + set eperm 0
> + set test "attach"
> + gdb_test_multiple "attach $testpid" $test {
> + -re "new threads in iteration" {
> + # Seen when "set debug libthread_db" is on.
> + exp_continue
> + }
> + -re "warning: Cannot attach to lwp $decimal: Operation not permitted" {
> + # On Linux, PTRACE_ATTACH sometimes fails with
> + # EPERM, even though /proc/PID/status indicates
> + # the thread is running.
> + set eperm 1
> + exp_continue
> + }
> + -re "debugger service failed.*$gdb_prompt $" {
> + fail $test
> + }
> + -re "$gdb_prompt $" {
> + if {$eperm} {
> + kfail "gdb/NNNN" "$test (EPERM)"
Replace NNNN with a PR number?
> + } else {
> + pass $test
> + }
> + }
> + -re "Attaching to program.*process $testpid.*$gdb_prompt $" {
> + pass $test
> + }
> + }
> +
> + # Sleep a bit and try updating the thread list. We should
> + # know about all threads already at this point. If we see
> + # "New Thread" or similar being output, then "attach" is
> + # failing to actually attach to all threads in the process,
> + # which would be a bug.
> + sleep 1
> + set saw_new 0
> + set test "info threads"
> + gdb_test_multiple $test $test {
> + -re "New " {
> + set saw_new 1
> + exp_continue
> + }
> + -re "$gdb_prompt $" {
> + }
> + }
> +
> + gdb_assert !$saw_new "no new threads"
Nit: I feel the test above can be simplified a little bit,
gdb_test_multiple $test $test {
-re "New .*$gdb_prompt $" {
fail "no new threads"
}
-re "$gdb_prompt $" {
pass "no new threads"
}
}
--
Yao (éå)