Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Simon Marchi <simon.marchi@polymtl.ca>
To: gdb-patches@sourceware.org
Cc: Simon Marchi <simon.marchi@polymtl.ca>
Subject: [PATCH c++ 02/12] ctf.c: Fix int/enum implicit cast
Date: Mon, 26 Oct 2015 10:03:00 -0000	[thread overview]
Message-ID: <1445831204-16588-2-git-send-email-simon.marchi@polymtl.ca> (raw)
In-Reply-To: <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);
-- 
2.6.2


  parent reply	other threads:[~2015-10-26  3:46 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-10-26  3:49 [PATCH c++ 01/12] Introduce ax_raw_byte and use it Simon Marchi
2015-10-26  4:17 ` [PATCH c++ 03/12] ctf_xfer_partial: Return TARGET_XFER_E_IO instead of -1 on error Simon Marchi
2015-10-27  9:54   ` Simon Marchi
2015-10-26  5:24 ` [PATCH c++ 06/12] Fix constness problem in ioscm_make_gdb_stdio_port Simon Marchi
2015-10-26 12:40   ` Doug Evans
2015-10-26 18:36   ` Pedro Alves
2015-10-27  1:30     ` Simon Marchi
2015-10-27  1:55       ` Pedro Alves
2015-10-27  2:02         ` Doug Evans
2015-10-27  2:07           ` Simon Marchi
2015-10-26  5:27 ` [PATCH c++ 08/12] scm-symbol.c: Add (domain_enum) casts Simon Marchi
2015-10-26 12:55   ` Doug Evans
2015-10-26  5:29 ` [PATCH c++ 05/12] guile: Constify gdbscm_with_guile return value Simon Marchi
2015-10-26 11:45   ` Doug Evans
2015-10-26 17:39     ` Simon Marchi
2015-10-26 20:34       ` Doug Evans
2015-10-27  9:31         ` Simon Marchi
2015-10-27 17:35           ` Doug Evans
2015-10-28 14:59             ` Simon Marchi
2015-10-26  5:30 ` [PATCH c++ 09/12] stap-probe.c: Add casts Simon Marchi
2015-10-27  9:54   ` Simon Marchi
2015-10-26  5:32 ` [PATCH c++ 10/12] symtab.c: Add cast Simon Marchi
2015-10-26 12:55   ` Doug Evans
2015-10-26  7:53 ` [PATCH c++ 04/12] Add scm_t_dynwind_flags casts Simon Marchi
2015-10-27 14:59   ` Pedro Alves
2015-10-27 16:02     ` Simon Marchi
2015-10-26  8:17 ` [PATCH c++ 07/12] gdbscm_memory_port_write: use local variable to avoid adding casts Simon Marchi
2015-10-26 12:55   ` Doug Evans
2015-10-26 10:03 ` Simon Marchi [this message]
2015-10-27 15:17   ` [PATCH c++ 02/12] ctf.c: Fix int/enum implicit cast Pedro Alves
2015-10-27 17:11     ` Yao Qi
2015-10-27 17:14       ` Simon Marchi
2015-10-27 15:08 ` [PATCH c++ 01/12] Introduce ax_raw_byte and use it Pedro Alves
2015-10-27 16:55   ` Simon Marchi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1445831204-16588-2-git-send-email-simon.marchi@polymtl.ca \
    --to=simon.marchi@polymtl.ca \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox