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.129.124]) by sourceware.org (Postfix) with ESMTPS id 097D1385843D for ; Wed, 22 Mar 2023 21:29:27 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 097D1385843D Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1679520566; 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=tkYRRTjxwR0+uMlTPIQUaCddaOU+Cs+eX4Xb+J317bc=; b=WUFVsZfYFfe5kHEgRSAJJINJTgIoIS2CUBb585dP9r5S68X8aNqyE9BfSOK8AEV19uuzGK slX4112iFLBLfuniWEX4QX69Q4Ze7ZaPVnDEPYYAtEo+mtegZo0z62JPgXB9Rn19rKqdPY Wq0nXwP0ar2Mqsjbk7yumJE8P7o5jyg= Received: from mail-qt1-f200.google.com (mail-qt1-f200.google.com [209.85.160.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-403-eu-weQUjNCKtGuI11-OCOQ-1; Wed, 22 Mar 2023 17:29:24 -0400 X-MC-Unique: eu-weQUjNCKtGuI11-OCOQ-1 Received: by mail-qt1-f200.google.com with SMTP id h6-20020a05622a170600b003e22c6de617so6152419qtk.13 for ; Wed, 22 Mar 2023 14:29:24 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679520563; 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=tkYRRTjxwR0+uMlTPIQUaCddaOU+Cs+eX4Xb+J317bc=; b=GIG93N3qaqIX2m4K2yEj6aIOnYFAv3MVe+8UnBIpY+am/AzxDqUiR3tNO7lDIvuYpJ Mu9B5+GuhzKlTylfnkEH9SGX4mYZerooMKZVazJpDDuc0UGWQSpWg6T3mhWPzZqWjJ6k krpAzzqYtbWrR2GSgzEuWY0eQvAyivE1Q4nIKTNO83thZIFhAYvP8wwfHheKLTjSI+PQ uCpT7mNA7pfO2U7jBxOZCehHX/1syTcmgksOCl9Zn/Y1TquChL0/Nn0PuH1YpYZeZcrk Jf7nVbEXV3kb9U1K2aAY8GdktIDmHutc0JJ8jOULrwxJgsh3u8ZIBmmA4ld28sz8bzWP /9Rw== X-Gm-Message-State: AO0yUKX3e7lPQ9Dwll/nAJmCuvL6SqGHxsuVmjMoNYmoXt5Ko5y1tK5W tMTQlm3y7A0pWVgPmcW6XCVZH1ftSqcACwk0C6eYz5DJbuZX1EDPq/27iqSNB0pbPU7O6ol9Wg/ LdGlZTlQ2/PPERoKpVy2yY4d4ksb9hw== X-Received: by 2002:a05:622a:83:b0:3d5:500a:4809 with SMTP id o3-20020a05622a008300b003d5500a4809mr9855254qtw.26.1679520563625; Wed, 22 Mar 2023 14:29:23 -0700 (PDT) X-Google-Smtp-Source: AK7set8cySse4Nu8SsOUXfhlWrDcYQIXDUgXWMNurzdYcHrUpz1cb4f4BvZoyTaFexA/xh8LOYqLxQ== X-Received: by 2002:a05:622a:83:b0:3d5:500a:4809 with SMTP id o3-20020a05622a008300b003d5500a4809mr9855232qtw.26.1679520563301; Wed, 22 Mar 2023 14:29:23 -0700 (PDT) Received: from localhost (95.72.115.87.dyn.plus.net. [87.115.72.95]) by smtp.gmail.com with ESMTPSA id 11-20020a37060b000000b0071d0f1d01easm5955738qkg.57.2023.03.22.14.29.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Mar 2023 14:29:22 -0700 (PDT) From: Andrew Burgess To: Pedro Alves , gdb-patches@sourceware.org Subject: Re: [PATCH 01/31] displaced step: pass down target_waitstatus instead of gdb_signal In-Reply-To: <87zg8cel2d.fsf@redhat.com> References: <20221212203101.1034916-1-pedro@palves.net> <20221212203101.1034916-2-pedro@palves.net> <87fsbnrpss.fsf@redhat.com> <87zg8cel2d.fsf@redhat.com> Date: Wed, 22 Mar 2023 21:29:21 +0000 Message-ID: <877cv8cw5q.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=-5.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,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: Andrew Burgess writes: > Pedro Alves writes: > >> On 2023-02-03 10:44 a.m., Andrew Burgess wrote: >>> Pedro Alves writes: >>> >>>> This commit tweaks displaced_step_finish & friends to pass down a >>>> target_waitstatus instead of a gdb_signal. This needed because a >>> >>> missing word: "This IS needed". >> >> Fixed. >> >>>> @@ -5699,7 +5696,7 @@ handle_inferior_event (struct execution_control_state *ecs) >>>> has been done. Perform cleanup for parent process here. Note >>>> that this operation also cleans up the child process for vfork, >>>> because their pages are shared. */ >>>> - displaced_step_finish (ecs->event_thread, GDB_SIGNAL_TRAP); >>>> + displaced_step_finish (ecs->event_thread, ecs->ws); >>> >>> This change is interesting. >>> >>> If I understand the code correctly, this call will eventually end up in >>> displaced_step_buffers::finish (displaced-stepping.c), which in turn >>> calls displaced_step_instruction_executed_successfully. >>> >>> Previously, we always passed GDB_SIGNAL_TRAP here, which (if we ignore >>> the watchpoint check in >>> displaced_step_instruction_executed_successfully) means that >>> displaced_step_instruction_executed_successfully would always return >>> true, and then displaced_step_buffers::finish would call >>> gdbarch_displaced_step_fixup. >>> >>> After this change, we know that esc->ws.kind is either >>> TARGET_WAITKIND_FORKED or TARGET_WAITKIND_VFORKED, so we know that >>> displaced_step_instruction_executed_successfully will always return >>> false, and displaced_step_buffers::finish will no longer call >>> gdbarch_displaced_step_fixup. >>> >> >> Good catch! >> >> I was tweaking the change to address your comment, and was coming to the >> conclusion that what I really wanted was this: >> >> static bool >> displaced_step_instruction_executed_successfully >> (gdbarch *arch, const target_waitstatus &status) >> { >> if (status.kind () == TARGET_WAITKIND_STOPPED >> && status.sig () != GDB_SIGNAL_TRAP) >> return false; >> >> /* All other waitkinds can only happen if the instruction fully >> executed. For example, a fork, or a syscall entry can only >> happen if the syscall instruction actually executed. */ >> >> (the comment is new) >> >> And then, I remembered, I actually wrote that early if like that originally, >> and I changed it in response to this review: >> >> https://inbox.sourceware.org/gdb-patches/44f74af8-248b-1af8-3612-980c08607bf4@simark.ca/ >> >> The review was totally right, it was my response that was misguided. >> >> But I'm confused because I am pretty sure that I wrote a reply to that >> message, saying that I did not intend to change the behavior, so I'd "fix" it. >> I can't find it in my outbox either, I guess I erroneously canceled my >> email window instead of sending the message... >> >> Anyhow, looks like I made it worse while trying to address Simon's comment. :-P >> >> So I think I should go back to what I had, like before, and my response >> to Simon should have been instead: >> >> - yes, the change is intended. If we stopped for an event other than >> TARGET_WAITKIND_STOPPED, like for instance, TARGET_WAITKIND_FORKED, >> TARGET_WAITKIND_SYSCALL_ENTRY, then it must be that the instruction >> executed successfully, otherwise the syscall wouldn't have triggered. >> >>> What I don't understand well enough is what this actually means for a >>> running inferior. >>> >>> It's odd because the comment in infrun.c (just above your change) >>> indicates that to get to this point the displaced step must have >>> completed successfully, while after this change, the new code path in >>> displaced_step_buffers::finish indicates we believe the displaced step >>> didn't complete successfully: >>> >>> /* Since the instruction didn't complete, all we can do is relocate the >>> PC. */ >>> >>> Do you know if any of our test cases hit this path? >>> >> >> I know that you posted a series for this, which I plan to take a good look >> at (I actually planned on doing that earlier this week, but I had a couple >> major distractions, sorry). >> >> WDYT of the version below? > > I took a look through and I'm happy with it. But I would like you to > consider holding off until my displaced step patch has some feedback. > > I'm currently rebasing the patch. My patch deletes > displaced_step_instruction_executed_successfully, which I realised makes > passing the signal (or now target_waitstatus) redundant. As such I'm > just testing an additional patch in the series which touches every place > you're touching - but removes the signal instead of changing it. > > I hope to post my updated series later today (once testing completes). Pedro, Thanks for your feedback on my displaced stepping series. You're right that just checking the $pc isn't going to be enough. So I'm now thinking that I should be passing the gdb_signal through to the gdbarch_displaced_step_fixup function. Rather than change things to pass through the gdb_signal though, and then have this patch come along and s/gdb_signal/target_waitstatus/, I wonder how you'd feel about merging this patch sooner rather than later? I'm planning to rebase my displaced stepping series off this patch -- I just want to check you'd be OK with this patch possibly landing before the rest of this series? Thanks, Andrew