From patchwork Wed Jun 20 21:08:55 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: pedromfc X-Patchwork-Id: 27953 Received: (qmail 18069 invoked by alias); 20 Jun 2018 21:09:32 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 17890 invoked by uid 89); 20 Jun 2018 21:09:31 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-27.6 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_LOW, TIME_LIMIT_EXCEEDED autolearn=unavailable version=3.3.2 spammy=throwing, resize, 10869 X-HELO: mx0a-001b2d01.pphosted.com Received: from mx0a-001b2d01.pphosted.com (HELO mx0a-001b2d01.pphosted.com) (148.163.156.1) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 20 Jun 2018 21:09:21 +0000 Received: from pps.filterd (m0098399.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w5KKs0I1031888 for ; Wed, 20 Jun 2018 17:09:19 -0400 Received: from e31.co.us.ibm.com (e31.co.us.ibm.com [32.97.110.149]) by mx0a-001b2d01.pphosted.com with ESMTP id 2jqvwx3qh4-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Wed, 20 Jun 2018 17:09:19 -0400 Received: from localhost by e31.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 20 Jun 2018 15:09:18 -0600 Received: from b03cxnp08027.gho.boulder.ibm.com (9.17.130.19) by e31.co.us.ibm.com (192.168.1.131) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Wed, 20 Jun 2018 15:09:16 -0600 Received: from b03ledav004.gho.boulder.ibm.com (b03ledav004.gho.boulder.ibm.com [9.17.130.235]) by b03cxnp08027.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w5KL9DkY9371936 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Wed, 20 Jun 2018 14:09:14 -0700 Received: from b03ledav004.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id CA82178064; Wed, 20 Jun 2018 15:09:13 -0600 (MDT) Received: from b03ledav004.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 95CC67805F; Wed, 20 Jun 2018 15:09:13 -0600 (MDT) Received: from pedro.localdomain (unknown [9.18.235.95]) by b03ledav004.gho.boulder.ibm.com (Postfix) with ESMTP; Wed, 20 Jun 2018 15:09:13 -0600 (MDT) Received: by pedro.localdomain (Postfix, from userid 1000) id 08A9B3C042F; Wed, 20 Jun 2018 18:09:11 -0300 (-03) From: Pedro Franco de Carvalho To: gdb-patches@sourceware.org Cc: uweigand@de.ibm.com Subject: [PATCH 4/4] Variable size for regs mask in collection list Date: Wed, 20 Jun 2018 18:08:55 -0300 In-Reply-To: <20180620210855.6385-1-pedromfc@linux.vnet.ibm.com> References: <20180620210855.6385-1-pedromfc@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 18062021-8235-0000-0000-00000DC4FB4C X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00009229; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000265; SDB=6.01049879; UDB=6.00537992; IPR=6.00828851; MB=3.00021765; MTD=3.00000008; XFM=3.00000015; UTC=2018-06-20 21:09:17 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18062021-8236-0000-0000-0000419902A5 Message-Id: <20180620210855.6385-5-pedromfc@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2018-06-20_09:, , signatures=0 X-IsSubscribed: yes This patch changes collection_list to allow larger register masks. The mask is changed from an array to a vector and is initialized with num_regs + num_pseudoregs. Although no pseudoreg numbers should be set in the mask, some parts of collection_list still do this. The mask is also resized as needed when new registers are added to the mask. YYYY-MM-DD Pedro Franco de Carvalho * tracepoint.h (collection_list) : Change type to std::vector. * tracepoint.c (collection_list::collection_list): Remove m_regs_mask initializer from initializer list. Resize m_regs_mask in using the number of registers from the arch. (collection_list::add_register): Resize m_regs_mask instead of throwing error when regno is too large. (collection_list::stringify): Use size () instead of sizeof. Use xsnprintf instead of sprintf. --- gdb/tracepoint.c | 28 +++++++++++++++++++++------- gdb/tracepoint.h | 2 +- 2 files changed, 22 insertions(+), 8 deletions(-) diff --git a/gdb/tracepoint.c b/gdb/tracepoint.c index 5af3cfe202..2cffc0251e 100644 --- a/gdb/tracepoint.c +++ b/gdb/tracepoint.c @@ -818,9 +818,10 @@ collection_list::add_register (unsigned int regno) { if (info_verbose) printf_filtered ("collect register %d\n", regno); - if (regno >= (8 * sizeof (m_regs_mask))) - error (_("Internal: register number %d too large for tracepoint"), - regno); + + if (regno / 8 >= m_regs_mask.size ()) + m_regs_mask.resize ((regno / 8) + 1); + m_regs_mask[regno / 8] |= 1 << (regno % 8); } @@ -1086,9 +1087,21 @@ collection_list::add_static_trace_data () } collection_list::collection_list () - : m_regs_mask (), - m_strace_data (false) + : m_strace_data (false) { + /* Guess the number of bytes needed for the register mask. If it's + too low, it will be expanded in add_register. If it's too high, + stringify will ignore the extra bytes. + + The mask shouldn't include pseudoreg numbers, but + encode_actions_1 currently doesn't handle remote register numbers + and pseudoregs properly for tracepoint actions that don't + generate an AX (e.g. "collect $"). */ + int num_regs = gdbarch_num_regs (target_gdbarch ()) + + gdbarch_num_pseudo_regs (target_gdbarch ()); + + m_regs_mask.resize ((num_regs / 8) + 1); + m_memranges.reserve (128); m_aexprs.reserve (128); } @@ -1113,7 +1126,7 @@ collection_list::stringify () str_list.emplace_back (temp_buf, end - temp_buf); } - for (i = sizeof (m_regs_mask) - 1; i > 0; i--) + for (i = m_regs_mask.size () - 1; i > 0; i--) if (m_regs_mask[i] != 0) /* Skip leading zeroes in regs_mask. */ break; if (m_regs_mask[i] != 0) /* Prepare to send regs_mask to the stub. */ @@ -1127,7 +1140,8 @@ collection_list::stringify () QUIT; /* Allow user to bail out with ^C. */ if (info_verbose) printf_filtered ("%02X", m_regs_mask[i]); - sprintf (end, "%02X", m_regs_mask[i]); + xsnprintf (end, sizeof (temp_buf) - (end - temp_buf), + "%02X", m_regs_mask[i]); end += 2; } str_list.emplace_back (temp_buf); diff --git a/gdb/tracepoint.h b/gdb/tracepoint.h index 42e413018a..59279a73ef 100644 --- a/gdb/tracepoint.h +++ b/gdb/tracepoint.h @@ -289,7 +289,7 @@ public: private: /* room for up to 256 regs */ - unsigned char m_regs_mask[32]; + std::vector m_regs_mask; std::vector m_memranges;