X-Git-Url: http://git.efficios.com/?p=babeltrace.git;a=blobdiff_plain;f=bindings%2Fpython%2Fexamples%2Fsched_switch.py;h=1d9f671961a608f5454a2b429d972b09a9070505;hp=83c191f813f7cd7c8b99e5cfd8751727548ba232;hb=24d5c942785816bc3c6ad926dc1272510c38948d;hpb=7a30a66858f0835baaf65fdd94ad6c50a44b41d2 diff --git a/bindings/python/examples/sched_switch.py b/bindings/python/examples/sched_switch.py index 83c191f8..1d9f6719 100644 --- a/bindings/python/examples/sched_switch.py +++ b/bindings/python/examples/sched_switch.py @@ -43,7 +43,7 @@ if ret is None: # Setting iterator bp = IterPos(SEEK_BEGIN) -ctf_it = ctf.Iterator(ctx, bp) +ctf_it = CTFReader.Iterator(ctx, bp) # Reading events event = ctf_it.read_event() @@ -51,65 +51,63 @@ while event is not None: while True: if event.get_name() == "sched_switch": # Getting scope definition - sco = event.get_top_level_scope(ctf.scope.STREAM_EVENT_CONTEXT) + sco = event.get_top_level_scope(CTFReader.scope.STREAM_EVENT_CONTEXT) if sco is None: print("ERROR: Cannot get definition scope for sched_switch") break # Next event # Getting PID - pid_field = event.get_field_with_scope(sco, "_pid") - pid = pid_field.get_int64() - - if ctf.field_error(): + pid_field = event.get_field_with_scope(sco, "pid") + if pid_field is None: print("ERROR: Missing PID info for sched_switch") break # Next event - + pid = pid_field.get_value() if usePID and (pid != long(sys.argv[1])): break # Next event - sco = event.get_top_level_scope(ctf.scope.EVENT_FIELDS) + sco = event.get_top_level_scope(CTFReader.scope.EVENT_FIELDS) # prev_comm - field = event.get_field_with_scope(sco, "_prev_comm") - prev_comm = field.get_char_array() - if ctf.field_error(): + field = event.get_field_with_scope(sco, "prev_comm") + if field is None: print("ERROR: Missing prev_comm context info") + prev_comm = field.get_value() # prev_tid - field = event.get_field_with_scope(sco, "_prev_tid") - prev_tid = field.get_int64() - if ctf.field_error(): + field = event.get_field_with_scope(sco, "prev_tid") + if field is None: print("ERROR: Missing prev_tid context info") + prev_tid = field.get_value() # prev_prio - field = event.get_field_with_scope(sco, "_prev_prio") - prev_prio = field.get_int64() - if ctf.field_error(): + field = event.get_field_with_scope(sco, "prev_prio") + if field is None: print("ERROR: Missing prev_prio context info") + prev_prio = field.get_value() # prev_state - field = event.get_field_with_scope(sco, "_prev_state") - prev_state = field.get_int64() - if ctf.field_error(): + field = event.get_field_with_scope(sco, "prev_state") + if field is None: print("ERROR: Missing prev_state context info") + prev_state = field.get_value() # next_comm - field = event.get_field_with_scope(sco, "_next_comm") - next_comm = field.get_char_array() - if ctf.field_error(): + field = event.get_field_with_scope(sco, "next_comm") + if field is None: print("ERROR: Missing next_comm context info") + next_comm = field.get_value() # next_tid - field = event.get_field_with_scope(sco, "_next_tid") - next_tid = field.get_int64() - if ctf.field_error(): + field = event.get_field_with_scope(sco, "next_tid") + if field is None: print("ERROR: Missing next_tid context info") + next_tid = field.get_value() # next_prio - field = event.get_field_with_scope(sco, "_next_prio") - next_prio = field.get_int64() - if ctf.field_error(): + field = event.get_field_with_scope(sco, "next_prio") + if field is None: print("ERROR: Missing next_prio context info") + next_prio = field.get_value() # Output print("sched_switch, pid = {}, TS = {}, prev_comm = {},\n\t"