From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 125195 invoked by alias); 18 Feb 2020 20:52:52 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 125146 invoked by uid 89); 18 Feb 2020 20:52:51 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-8.1 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_NONE,SPF_HELO_PASS autolearn=ham version=3.3.1 spammy=our X-HELO: gateway22.websitewelcome.com Received: from gateway22.websitewelcome.com (HELO gateway22.websitewelcome.com) (192.185.47.100) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 18 Feb 2020 20:52:50 +0000 Received: from cm17.websitewelcome.com (cm17.websitewelcome.com [100.42.49.20]) by gateway22.websitewelcome.com (Postfix) with ESMTP id C6D62A682 for ; Tue, 18 Feb 2020 14:52:48 -0600 (CST) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with SMTP id 49rMjKjyZAGTX49rMjVgWf; Tue, 18 Feb 2020 14:52:48 -0600 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=Content-Type:MIME-Version:Message-ID:In-Reply-To:Date: References:Subject:Cc:To:From:Sender:Reply-To:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=kKNeARCnR9FCZyAEt4ED0yLWHSEduZ+jaVgSqbuV7j0=; b=qYLVrWbqapduYfaX7hePAMr4ns HwGpU5FqG2Su3QRO74uXrVvFRVEICHYhR4i7oKCvo+cZH1MDjc9c5SGU5gcBwgkY0/NCc/RFD5zwc EJWxEveRs8w7KrmV+OmsSHJsc; Received: from 75-166-123-50.hlrn.qwest.net ([75.166.123.50]:49104 helo=murgatroyd) by box5379.bluehost.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.92) (envelope-from ) id 1j49rM-001o3I-Ib; Tue, 18 Feb 2020 13:52:48 -0700 From: Tom Tromey To: Simon Marchi Cc: gdb-patches@sourceware.org, Simon Marchi Subject: Re: [PATCH v3] Pass thread_info pointer to various inferior control functions References: <20200213230428.14476-1-simon.marchi@efficios.com> Date: Tue, 18 Feb 2020 20:52:00 -0000 In-Reply-To: <20200213230428.14476-1-simon.marchi@efficios.com> (Simon Marchi's message of "Thu, 13 Feb 2020 18:04:28 -0500") Message-ID: <87o8tv62jk.fsf@tromey.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-SW-Source: 2020-02/txt/msg00743.txt.bz2 >>>>> "Simon" == Simon Marchi writes: Simon> I noticed that some functions in infcmd and infrun call each other and Simon> all call inferior_thread, while they could just get the thread_info Simon> pointer from their caller. That means less calls to inferior_thread, so Simon> less reliance on global state, since inferior_thread reads Simon> inferior_ptid. ... Simon> -set_step_frame (void) Simon> +set_step_frame (thread_info *tp) Simon> { Simon> frame_info *frame = get_current_frame (); I like the idea of passing parameters rather than relying on global state. However, in its current form, I think this patch may lull the reader into a false sense of security. That is, it makes it seems like these functions operate on a thread that you pass in. However, they don't actually. For example, in this one, I think get_current_frame must be relying on the global inferior_ptid. So, this would change the function from something that obviously has to be relying on globals to something that un-obviously is. I don't know whether that's a reason to reject it or not. It just seemed like maybe a future source of bugs. I do welcome changes to reduce our reliance on globals. Perhaps there's an argument that we can only achieve this incrementally like this. Though, the follow-on question there is whether this is something that will actually happen. Let me know what you think of this. thanks, Tom