From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id 5DB663858408 for ; Fri, 12 Apr 2024 16:05:31 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 5DB663858408 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 5DB663858408 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1712937933; cv=none; b=GE/NtCAaRodX5lKl23wrKib01AOtBo2ku1Pe8WVv3RTzMjKaNbRKkDDO1QnUmkEPyKReNVnGQvL5WQZe7JFpKyGadkrCuIgqqdZwjrBvOUHu51qeyaAq7rc1heoyms2C2rADEctUX9OblrUqKSVt2zT7RVP4EmpvHRM2GVGQJBo= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1712937933; c=relaxed/simple; bh=Han5kP70tu2YWEIWkLCopJ/s+/bj9Onrhs8pOTzhsqo=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=digA6//9KYGv1eVMgnU0NxCGGIIl1nLaQNrqroUOCspMKQq0gcgzN8A5Qcf+gmZdOQTB0SgzKeNTURH9XlDoQZc2e3MvuYchWSXAW0U2RD5Joz4T+tCjnex8//thK0uI24PGd332xiiEm1hp9zBfwqqx+L9MWX+JDOhTsNsfK+M= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1712937931; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=Zj4BN3VHHCQI/wxkRmLPWl3X4wiUeruQXdjLxOu9z68=; b=KAZf+jSHRfjZ3yMR+15O7hay+M3b/dmIRTBX7AWoGqJWeC/dJ5M8UBb+7F/U2U7CGtO1Dg eI1luG8JSlPqBqLiWpRXsmnopblc2mPry7P4p5OzdSZkIpeELiC2Hn1A0FHJpf+yF7VHb5 AJ5tKIAJSP0jFSMR+JpvO47m0P5ZyPQ= Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-130-qx-idkCiNViJDnIAtz7tjw-1; Fri, 12 Apr 2024 12:05:29 -0400 X-MC-Unique: qx-idkCiNViJDnIAtz7tjw-1 Received: by mail-wm1-f69.google.com with SMTP id 5b1f17b1804b1-415591b1500so4919405e9.3 for ; Fri, 12 Apr 2024 09:05:29 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712937927; x=1713542727; h=mime-version:message-id:date:references:in-reply-to:subject:to:from :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=Zj4BN3VHHCQI/wxkRmLPWl3X4wiUeruQXdjLxOu9z68=; b=hjKQ7PYBh1+xFjHafLX46tlHqE8g0WUZOT79wbBAKHol03sVsZ0G5lUgIEczgdhBLl Jt+T7jLjD6Njcb0IFKLAFic2xDH6877VCJr8KhpIP5y7DKiuC8xQ3DmhD+1PzoTvvC4w 9cBvH1cMYzoP2dArA5V5d8CxL4/MbeZbuiz7GKN6U9RPA23RYlLIvQ3504jBQ9UqCNNP 2H0yPkMLLsoCmI+6E7YfjLfFcxSRqg/+qIT8iAne4WNSGmji6zxxl3N1axS8SRwhej5/ cEZXHdpS3lQcpGODbeyI9GJjo920sHIJzIRdHI2LzFakNJbj6/98YXW4lmnC1kM5vuu6 4NuQ== X-Forwarded-Encrypted: i=1; AJvYcCWm5UQGtM7/1UV2bXHbhFjXi2mwkM9zPBB5qyhwfCuukHtm0YFlg+ma6j+AXL3aL18k1qnAijpeusgtlSgboR7yQFVhg+1GzeQxXg== X-Gm-Message-State: AOJu0YweneHd2SXxFU8n/um0b8oSsnQd6+OJkEdwtUTByRZISYpUsu1h Pc7DaKRpbxMUxwbkkwetdUr0Yv9CPpxnF39XusB6O/yAMTmwRZkbAEVrWKFzQela/7kdGq4fERl txKhaa4Q0MRcSAgTSkbl3aoYq367KG5abBqgRZ70d7RbL6JluhTWBBcGQTkrKQB5H8hg= X-Received: by 2002:a05:600c:3511:b0:417:e709:1495 with SMTP id h17-20020a05600c351100b00417e7091495mr2443983wmq.14.1712937927410; Fri, 12 Apr 2024 09:05:27 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHEQTZ6j41/jzFYH6EuQ+Lr/MlQGvLSRXoBoQkfpy3pZxeFAgXmRYxl6p+4RSk5KpoIXTtfCQ== X-Received: by 2002:a05:600c:3511:b0:417:e709:1495 with SMTP id h17-20020a05600c351100b00417e7091495mr2443962wmq.14.1712937926870; Fri, 12 Apr 2024 09:05:26 -0700 (PDT) Received: from localhost (185.223.159.143.dyn.plus.net. [143.159.223.185]) by smtp.gmail.com with ESMTPSA id di7-20020a0560000ac700b003439d2a5f99sm4540616wrb.55.2024.04.12.09.05.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Apr 2024 09:05:26 -0700 (PDT) From: Andrew Burgess To: Pedro Alves , gdb-patches@sourceware.org Subject: Re: [PATCH] gdb/linux-nat: Fix mem access ptrace fallback (PR threads/31579) In-Reply-To: <20240411113941.204268-1-pedro@palves.net> References: <20240411113941.204268-1-pedro@palves.net> Date: Fri, 12 Apr 2024 17:05:25 +0100 Message-ID: <8734rq5zy2.fsf@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain X-Spam-Status: No, score=-13.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: Pedro Alves writes: > > diff --git a/gdb/linux-nat.c b/gdb/linux-nat.c > index 2602e1f240d..d2b9aea724d 100644 > --- a/gdb/linux-nat.c > +++ b/gdb/linux-nat.c > @@ -2199,6 +2199,21 @@ mark_lwp_dead (lwp_info *lp, int status) > lp->stopped = 1; > } > > +/* Return true if LP is dead, with a pending exit/signalled event. */ > + > +static bool > +is_lwp_marked_dead (lwp_info *lp) > +{ > + switch (lp->waitstatus.kind ()) > + { > + case TARGET_WAITKIND_EXITED: > + case TARGET_WAITKIND_THREAD_EXITED: > + case TARGET_WAITKIND_SIGNALLED: > + return true; > + } > + return false; > +} I wonder if this would be better as a method on waitstatus? There's at least one place in infrun.c (in handle_one) where we check for these three statuses, and there's a few places where we check TARGET_WAITKIND_EXITED and TARGET_WAITKIND_SIGNALLED ... and I suspect we either _should_ be checking for TARGET_WAITKIND_THREAD_EXITED, or it wouldn't matter if we did. Not that I'm suggesting you should look at all those ... just I'm wondering if it would be better to make is_lwp_marked_dead a waitstatus method now, and we can then clean up other users later? Consider this an optional suggestion, we can always make this a method later if needed. > + > /* Wait for LP to stop. Returns the wait status, or 0 if the LWP has > exited. */ > > @@ -3879,6 +3894,20 @@ linux_proc_xfer_memory_partial (int pid, gdb_byte *readbuf, > const gdb_byte *writebuf, ULONGEST offset, > LONGEST len, ULONGEST *xfered_len); > > +/* Look for an LWP of PID that we know is ptrace-stopped. Returns > + NULL if none is found. */ s/NULL/nullptr/ ? Approved-By: Andrew Burgess Thanks, Andrew