From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 26233 invoked by alias); 25 Jun 2018 10:37:28 -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 26217 invoked by uid 89); 25 Jun 2018 10:37:28 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.8 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.2 spammy=UD:data, Hx-languages-length:1643, agent X-HELO: mx0a-001b2d01.pphosted.com Received: from mx0b-001b2d01.pphosted.com (HELO mx0a-001b2d01.pphosted.com) (148.163.158.5) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 25 Jun 2018 10:37:26 +0000 Received: from pps.filterd (m0098420.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w5PAXfb6114009 for ; Mon, 25 Jun 2018 06:37:25 -0400 Received: from e06smtp07.uk.ibm.com (e06smtp07.uk.ibm.com [195.75.94.103]) by mx0b-001b2d01.pphosted.com with ESMTP id 2jtwuaaj5w-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Mon, 25 Jun 2018 06:37:25 -0400 Received: from localhost by e06smtp07.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 25 Jun 2018 11:37:23 +0100 Received: from b06cxnps4076.portsmouth.uk.ibm.com (9.149.109.198) by e06smtp07.uk.ibm.com (192.168.101.137) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Mon, 25 Jun 2018 11:37:21 +0100 Received: from d06av24.portsmouth.uk.ibm.com (d06av24.portsmouth.uk.ibm.com [9.149.105.60]) by b06cxnps4076.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w5PAbK6w26804356 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 25 Jun 2018 10:37:20 GMT Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 8FF484203F; Mon, 25 Jun 2018 11:37:15 +0100 (BST) Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 7F70442041; Mon, 25 Jun 2018 11:37:15 +0100 (BST) Received: from oc3748833570.ibm.com (unknown [9.152.213.77]) by d06av24.portsmouth.uk.ibm.com (Postfix) with ESMTP; Mon, 25 Jun 2018 11:37:15 +0100 (BST) Received: by oc3748833570.ibm.com (Postfix, from userid 1000) id 2F6DAD801CC; Mon, 25 Jun 2018 12:37:20 +0200 (CEST) Subject: Re: [PATCH 3/4] Use get_remote_packet_size in download_tracepoint To: pedromfc@linux.vnet.ibm.com (Pedro Franco de Carvalho) Date: Mon, 25 Jun 2018 10:37:00 -0000 From: "Ulrich Weigand" Cc: gdb-patches@sourceware.org In-Reply-To: <20180620210855.6385-4-pedromfc@linux.vnet.ibm.com> from "Pedro Franco de Carvalho" at Jun 20, 2018 06:08:54 PM MIME-Version: 1.0 X-TM-AS-GCONF: 00 x-cbid: 18062510-0028-0000-0000-000002D49A73 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18062510-0029-0000-0000-0000238BF87F Message-Id: <20180625103720.2F6DAD801CC@oc3748833570.ibm.com> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 8bit X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2018-06-25_05:,, signatures=0 X-SW-Source: 2018-06/txt/msg00575.txt.bz2 Pedro Franco de Carvalho wrote: > * remote.c (remote_target::download_tracepoint): Remove BUF_SIZE > and pkt. Replace array buf with gdb::char_vector buf, of size > get_remote_packet_size (). Replace references to buf and BUF_SIZE > to buf.data () and buf.size (). Replace strcpy, strcat and > pack_hex_byte with xsnprintf. This makes sense in general, but I'm not sure it makes sense to use a separate hex_byte buffer here: > { > agent_expr_up aexpr = gen_eval_for_expr (tpaddr, loc->cond.get ()); > - xsnprintf (buf + strlen (buf), BUF_SIZE - strlen (buf), ":X%x,", > + xsnprintf (buf.data () + strlen (buf.data ()), > + buf.size () - strlen (buf.data ()), ":X%x,", > aexpr->len); > - pkt = buf + strlen (buf); > + > + char *end = buf.data () + strlen (buf.data ()); > + long size_left = buf.size () - strlen (buf.data ()); > + char hex_byte[3]; > + hex_byte[2] = '\0'; > + > for (int ndx = 0; ndx < aexpr->len; ++ndx) > - pkt = pack_hex_byte (pkt, aexpr->buf[ndx]); > - *pkt = '\0'; > + { > + pack_hex_byte (hex_byte, aexpr->buf[ndx]); > + xsnprintf (end, size_left, hex_byte); > + > + size_left -= strlen (end); > + end += strlen (end); > + } > } You know from the beginning that the agent expression will take (2 * aexpr->len) bytes, so it should be OK to only check this once, ahead of time. In fact, sending a partial agent expression seems to be worse than sending none, so if the agent expression is too long, I think it should be just omitted (and the user warned). Bye, Ulrich -- Dr. Ulrich Weigand GNU/Linux compilers and toolchain Ulrich.Weigand@de.ibm.com