Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Doug Evans <dje@google.com>
To: Yao Qi <yao@codesourcery.com>
Cc: <gdb-patches@sourceware.org>
Subject: Re: [PATCH v3 06/15] Write status to CTF and read.
Date: Thu, 14 Mar 2013 18:06:00 -0000	[thread overview]
Message-ID: <20802.4537.197713.506858@ruffy2.mtv.corp.google.com> (raw)
In-Reply-To: <1362800844-27940-7-git-send-email-yao@codesourcery.com>

Yao Qi writes:
 > 2013-03-08  Yao Qi  <yao@codesourcery.com>
 > 
 > 	* ctf.c (CTF_EVENT_ID_STATUS, ctf_save_write_int32): New
 > 	macros.
 > 	(ctf_save_metadata_header): Define new type alias in
 > 	metadata.
 > 	(ctf_write_header): Start a new faked packet for trace status.
 > 	(ctf_write_status): Write trace status to CTF.
 > 	(ctf_write_definition_end): End the faked packet.
 > 	(start_pos): New variable.
 > 	(SET_INT32_FIELD): New macro.
 > 	(ctf_read_status): New.
 > 	(ctf_open): Skip the first faked packet and assert on some
 > 	event types.
 > 	(ctf_trace_find): Set the iterator to the beginning of packet
 > 	including trace frames, instead of the first packet.
 > 	(ctf_get_trace_status): New.
 > 	(init_ctf_ops): Install ctf_get_trace_status to field
 > 	'to_get_trace_status'.
 > @@ -747,15 +798,66 @@ ctf_open_dir (char *dirname)
 >  
 >  }
 > [...]
 > +#define SET_INT32_FIELD(EVENT, SCOPE, VAR, FIELD)			\
 > +  VAR->FIELD = (int) bt_ctf_get_int64 (bt_ctf_get_field (EVENT,	\
 > +							SCOPE,		\
 > +							#FIELD))

Macros like this should be in a do { } while (0).
  do { \
    ...; \
  } while (0)

Plus wrap params in parens (except #FIELD of course).

 >  static void
 >  ctf_open (char *dirname, int from_tty)
 >  {
 > +  struct bt_ctf_event *event;
 > +  uint32_t event_id;
 > +  const struct bt_definition *scope;
 > +
 >    target_preopen (from_tty);
 >    if (!dirname)
 >      error (_("No CTF directory specified."));
 >  
 >    ctf_open_dir (dirname);
 >  
 > +  /* Skip the first packet which about the trace status.  The first
 > +     event is "frame".  */
 > +  event = bt_ctf_iter_read_event (ctf_iter);
 > +  scope = bt_ctf_get_top_level_scope (event, BT_STREAM_EVENT_HEADER);
 > +  event_id = bt_ctf_get_uint64 (bt_ctf_get_field (event, scope, "id"));
 > +  gdb_assert (event_id == CTF_EVENT_ID_FRAME);

Question: Will these asserts trigger on bad input data?
[If so, you need to use something else besides gdb_assert.]

 > +  /* The second event is "status".  */
 > +  gdb_assert (bt_iter_next (bt_ctf_get_iter (ctf_iter)) >= 0);
 > +  event = bt_ctf_iter_read_event (ctf_iter);
 > +  scope = bt_ctf_get_top_level_scope (event, BT_STREAM_EVENT_HEADER);
 > +  event_id = bt_ctf_get_uint64 (bt_ctf_get_field (event, scope, "id"));
 > +  gdb_assert (event_id == CTF_EVENT_ID_STATUS);
 > +  ctf_read_status (event, current_trace_status ());
 > +
 > +  /* The third event is "frame".  A new packet.  */
 > +  gdb_assert (bt_iter_next (bt_ctf_get_iter (ctf_iter)) >= 0);
 > +  event = bt_ctf_iter_read_event (ctf_iter);
 > +  scope = bt_ctf_get_top_level_scope (event, BT_STREAM_EVENT_HEADER);
 > +  event_id = bt_ctf_get_uint64 (bt_ctf_get_field (event, scope, "id"));
 > +  gdb_assert (event_id == CTF_EVENT_ID_FRAME);
 > +
 > +  start_pos = bt_iter_get_pos (bt_ctf_get_iter (ctf_iter));
 > +  gdb_assert (start_pos->type == BT_SEEK_RESTORE);
 > +
 >    trace_dirname = xstrdup (dirname);
 >    push_target (&ctf_ops);
 >  }


  parent reply	other threads:[~2013-03-14 18:06 UTC|newest]

Thread overview: 60+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-03-09  3:48 [PATCH v3 00/15] CTF Support Yao Qi
2013-03-09  3:49 ` [PATCH v3 11/15] Write tsv definition in CTF and read Yao Qi
2013-03-12 19:56   ` Tom Tromey
2013-03-09  3:49 ` [PATCH v3 01/15] Refactor 'tsave' Yao Qi
2013-03-12 18:30   ` Tom Tromey
2013-03-13 10:33     ` Yao Qi
2013-03-13 19:26       ` Tom Tromey
2013-03-14  9:17         ` Yao Qi
2013-03-09  3:49 ` [PATCH v3 09/15] Check the tstatus output on tfile target Yao Qi
2013-03-12 19:45   ` Tom Tromey
2013-03-09  3:49 ` [PATCH v3 08/15] Write 'stop_desc' of trace status to tfile Yao Qi
2013-03-12 19:15   ` Tom Tromey
2013-03-09  3:49 ` [PATCH v3 07/15] Write trace notes and username into tfile Yao Qi
2013-03-12 19:35   ` Tom Tromey
2013-03-09  3:49 ` [PATCH v3 13/15] Test on saving tracepoint defs Yao Qi
2013-03-12 20:10   ` Tom Tromey
2013-03-13  9:48     ` Yao Qi
2013-03-13 14:58       ` Tom Tromey
2013-03-09  3:49 ` [PATCH v3 06/15] Write status to CTF and read Yao Qi
2013-03-12 19:31   ` Tom Tromey
2013-03-14 18:06   ` Doug Evans [this message]
2013-03-29 14:46     ` Yao Qi
2013-03-29 16:47       ` Doug Evans
2013-03-09  3:49 ` [PATCH v3 12/15] Write tracepoint definition in " Yao Qi
2013-03-12 20:02   ` Tom Tromey
2013-03-14 18:34   ` Doug Evans
2013-03-09  3:49 ` [PATCH v3 10/15] tstatus.exp: ctf Yao Qi
2013-03-12 19:48   ` Tom Tromey
2013-03-09  3:49 ` [PATCH v3 02/15] Save trace into CTF format Yao Qi
2013-03-12 18:49   ` Tom Tromey
2013-03-13 10:33     ` Yao Qi
2013-03-13 19:30       ` Tom Tromey
2013-03-14 17:49       ` Doug Evans
2013-03-09  3:49 ` [PATCH v3 03/15] Read CTF by the ctf target Yao Qi
2013-03-13 20:09   ` Tom Tromey
2013-03-14 13:23     ` Yao Qi
2013-03-14 14:59       ` Tom Tromey
2013-03-14 16:57     ` Doug Evans
2013-03-14 17:39       ` Doug Evans
2013-03-25 13:33         ` Yao Qi
2013-03-25 17:14           ` Doug Evans
2013-03-26 16:16             ` Yao Qi
2013-03-29 17:56               ` Doug Evans
2013-04-08 14:19                 ` Yao Qi
2013-04-08 21:48                   ` Doug Evans
2013-04-09 15:23                     ` Yao Qi
2013-04-09 18:41                       ` Doug Evans
2013-03-09  3:49 ` [PATCH v3 04/15] ctf doc and NEWS Yao Qi
2013-03-09  3:49 ` [PATCH v3 05/15] ctf test: report.exp Yao Qi
2013-03-12 19:25   ` Tom Tromey
2013-03-09  3:49 ` [PATCH v3 14/15] Test on saving tracepoint defs: CTF Yao Qi
2013-03-12 20:23   ` Tom Tromey
2013-03-13  9:55     ` Yao Qi
2013-03-13 15:49       ` Tom Tromey
2013-03-09  3:49 ` [PATCH v3 15/15] MAINTAINERS Yao Qi
2013-04-10 19:16 ` [PATCH v3 00/15] CTF Support Yao Qi
2013-04-11 22:59   ` [patch] Regenerate config.in [Re: [PATCH v3 00/15] CTF Support] Jan Kratochvil
2013-04-12 22:27     ` [commit] " Jan Kratochvil
2014-08-04 18:59   ` Incorrect placement of babeltrace gdb/NEWS item " Jan Kratochvil
2014-08-06  1:30     ` Yao Qi

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=20802.4537.197713.506858@ruffy2.mtv.corp.google.com \
    --to=dje@google.com \
    --cc=gdb-patches@sourceware.org \
    --cc=yao@codesourcery.com \
    /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