From patchwork Mon Oct 26 03:46:34 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Marchi X-Patchwork-Id: 9363 Received: (qmail 12798 invoked by alias); 26 Oct 2015 03:46:57 -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 12730 invoked by uid 89); 26 Oct 2015 03:46:57 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.1 required=5.0 tests=AWL, BAYES_00, SPF_SOFTFAIL autolearn=no version=3.3.2 X-HELO: smtp.electronicbox.net Received: from smtp.electronicbox.net (HELO smtp.electronicbox.net) (96.127.255.83) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 26 Oct 2015 03:46:55 +0000 Received: from simark.lan. (cable-192.222.137.139.electronicbox.net [192.222.137.139]) by smtp.electronicbox.net (Postfix) with ESMTP id AD122440E79; Sun, 25 Oct 2015 23:46:53 -0400 (EDT) From: Simon Marchi To: gdb-patches@sourceware.org Cc: Simon Marchi Subject: [PATCH c++ 02/12] ctf.c: Fix int/enum implicit cast Date: Sun, 25 Oct 2015 23:46:34 -0400 Message-Id: <1445831204-16588-2-git-send-email-simon.marchi@polymtl.ca> In-Reply-To: <1445831204-16588-1-git-send-email-simon.marchi@polymtl.ca> References: <1445831204-16588-1-git-send-email-simon.marchi@polymtl.ca> This patch was taken directly from Pedro's branch. Right now, SET_INT32_FIELD is used to set enum fields. This works in C, but not C++. Therefore, define the new SET_ENUM_FIELD, which casts the value to the right enum type. gdb/ChangeLog: * ctf.c (SET_ENUM_FIELD): New macro. (ctf_read_status): Use it. (ctf_read_tp): Use it. --- gdb/ctf.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/gdb/ctf.c b/gdb/ctf.c index 6c1aede..cb0d707 100644 --- a/gdb/ctf.c +++ b/gdb/ctf.c @@ -914,6 +914,12 @@ ctf_open_dir (const char *dirname) (SCOPE), \ #FIELD)) +#define SET_ENUM_FIELD(EVENT, SCOPE, VAR, TYPE, FIELD) \ + (VAR)->FIELD = (TYPE) bt_ctf_get_int64 (bt_ctf_get_field ((EVENT), \ + (SCOPE), \ + #FIELD)) + + /* EVENT is the "status" event and TS is filled in. */ static void @@ -922,7 +928,7 @@ ctf_read_status (struct bt_ctf_event *event, struct trace_status *ts) const struct bt_definition *scope = bt_ctf_get_top_level_scope (event, BT_EVENT_FIELDS); - SET_INT32_FIELD (event, scope, ts, stop_reason); + SET_ENUM_FIELD (event, scope, ts, enum trace_stop_reason, stop_reason); SET_INT32_FIELD (event, scope, ts, stopping_tracepoint); SET_INT32_FIELD (event, scope, ts, traceframe_count); SET_INT32_FIELD (event, scope, ts, traceframes_created); @@ -1058,7 +1064,7 @@ ctf_read_tp (struct uploaded_tp **uploaded_tps) SET_INT32_FIELD (event, scope, utp, step); SET_INT32_FIELD (event, scope, utp, pass); SET_INT32_FIELD (event, scope, utp, hit_count); - SET_INT32_FIELD (event, scope, utp, type); + SET_ENUM_FIELD (event, scope, utp, enum bptype, type); /* Read 'cmd_strings'. */ SET_ARRAY_FIELD (event, scope, utp, cmd_num, cmd_strings);