From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 107262 invoked by alias); 25 May 2018 14:31:45 -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 107234 invoked by uid 89); 25 May 2018 14:31:43 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.9 required=5.0 tests=AWL,BAYES_00,SPF_HELO_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mx1.redhat.com Received: from mx3-rdu2.redhat.com (HELO mx1.redhat.com) (66.187.233.73) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 25 May 2018 14:31:37 +0000 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 545477C6B3 for ; Fri, 25 May 2018 14:31:35 +0000 (UTC) Received: from [127.0.0.1] (ovpn04.gateway.prod.ext.ams2.redhat.com [10.39.146.4]) by smtp.corp.redhat.com (Postfix) with ESMTP id C7AD3111AF3B; Fri, 25 May 2018 14:31:34 +0000 (UTC) Subject: Re: [RFC][PATCH v3] Consolidate gdbserver global variables To: Stan Cox , gdb-patches@sourceware.org References: <3153f899-a653-9372-72fd-25ea874f7d3c@redhat.com> <44875dda-adc6-d9a4-940c-0c27aeac574b@redhat.com> <6a41763b-6949-2d32-37fa-9d3f1afceec1@redhat.com> <7d9764b6-d95a-96b4-b064-27ce539327cf@redhat.com> <9988957e-3bf8-cbe8-6c08-58706b11bd60@redhat.com> <9e844707-a2f8-c969-4d09-7ee2fa3bd1ed@redhat.com> From: Pedro Alves Message-ID: <5a41d41f-a0ce-2941-c759-fb1854a1792c@redhat.com> Date: Fri, 25 May 2018 15:01:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 MIME-Version: 1.0 In-Reply-To: <9e844707-a2f8-c969-4d09-7ee2fa3bd1ed@redhat.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-SW-Source: 2018-05/txt/msg00666.txt.bz2 On 05/08/2018 09:58 PM, Stan Cox wrote: > (Addressed formatting and ChangeLog issues) Thanks. This is looking great now. Some comments below, but no need for another round of review. > >> As mentioned, I'm skeptical of all client_state references >> in the backends. >> >> How will this work with multiple clients?   What if one client >> wants exec events, and the other one doesn't?  This seems to >> suggest that the backends need to enable exec events if _any_ >> client wants them (or unconditionally), and then filter out exec >> events at a higher level, before reporting the event to >> each client? > > Perhaps filtering that is roughly analogous to the way > gdb_catch_this_syscall_p filters for particular syscalls. > >> This "= 0" is a spurious change.  Remove it. > > Removed (it eliminated a compiler warning with gcc 7.3.1) You mean, without the change, we trigger a warning? What does it look like? If we do, then we'll need to address it somehow, of course, given -Werror. But I'd like to see it first. > Tested on linux with native-gdbserver. > > Add client_state struct. > > Collect per client specific global data items into struct client_state, > which is similar in purpose to remote.c::remote_state. > @@ -1835,6 +1820,7 @@ handle_qxfer_btrace (const char *annex, >               gdb_byte *readbuf, const gdb_byte *writebuf, >               ULONGEST offset, LONGEST len) >  { > +  client_state &cs = get_client_state (); >    static struct buffer cache; This "static" here made me notice that there is more global state stored as function local static variables that should be moved to client_state. E.g.,: $ nm -A server.o | c++filt | grep " b " | grep "::" server.o:0000000000000700 b guard variable for handle_query(char*, int, int*)::thread_iter server.o:00000000000006f8 b handle_query(char*, int, int*)::thread_iter server.o:00000000000006c0 b handle_qxfer_btrace(char const*, unsigned char*, unsigned char const*, unsigned long long, long long)::cache server.o:00000000000006a0 b handle_qxfer_threads(char const*, unsigned char*, unsigned char const*, unsigned long long, long long)::result_length server.o:0000000000000698 b handle_qxfer_threads(char const*, unsigned char*, unsigned char const*, unsigned long long, long long)::result server.o:00000000000006e0 b handle_qxfer_btrace_conf(char const*, unsigned char*, unsigned char const*, unsigned long long, long long)::cache server.o:00000000000006b0 b handle_qxfer_traceframe_info(char const*, unsigned char*, unsigned char const*, unsigned long long, long long)::result_length server.o:00000000000006a8 b handle_qxfer_traceframe_info(char const*, unsigned char*, unsigned char const*, unsigned long long, long long)::result That can be done as follow up. > @@ -3643,7 +3642,7 @@ captured_main (int argc, char *argv[]) >          } >      } >        else if (strcmp (*next_arg, "--remote-debug") == 0) > -    remote_debug = 1; > +    cs.remote_debug = 1; remote_debug controls whether to print debug output to gdbserver' own terminal, so I'm thinking that it should probably remain a global. Otherwise it looks good to me. If we don't need to handle a warning, then feel free to push this in with the remote_debug issue above addressed. Thanks, Pedro Alves