public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Yao Qi <yao@codesourcery.com>
To: Pedro Alves <palves@redhat.com>
Cc: <gdb-patches@sourceware.org>
Subject: Re: [PATCH 5/5] Test attaching to a program that constantly spawns short-lived threads
Date: Wed, 17 Dec 2014 11:10:00 -0000	[thread overview]
Message-ID: <87wq5qsfaf.fsf@codesourcery.com> (raw)
In-Reply-To: <1418748834-27545-6-git-send-email-palves@redhat.com> (Pedro	Alves's message of "Tue, 16 Dec 2014 16:53:54 +0000")

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 (齐尧)

  reply	other threads:[~2014-12-17 11:10 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-12-16 16:54 [PATCH 0/5] GNU/Linux, fix attach races/problems Pedro Alves
2014-12-16 16:54 ` [PATCH 1/5] libthread_db: debug output should go to gdb_stdlog Pedro Alves
2014-12-17  8:02   ` Yao Qi
2014-12-17 13:45     ` Pedro Alves
2014-12-17 14:09       ` Yao Qi
2014-12-16 16:54 ` [PATCH 3/5] libthread_db: Skip attaching to terminated and joined threads Pedro Alves
2014-12-16 16:54 ` [PATCH 4/5] Linux: Skip thread_db thread event reporting if PTRACE_EVENT_CLONE is supported Pedro Alves
2014-12-16 21:24   ` Simon Marchi
2014-12-17 13:04     ` Pedro Alves
2014-12-16 16:54 ` [PATCH 2/5] Linux: on attach, attach to lwps listed under /proc/$pid/task/ Pedro Alves
2014-12-16 20:52   ` Simon Marchi
2014-12-17 13:35     ` Pedro Alves
2014-12-16 17:35 ` [PATCH 5/5] Test attaching to a program that constantly spawns short-lived threads Pedro Alves
2014-12-17 11:10   ` Yao Qi [this message]
2014-12-18  0:02     ` Pedro Alves
2015-01-05 19:02       ` Breazeal, Don
2015-01-07 16:17         ` [PATCH] skip "attach" tests when testing against stub-like targets (was: Re: [PATCH 5/5] Test attaching to a program that constantly spawns short-lived threads) Pedro Alves
2015-01-09 11:24           ` [PATCH] skip "attach" tests when testing against stub-like targets Pedro Alves
2015-01-12  4:43             ` [regression/native-gdbserver][buildbot] Python testscases get staled (was: Re: [PATCH] skip "attach" tests when testing against stub-like targets) Sergio Durigan Junior
2015-01-12 11:15               ` [regression/native-gdbserver][buildbot] Python testscases get staled Pedro Alves
2015-01-12 16:55                 ` Sergio Durigan Junior
2015-01-12 17:01                   ` Pedro Alves
2015-01-12 17:13                     ` [PATCH] gdb.python/py-prompt.exp: restore GDBFLAGS Pedro Alves
2015-01-09 12:03 ` [PATCH 0/5] GNU/Linux, fix attach races/problems Pedro Alves

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87wq5qsfaf.fsf@codesourcery.com \
    --to=yao@codesourcery.com \
    --cc=gdb-patches@sourceware.org \
    --cc=palves@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).