From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr1-f53.google.com (mail-wr1-f53.google.com [209.85.221.53]) by sourceware.org (Postfix) with ESMTPS id 350733858CD1 for ; Fri, 14 Jul 2023 19:18:27 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 350733858CD1 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=palves.net Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-wr1-f53.google.com with SMTP id ffacd0b85a97d-3144098df56so2481034f8f.2 for ; Fri, 14 Jul 2023 12:18:27 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689362306; x=1691954306; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=FH1BKXbXxFeq3EHkDFCcqt5kupspIuskcN3/ifcFjIc=; b=cJTq2oefZvN4NcHd75nNheatBwHEOkTihRjYX2tAsKCFEODSfotdiTVjXF6O9oS03+ Q33KbjJ2CPf3x/SMfBxnBe4o3/U/L1VsnOMCcnVlRCP3+Fk3wgRG0ggAaVhvJ0kXkm+3 hz9NndNQ8IOAJAO61eVWxnkKkIFBEOgO/RZXEGDgvaf0SuZYIz3nA/7jpEKXxZccME/r hGccdmum9h+4MzYYgmNRK57XsXuIr9hFMxti70uEDuvQjWz5WvxrmRPlsD0YFGNpWxgp oUi4ipUBMTrXOUMKhZLEDc1U8FmpaI98kWNnXcHLsw2BboIsgdbwuKlxMHq6G+hyu5Ho GHAg== X-Gm-Message-State: ABy/qLYzBFDg0hBpGSF0INaVkg4R5mppprRytDLpHa+sMJjAdwEZ6/rn kX2Ii8kEFR4fw3zrDmnwOTl/9wZSq9w= X-Google-Smtp-Source: APBJJlHsFd0E08hUZQZwMraqLQ05Tg4NW/mQmXiXBEcYHYZZb2DP0OA+aB3hTB2QrLnCnsEFZREF9A== X-Received: by 2002:a5d:66c5:0:b0:316:e073:e547 with SMTP id k5-20020a5d66c5000000b00316e073e547mr4755231wrw.28.1689362305767; Fri, 14 Jul 2023 12:18:25 -0700 (PDT) Received: from ?IPV6:2001:8a0:f91d:bc00:98b3:dfb7:8070:8955? ([2001:8a0:f91d:bc00:98b3:dfb7:8070:8955]) by smtp.gmail.com with ESMTPSA id x14-20020a5d490e000000b0031423a8f4f7sm11610355wrq.56.2023.07.14.12.18.24 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 14 Jul 2023 12:18:25 -0700 (PDT) Message-ID: <31b6963a-6b3a-f18e-9863-40acff23c546@palves.net> Date: Fri, 14 Jul 2023 20:18:24 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.13.0 Subject: Re: [PATCH] gdb/amd-dbgapi-target: Use inf param in detach Content-Language: en-US To: Lancelot SIX , gdb-patches@sourceware.org Cc: lsix@lancelotsix.com References: <20230616092528.69358-1-lancelot.six@amd.com> <2c7f2ef1-dea2-5dbe-8d3f-b9b885be3b72@palves.net> <05217693-1a01-bffb-e74a-503b3fe3a604@amd.com> From: Pedro Alves In-Reply-To: <05217693-1a01-bffb-e74a-503b3fe3a604@amd.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-3.9 required=5.0 tests=BAYES_00,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,KAM_DMARC_STATUS,NICE_REPLY_A,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On 2023-07-14 19:54, Lancelot SIX wrote: > On 14/07/2023 19:35, Pedro Alves wrote: >> IMO this is a case of the target method's inferior * parameter having >> been added too soon -- it would only make sense to have it if nothing in >> the body of the target method implementations is relying on inf being >> current_inferior on entry.  But that is not the case, plenty of target_ops::detach >> code has that assumption.  The presence of an explicit inferior pointer should mean >> that detach target method implementations that call code that depends >> on the inferior being the current inferior, should be using a >> scoped_restore_current_thread/inferior before calling such global-state-assuming >> code.  But, they don't do that, instead, we have this mixed situation.  IMO, it would >> be better to remove the parameter to avoid confusion and stick to the >> (if explicit param, then switch global state to it if you need it) rule. >> >> Anyhow, your patch doesn't make it worse, so it's fine with me. >> > > I can also go the other way around and always use `current_inferior ()` instead of the `inf` parameter in this detach implementation. > > What bugged me here is the inconsistency from one line to the next. > Please go ahead and merge your patch. I quickly looked at what it would like to remove the parameter throughout, and I think we'd just end up doing: inferior *inf = current_inferior (); at the top of the function, so using "inf" in the remove_breakpoints_inf call anyhow, as we have multiple references to the current inferior. Pedro Alves