Project

General

Profile

Actions

Bug #1277

open

The `ctf` plugin does not support a negative TSDL clock class `offset` attribute

Added by Seongab Kim over 4 years ago. Updated about 1 month ago.

Status:
Confirmed
Priority:
Normal
Assignee:
-
Category:
src.ctf.fs
Start date:
07/23/2020
Due date:
% Done:

0%

Estimated time:

Description

Hi,

I have a trace which cannot be opened by babeltrace as below, but I can open it with Trace Compass.

skim@d54030999178:/mnt/ssd/work/skim/traces$ babeltrace2  ./kernel/
07-22 07:49:20.099  5264  5264 E PLUGIN/CTF/META/IR-VISITOR get_unary_unsigned@visitor-generate-ir.c:800 [auto-disc-source-ctf-fs] At line 40 in metadata stream: Invalid constant unsigned integer.
07-22 07:49:20.099  5264  5264 E PLUGIN/CTF/META/IR-VISITOR visit_clock_decl_entry@visitor-generate-ir.c:4357 [auto-disc-source-ctf-fs] At line 40 in metadata stream: Unexpected unary expression for clock class's `offset` attribute.
07-22 07:49:20.099  5264  5264 E PLUGIN/CTF/META/IR-VISITOR visit_clock_decl@visitor-generate-ir.c:4532 [auto-disc-source-ctf-fs] At line 40 in metadata stream: Cannot visit clock class's entry: ret=-22
07-22 07:49:20.099  5264  5264 E PLUGIN/CTF/META/IR-VISITOR ctf_visitor_generate_ir_visit_node@visitor-generate-ir.c:4775 [auto-disc-source-ctf-fs] At line 41 in metadata stream: Cannot visit clock class: ret=-22
07-22 07:49:20.099  5264  5264 E PLUGIN/CTF/META/DECODER ctf_metadata_decoder_append_content@decoder.c:337 [auto-disc-source-ctf-fs] Failed to visit AST node to create CTF IR objects: mdec-addr=0x22a0d90, ret=-22
07-22 07:49:20.099  5264  5264 E PLUGIN/SRC.CTF.FS/META ctf_fs_metadata_set_trace_class@metadata.c:128 [auto-disc-source-ctf-fs] Cannot update metadata decoder's content.
07-22 07:49:20.122  5264  5264 E PLUGIN/SRC.CTF.FS ctf_fs_component_create_ctf_fs_trace_one_path@fs.c:1206 [auto-disc-source-ctf-fs] Cannot create trace for `/mnt/ssd/work/skim/traces/kernel`.
07-22 07:49:20.123  5264  5264 W LIB/GRAPH add_component_with_init_method_data@graph.c:977 Component initialization method failed: status=ERROR, comp-addr=0x22a68d0, comp-name="auto-disc-source-ctf-fs", comp-log-level=WARNING, comp-class-type=SOURCE, comp-class-name="fs", comp-class-partial-descr="Read CTF traces from the file sy", comp-class-is-frozen=0, comp-class-so-handle-addr=0x22b0de0, comp-class-so-handle-path="/usr/lib/x86_64-linux-gnu/babeltrace2/plugins/babeltrace-plugin-ctf.so", comp-input-port-count=0, comp-output-port-count=0
07-22 07:49:20.123  5264  5264 E CLI cmd_run_ctx_create_components_from_config_components@babeltrace2.c:2301 Cannot create component: plugin-name="ctf", comp-cls-name="fs", comp-cls-type=1, comp-name="auto-disc-source-ctf-fs" 
07-22 07:49:20.123  5264  5264 E CLI cmd_run@babeltrace2.c:2480 Cannot create components.

ERROR:    [Babeltrace CLI] (babeltrace2.c:2480)
  Cannot create components.
CAUSED BY [Babeltrace CLI] (babeltrace2.c:2301)
  Cannot create component: plugin-name="ctf", comp-cls-name="fs", comp-cls-type=1, comp-name="auto-disc-source-ctf-fs" 
CAUSED BY [libbabeltrace2] (graph.c:977)
  Component initialization method failed: status=ERROR, comp-addr=0x22a68d0, comp-name="auto-disc-source-ctf-fs", comp-log-level=WARNING,
  comp-class-type=SOURCE, comp-class-name="fs", comp-class-partial-descr="Read CTF traces from the file sy", comp-class-is-frozen=0,
  comp-class-so-handle-addr=0x22b0de0, comp-class-so-handle-path="/usr/lib/x86_64-linux-gnu/babeltrace2/plugins/babeltrace-plugin-ctf.so",
  comp-input-port-count=0, comp-output-port-count=0 CAUSED BY [auto-disc-source-ctf-fs: 'source.ctf.fs'] (fs.c:1206)
  Cannot create trace for `/mnt/ssd/work/skim/traces/kernel`.

I'm using below version.

skim@d54030999178:~/work/tmp$ babeltrace2 -V 
Babeltrace 2.0.4 "Amqui" 

Amqui (/_mkwi_/) is a town in eastern Qu_bec, Canada, at the base of the Gasp_ peninsula in Bas-Saint-Laurent. Located at the confluence of the Humqui and Matap_dia Rivers, its proximity to woodlands makes it a great destination for outdoor activities such as camping, hiking, and mountain biking.

Here is the test result which Philippe Proulx requested.

skim@d54030999178:~/ssd_work/traces$ babeltrace2 -o ctf-metadata ./kernel | grep -A10 '^clock {'
clock {
        name = "monotonic";
        uuid = "e00bcef2-1ef1-4f02-a241-8561834511fd";
        description = "Monotonic Clock";
        freq = 1000000000; /* Frequency, in Hz */
        /* clock value offset from Epoch is: offset * (1/freq) */
        offset = -48;
};
Actions #1

Updated by Philippe Proulx over 4 years ago

  • Description updated (diff)

Formatting the description.

Actions #2

Updated by Philippe Proulx over 4 years ago

  • Subject changed from babeltrace cannot open the trace but Trace Compass can open to The `ctf` plugin does not support a negative TSDL clock class `offset` attribute
  • Category set to src.ctf.fs
  • Status changed from New to Confirmed

It looks like CTF doesn't specify the signedness of the offset and offset_s attributes of a clock class.

It also looks like LTTng can generate a negative offset attribute value:

clock {
        name = "monotonic";
        uuid = "e00bcef2-1ef1-4f02-a241-8561834511fd";
        description = "Monotonic Clock";
        freq = 1000000000; /* Frequency, in Hz */
        /* clock value offset from Epoch is: offset * (1/freq) */
        offset = -48;
};

We will update the CTF specification to explicitly allow negative offset/offset_s attributes.

Which means we also need to fix this in Babeltrace 2.

The solution is to:

  1. Accept a signed value for the offset attribute at the TSDL parser level (like we already do for offset_s).
  2. As a Babeltrace 2 clock class's offset (in cycles) is an unsigned integer property, transfer any negative offset attribute value to the offset_s attribute before creating the clock class object.
    For example, with a 1 GHz frequency, an offset (in cycles) of -48 is equivalent to an offset (in seconds) of -1 and an offset (in cycles) of 999,999,952.
    This is similar to what calibrate_clock_class_offsets() does in visitor-generate-ir.c.
Actions #3

Updated by Philippe Proulx about 1 month ago

Note that a negative offset in cycles is explicitly not allowed in CTF 2.

From https://diamon.org/ctf/#clock-offset:

The value of this property MUST be greater than or equal to zero.

The value of this property MUST be less than the value of the frequency property of F

The part in seconds may be negative.

When converting, you can transfer any negative offset (in cycles) value to the offset (in seconds) value, as I wrote above.

Actions

Also available in: Atom PDF