From: Pedro Alves <pedro@palves.net>
To: Tiezhu Yang <yangtiezhu@loongson.cn>, gdb-patches@sourceware.org
Subject: Re: [PATCH v5 2/2] gdb: testsuite: fix wrong expected result in attach-pie-noexec.exp
Date: Thu, 3 Mar 2022 18:45:13 +0000 [thread overview]
Message-ID: <e5f08136-fa4d-2f21-ff83-8adf4d3a158e@palves.net> (raw)
In-Reply-To: <1645584316-5375-3-git-send-email-yangtiezhu@loongson.cn>
On 2022-02-23 02:45, Tiezhu Yang wrote:
> -proc can_spawn_for_attach { } {
> +gdb_caching_proc can_spawn_for_attach {
> # We use exp_pid to get the inferior's pid, assuming that gives
> # back the pid of the program. On remote boards, that would give
> # us instead the PID of e.g., the ssh client, etc.
> @@ -5079,6 +5079,42 @@ proc can_spawn_for_attach { } {
> return 0
> }
>
> + set me "can_spawn_for_attach"
> + set src { int main (void) { sleep (600); return 0; } }
> + if {![gdb_simple_compile $me $src executable]} {
> + return 0
> + }
> +
> + set test_spawn_id [spawn_wait_for_attach $obj]
> + set test_pid [spawn_id_get_pid $test_spawn_id]
> +
> + gdb_start
> + file delete $obj
> + gdb_test_multiple "attach $test_pid" "can spawn for attach" {
> + -re -wrap "Attaching to process $test_pid\r\n.*No executable file now.*" {
> + pass $gdb_test_name
I don't think caching procs should issue pass/fail, as whether the proc does anything
depends on whether the result was cached before. It seems weird to get a PASS/FAIL
depending on whether the result was cached or not earlier.
> + kill_wait_spawned_process $test_spawn_id
> + return 1
I have to say this whole thing seems completely backwards to me. We are checking
whether we can spawn a program for attaching, by spawning a program for attaching,
and then attaching... If the "attach" command has some kind of bug, then we will
fail can_spawn_for_attach instead of having that proc return true, and then letting
the proper "attach" tests fail.
Why isn't this all solved by leaving can_spawn_for_attach alone, and then making
the "attach" tests bail out on failure to attach. We could add some new
gdb_attach proc to centralize the failure checking.
next prev parent reply other threads:[~2022-03-03 18:45 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-02-23 2:45 [PATCH v5 0/2] Modify can_spawn_for_attach Tiezhu Yang
2022-02-23 2:45 ` [PATCH v5 1/2] gdb: testsuite: print explicit test result in can_spawn_for_attach Tiezhu Yang
2022-02-23 2:45 ` [PATCH v5 2/2] gdb: testsuite: fix wrong expected result in attach-pie-noexec.exp Tiezhu Yang
2022-03-03 18:45 ` Pedro Alves [this message]
2022-03-18 20:07 ` Kevin Buettner
2022-03-18 20:43 ` Kevin Buettner
2022-02-28 6:59 ` [PATCH v5 0/2] Modify can_spawn_for_attach Tiezhu Yang
2022-02-28 14:36 ` Simon Marchi
2022-03-01 14:12 ` Simon Marchi
2022-03-02 6:42 ` Tiezhu Yang
2022-03-03 15:46 ` Simon Marchi
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=e5f08136-fa4d-2f21-ff83-8adf4d3a158e@palves.net \
--to=pedro@palves.net \
--cc=gdb-patches@sourceware.org \
--cc=yangtiezhu@loongson.cn \
/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).