From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr1-x42c.google.com (mail-wr1-x42c.google.com [IPv6:2a00:1450:4864:20::42c]) by sourceware.org (Postfix) with ESMTPS id 37D1B395A423 for ; Tue, 10 Mar 2020 19:05:38 +0000 (GMT) Received: by mail-wr1-x42c.google.com with SMTP id v9so17281459wrf.10 for ; Tue, 10 Mar 2020 12:05:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=embecosm.com; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=kiOzTsnU35L0xp0FgIWOlIZSZXQ0LCti4PbTN4zGocI=; b=SjmWFDehOEHuU82myrR3v4h989GWq3AzVhEROK/vNG9qS7qoO8qO+HaDSR6Ahpmira nWcV4l1ZO3RKiesb6RjJ6ZSjwqAuoo+Q0s5Pa8iiBlLFeyPbExZdrkJwW1/OVKNE6gaA TUbQhmJDss65gBRqOz/h8gckhRQhq95cDoIv1wlcpmo3eT2b6AcCa6k8qNf+IYKWI0Wx hdRwXY4C0WnZiWXjHoSQkubEMAzlwnq9vsp/0G46tYwYW8QaIp+t91OOk2xQJCeBm+zq MBUimTJaafqKgXpZAOjKufsxcj+7YgcEK/KJulTBVszNeXb1DtTZyF5rQhbZ0iwON0FE /8Kw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=kiOzTsnU35L0xp0FgIWOlIZSZXQ0LCti4PbTN4zGocI=; b=IiIk5y5AQymVAyfBeK9WwGuIlh7kirIGqVMEuYO7Jl8F0mBMa3u5dyrRduS6bqk9ZV WQyOKRCA5yC7lsoRZ5UUHKK+TM8iJ6xAUQLt3BVqiQ5jbVzA9sV2V5+7H56ZGcSHFY9C mARuDaQjVQ5yjJSe0wfjVRkbXQpcJ/3DoUF8xS5y9c6WPHTp1cZf7Dss94PbCm7eO8Ju wFbd1lddNmoDP4akdMuZ1tJH04pkQ9gtJZ7S2FqzJ0wnVZzSibiM4jZpTJ2O+cg3U9dh uLY+REXhtxVob0bx009ptN7Tv8RsdJFcvYBkujOIs7PFiiZkRnqAiKKYuwPg3tgMGwmQ 7eXA== X-Gm-Message-State: ANhLgQ0+U2tF3qp0qe3yrufbs2t4Qhtu5zLUN0/9tqB6TmmHZoTqyKXW 5nhtYvVkwVqskrZD+rxOQLWPTXuCCDc= X-Google-Smtp-Source: ADFU+vstvNaim2NJdErx4MZrUNm+GVZLx5gtcqKQrXfqcScIl0pcr/bbNjTmkqiNZpsZRMzlS1m0Ww== X-Received: by 2002:a5d:6245:: with SMTP id m5mr23086524wrv.154.1583867137035; Tue, 10 Mar 2020 12:05:37 -0700 (PDT) Received: from localhost (host86-180-62-221.range86-180.btcentralplus.com. [86.180.62.221]) by smtp.gmail.com with ESMTPSA id p10sm65650334wrx.81.2020.03.10.12.05.35 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 10 Mar 2020 12:05:36 -0700 (PDT) Date: Tue, 10 Mar 2020 19:05:35 +0000 From: Andrew Burgess To: Tom Tromey Cc: gdb-patches@sourceware.org, Pedro Alves Subject: Re: [PATCHv3 2/2] gdb/remote: Restore support for 'S' stop reply packet Message-ID: <20200310190535.GE3317@embecosm.com> References: <87d09lwhvr.fsf@tromey.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <87d09lwhvr.fsf@tromey.com> X-Operating-System: Linux/4.18.19-100.fc27.x86_64 (x86_64) X-Uptime: 17:03:27 up 25 days, 4:32, X-Fortune: If God had wanted you to go around nude, He would have given you bigger hands. X-Editor: GNU Emacs [ http://www.gnu.org/software/emacs ] User-Agent: Mutt/1.9.2 (2017-12-15) X-Spam-Status: No, score=-27.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 10 Mar 2020 19:05:39 -0000 * Tom Tromey [2020-03-09 11:35:52 -0600]: > Andrew> There was a regression in GDB's support for older aspects of the > Andrew> remote protocol. Specifically, when a target sends the 'S' stop reply > Andrew> packet (which doesn't include a thread-id) then GDB has to figure out > Andrew> which thread actually stopped. > > With this patch, I started seeing this warning when running the AdaCore > internal test suite using qemu. > > I investigated a little and the warning comes from this packet: > > Packet received: W00 > warning: multi-threaded target stopped without sending a thread-id, using first non-exited thread > > It seems to me that the warning must not be correct in this case, though > I am not 100% sure, so I thought I would ask. > > My reason is that this is a whole-process exit (so reporting a thread > doesn't make sense); and that in this run, qemu is not reporting that it > is multi-process-capable (so reporting a PID doesn't make sense). > > So, I wonder if process_stop_reply should be modified like (beware, > untested patch): > > diff --git a/gdb/remote.c b/gdb/remote.c > index 9b73faf9a34..810df658c54 100644 > --- a/gdb/remote.c > +++ b/gdb/remote.c > @@ -7666,7 +7666,7 @@ remote_target::process_stop_reply (struct stop_reply *stop_reply, > > /* If no thread/process was reported by the stub then use the first > non-exited thread in the current target. */ > - if (ptid == null_ptid) > + if (ptid == null_ptid && stop_reply->stop_reason != TARGET_WAITKIND_EXITED) > { > for (thread_info *thr : all_non_exited_threads (this)) > { > > > Perhaps this also applies to some of the other TARGET_WAITKIND_ values > as well? TARGET_WAITKIND_SIGNALLED seems similar. Sorry for the breakage. Looking through the list I think only W and X stop packets are going to have this problem, which correspond to TARGET_WAITKIND_EXITED and TARGET_WAITKIND_SIGNALLED respectively. I think the patch below will fix your problem, though it would be great if you could give it a try. I've only tested this against the specific issue you're seeing, I still need to clean this up, and add a test, so this is not the final version. Still, thoughts and feedback welcome. My motivation here, is to have ::process_stop_reply return some kind of valid ptid_t, so in this case, for a process wide event, I'm creating something like `ptid_t (pid)` where pid comes from the first thread we find in the target. Then I only give a warning for process wide events when the pids don't match. I'll try to post a cleaned up version with test tomorrow. Thanks, Andrew --- diff --git a/gdb/remote.c b/gdb/remote.c index 9b73faf9a34..4e201d58cd6 100644 --- a/gdb/remote.c +++ b/gdb/remote.c @@ -7670,7 +7670,10 @@ remote_target::process_stop_reply (struct stop_reply *stop_reply, { for (thread_info *thr : all_non_exited_threads (this)) { - if (ptid != null_ptid) + if (ptid != null_ptid + && ((!(status->kind == TARGET_WAITKIND_EXITED + || status->kind == TARGET_WAITKIND_SIGNALLED)) + || (ptid.pid () != thr->ptid.pid ()))) { static bool warned = false; @@ -7689,7 +7692,12 @@ remote_target::process_stop_reply (struct stop_reply *stop_reply, } break; } - ptid = thr->ptid; + + if (status->kind == TARGET_WAITKIND_EXITED + || status->kind == TARGET_WAITKIND_SIGNALLED) + ptid = ptid_t (thr->ptid.pid ()); + else + ptid = thr->ptid; } gdb_assert (ptid != null_ptid); }