From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 106508 invoked by alias); 13 Apr 2017 02:28:03 -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 105397 invoked by uid 89); 13 Apr 2017 02:28:01 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,RP_MATCHES_RCVD,SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=Maintain, wrapped 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; Thu, 13 Apr 2017 02:27:59 +0000 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 336647E9DE for ; Thu, 13 Apr 2017 02:28:00 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 336647E9DE Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=palves@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 336647E9DE Received: from cascais.lan (ovpn04.gateway.prod.ext.phx2.redhat.com [10.5.9.4]) by smtp.corp.redhat.com (Postfix) with ESMTP id B73AB7DEDF for ; Thu, 13 Apr 2017 02:27:59 +0000 (UTC) From: Pedro Alves To: gdb-patches@sourceware.org Subject: [PATCH 4/5] Don't memset non-POD types: struct btrace_insn Date: Thu, 13 Apr 2017 02:28:00 -0000 Message-Id: <1492050475-9238-5-git-send-email-palves@redhat.com> In-Reply-To: <1492050475-9238-1-git-send-email-palves@redhat.com> References: <1492050475-9238-1-git-send-email-palves@redhat.com> X-SW-Source: 2017-04/txt/msg00380.txt.bz2 struct btrace_insn is not a POD [1] so we shouldn't be using memset to initialize it [2]. Use list-initialization instead, wrapped in a "pt insn to btrace insn" function, which looks like just begging to be added next to the existing pt_reclassify_insn/pt_btrace_insn_flags functions. [1] - because its field "flags" is not POD, because enum_flags has a non-trivial default ctor. gdb/ChangeLog: yyyy-mm-dd Pedro Alves * btrace.c (pt_btrace_insn): New function. (ftrace_add_pt): Remove memset call and use pt_btrace_insn. --- gdb/btrace.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/gdb/btrace.c b/gdb/btrace.c index 95dc7ab..30359b6 100644 --- a/gdb/btrace.c +++ b/gdb/btrace.c @@ -1122,6 +1122,17 @@ pt_btrace_insn_flags (const struct pt_insn *insn) return flags; } +/* Return the btrace instruction for INSN. */ + +static btrace_insn +pt_btrace_insn (const struct pt_insn &insn) +{ + return {(CORE_ADDR) insn.ip, (gdb_byte) insn.size, + pt_reclassify_insn (insn.iclass), + pt_btrace_insn_flags (&insn)}; +} + + /* Add function branch trace using DECODER. */ static void @@ -1138,7 +1149,6 @@ ftrace_add_pt (struct pt_insn_decoder *decoder, end = *pend; for (;;) { - struct btrace_insn btinsn; struct pt_insn insn; errcode = pt_insn_sync_forward (decoder); @@ -1150,7 +1160,6 @@ ftrace_add_pt (struct pt_insn_decoder *decoder, break; } - memset (&btinsn, 0, sizeof (btinsn)); for (;;) { errcode = pt_insn_next (decoder, &insn, sizeof(insn)); @@ -1207,11 +1216,7 @@ ftrace_add_pt (struct pt_insn_decoder *decoder, /* Maintain the function level offset. */ *plevel = std::min (*plevel, end->level); - btinsn.pc = (CORE_ADDR) insn.ip; - btinsn.size = (gdb_byte) insn.size; - btinsn.iclass = pt_reclassify_insn (insn.iclass); - btinsn.flags = pt_btrace_insn_flags (&insn); - + btrace_insn btinsn = pt_btrace_insn (insn); ftrace_update_insns (end, &btinsn); } -- 2.5.5