From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 103009 invoked by alias); 15 Sep 2017 10:55:15 -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 102995 invoked by uid 89); 15 Sep 2017 10:55:14 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-11.9 required=5.0 tests=BAYES_00,GIT_PATCH_2,GIT_PATCH_3,RP_MATCHES_RCVD,SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=research X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 15 Sep 2017 10:55:13 +0000 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id D3CF0552F1; Fri, 15 Sep 2017 10:55:11 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com D3CF0552F1 Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=palves@redhat.com 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 3761960462; Fri, 15 Sep 2017 10:55:11 +0000 (UTC) Subject: Re: [PATCH 2/3] gdbserver: Remove gdb_id_to_thread_id To: Simon Marchi , gdb-patches@sourceware.org References: <1505074275-1662-1-git-send-email-simon.marchi@ericsson.com> <1505074275-1662-3-git-send-email-simon.marchi@ericsson.com> From: Pedro Alves Message-ID: Date: Fri, 15 Sep 2017 10:55:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 MIME-Version: 1.0 In-Reply-To: <1505074275-1662-3-git-send-email-simon.marchi@ericsson.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit X-SW-Source: 2017-09/txt/msg00398.txt.bz2 On 09/10/2017 09:11 PM, Simon Marchi wrote: > From what I understand, this function is not doing anything useful as of > today. > > Here's the result of my archeological research: > *nod* > --- a/gdb/gdbserver/server.c > +++ b/gdb/gdbserver/server.c > @@ -4011,7 +4011,6 @@ process_serial_event (void) > unsigned int len; > int res; > CORE_ADDR mem_addr; > - int pid; > unsigned char sig; > int packet_len; > int new_packet_len = -1; > @@ -4039,92 +4038,96 @@ process_serial_event (void) > handle_general_set (own_buf); > break; > case 'D': > - require_running (own_buf); > + { > + require_running (own_buf); > The reindentation makes it hard to see the actual change. Is it just moving the int pid variable, or something else? IMO, it'd be nicer to move the whole case 'D' body to a handle_detach function. > case '!': > extended_protocol = 1; > write_ok (own_buf); > @@ -4135,23 +4138,18 @@ process_serial_event (void) > case 'H': > if (own_buf[1] == 'c' || own_buf[1] == 'g' || own_buf[1] == 's') > { > - ptid_t gdb_id, thread_id; > - int pid; > + ptid_t thread_id; > > require_running (own_buf); > > - gdb_id = read_ptid (&own_buf[2], NULL); > - > - pid = ptid_get_pid (gdb_id); > + thread_id = read_ptid (&own_buf[2], NULL); Move ptid_t declaration here? : ptid_t thread_id = read_ptid (&own_buf[2], NULL); > > - if (ptid_equal (gdb_id, null_ptid) > - || ptid_equal (gdb_id, minus_one_ptid)) > + if (thread_id == null_ptid || thread_id == minus_one_ptid) > thread_id = null_ptid; This can be just: if (thread_id == minus_one_ptid) thread_id = null_ptid; > - else if (pid != 0 > - && ptid_equal (pid_to_ptid (pid), > - gdb_id)) > + else if (thread_id.is_pid ()) > { > - thread_info *thread = find_any_thread_of_pid (pid); > + /* The ptid represents a pid. */ > + thread_info *thread = find_any_thread_of_pid (thread_id.pid ()); > > if (thread == NULL) > { > @@ -4163,8 +4161,8 @@ process_serial_event (void) > } > else > { > - thread_id = gdb_id_to_thread_id (gdb_id); > - if (ptid_equal (thread_id, null_ptid)) > + /* The ptid represents a lwp/tid. */ > + if (find_thread_ptid (thread_id) == NULL) > { > write_enn (own_buf); > break; > @@ -4369,13 +4367,12 @@ process_serial_event (void) > > case 'T': > { > - ptid_t gdb_id, thread_id; > + ptid_t thread_id; > > require_running (own_buf); > > - gdb_id = read_ptid (&own_buf[1], NULL); > - thread_id = gdb_id_to_thread_id (gdb_id); > - if (ptid_equal (thread_id, null_ptid)) > + thread_id = read_ptid (&own_buf[1], NULL); ptid_t thread_id = ... ? > + if (find_thread_ptid (thread_id) == NULL) > { > write_enn (own_buf); > break; > Thanks, Pedro Alves