From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 101206 invoked by alias); 24 Jan 2020 18:12:21 -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 101198 invoked by uid 89); 24 Jan 2020 18:12:21 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-20.9 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,RCVD_IN_DNSWL_NONE,SPF_HELO_PASS autolearn=ham version=3.3.1 spammy=states, wish X-HELO: gateway30.websitewelcome.com Received: from gateway30.websitewelcome.com (HELO gateway30.websitewelcome.com) (192.185.160.12) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 24 Jan 2020 18:12:19 +0000 Received: from cm13.websitewelcome.com (cm13.websitewelcome.com [100.42.49.6]) by gateway30.websitewelcome.com (Postfix) with ESMTP id 0FDB56E4DD for ; Fri, 24 Jan 2020 12:12:18 -0600 (CST) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with SMTP id v3RJikxFSERZgv3RJicXkN; Fri, 24 Jan 2020 12:12:18 -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=yx8hqwiX41H2hxxJlYUYtx1QsFqz1JwGQVmEuSZUvoE=; b=xwtTwge+ZVGrhktlbGcFkAiYlU XYa3jBNlPBPeyPuOnnibPwWLRHcZaVEOLT8ayIy+rHE23Q5xCzQvkBtWIF3AOLV8SOGsGzB8XwZ4S Xx5SX1XjEelhNT5D3MDEGYDyo; Received: from 75-166-123-50.hlrn.qwest.net ([75.166.123.50]:33822 helo=murgatroyd) by box5379.bluehost.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.92) (envelope-from ) id 1iv3RJ-0000vH-Ia; Fri, 24 Jan 2020 11:12:17 -0700 From: Tom Tromey To: Stan Cox Cc: Tom Tromey , gdb-patches@sourceware.org Subject: Re: [PATCH] add file desc to gdbserver client_state References: <20191122233003.211567-1-cbiesinger@google.com> <8448b37f-ebdf-d2d9-829a-87f7f6ea102c@redhat.com> <87fthnvmxz.fsf@tromey.com> <827a8c5f-e797-58a3-62bf-335e7a44cd9a@redhat.com> Date: Fri, 24 Jan 2020 18:21:00 -0000 In-Reply-To: <827a8c5f-e797-58a3-62bf-335e7a44cd9a@redhat.com> (Stan Cox's message of "Mon, 23 Dec 2019 23:42:05 -0500") Message-ID: <871rroaflr.fsf@tromey.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.3 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-SW-Source: 2020-01/txt/msg00821.txt.bz2 >>>>> "Stan" == Stan Cox writes: Stan> Add struct multi_client_states Stan> * remote-utils.c (remote_desc): Move to struct client_state Stan> (gdb_connected, handle_accept_event, remote_open, putpkt_binary_1) Stan> (putpkt_notif, input_interrupt, block_unblock_async_io) Stan> (nto_conctrl, getpkt): Change remote_desc reference. Stan> * server.c (captured_main): Move remote_desc initialization to Stan> remote_prepare. Thanks for the patch. Stan> diff --git a/gdb/gdbserver/remote-utils.c b/gdb/gdbserver/remote-utils.c Stan> index d7da4b7aed..09095d9bbc 100644 Stan> --- a/gdb/gdbserver/remote-utils.c Stan> +++ b/gdb/gdbserver/remote-utils.c Stan> @@ -25,6 +25,7 @@ Stan> #include "tdesc.h" Stan> #include "debug.h" Stan> #include "dll.h" Stan> +#include "server.h" I think this is already included near the top. Normally, .c files in gdbserver include this first. Stan> + Stan> int Stan> gdb_connected (void) Spurious newline addition. Stan> + struct multi_client_states &client_states = get_client_states(); Needs a space before the "(". Stan> + get_client_states().set_current_client (cs); Ditto. Stan> +/* Container of client remote protocol states for all the currently Stan> + connected clients. */ Stan> + Stan> +#define get_client_state() get_client_states().get_current_client() Stan> + Stan> +class multi_client_states Stan> +{ Stan> +private: Stan> + client_state *current_cs; Stan> + Stan> +public: Stan> + /* Return the current client we are focused on. */ Stan> + client_state &get_current_client () { return *current_cs; } Stan> + Stan> + /* Set the current client we wish to focus on. */ Stan> + void set_current_client (client_state &cs) { current_cs = &cs; } I think this class is a bit strange. It stores a pointer but the set_ method takes a reference. If this class is going to own multiple clients in the future, then I think it makes sense to design the API that way from the start. thanks, Tom