[lttng-dev] [BABELTRACE PATCH] Use default if there is no clock declaration

Mathieu Desnoyers mathieu.desnoyers at efficios.com
Mon Feb 13 08:55:04 EST 2012


* Juha Niskanen (juniskane at gmail.com) wrote:
> In absence of clock description in metadata, use a default clock
> source which increments once per nanosecond.
> 
> Without this patch, the converter crashes when given old traces
> that are lacking clock description block.

Merged (with tiny cosmetic fixes). Thanks !

Mathieu

> 
> Signed-off-by: Juha Niskanen <juniskane at gmail.com>
> ---
>  .../ctf/metadata/ctf-visitor-generate-io-struct.c  |   29 +++++++++++++++----
>  1 files changed, 23 insertions(+), 6 deletions(-)
> 
> diff --git a/formats/ctf/metadata/ctf-visitor-generate-io-struct.c b/formats/ctf/metadata/ctf-visitor-generate-io-struct.c
> index 2d3361c..8de2cae 100644
> --- a/formats/ctf/metadata/ctf-visitor-generate-io-struct.c
> +++ b/formats/ctf/metadata/ctf-visitor-generate-io-struct.c
> @@ -2302,6 +2302,20 @@ error:
>  }
>  
>  static
> +void clock_default_monotonic(struct ctf_trace *trace)
> +{
> +	struct ctf_clock *clock;
> +
> +	clock = g_new0(struct ctf_clock, 1);
> +	/* Default clock frequency is set to 1000000000 */
> +	clock->freq = 1000000000ULL;
> +	clock->name = g_quark_from_string("monotonic");
> +
> +	trace->single_clock = clock;
> +	g_hash_table_insert(trace->clocks, (gpointer) (unsigned long) clock->name, clock);
> +}
> +
> +static
>  void clock_free(gpointer data)
>  {
>  	struct ctf_clock *clock = data;
> @@ -2516,12 +2530,15 @@ retry:
>  			 * declarations need to query clock hash table,
>  			 * so clock need to be treated first.
>  			 */
> -			cds_list_for_each_entry(iter, &node->u.root.clock, siblings) {
> -				ret = ctf_clock_visit(fd, depth + 1, iter,
> -						      trace);
> -				if (ret) {
> -					fprintf(fd, "[error] %s: clock declaration error\n", __func__);
> -					goto error;
> +			if (cds_list_empty(&node->u.root.clock))
> +				clock_default_monotonic(trace);
> +			else {
> +				cds_list_for_each_entry(iter, &node->u.root.clock, siblings) {
> +					ret = ctf_clock_visit(fd, depth + 1, iter, trace);
> +					if (ret) {
> +						fprintf(fd, "[error] %s: clock declaration error\n", __func__);
> +						goto error;
> +					}
>  				}
>  			}
>  			env_clock_done = 1;
> -- 
> 1.7.4.1
> 
> 
> _______________________________________________
> lttng-dev mailing list
> lttng-dev at lists.lttng.org
> http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev

-- 
Mathieu Desnoyers
Operating System Efficiency R&D Consultant
EfficiOS Inc.
http://www.efficios.com



More information about the lttng-dev mailing list