X-Git-Url: http://git.efficios.com/?p=babeltrace.git;a=blobdiff_plain;f=bindings%2Fpython%2Fexamples%2Fexample-api-test.py;h=d6b48ffda79e6119bbd13900ce3ba2ca4e549d18;hp=104f2d5585e3c216ebe2a0611f400cd1d1f28ecd;hb=3c2ce778cc0d5e5be91e2fd1d176365a2ad65aa3;hpb=bb919dd077169b5ee049ba3fc82f8555648cb22e diff --git a/bindings/python/examples/example-api-test.py b/bindings/python/examples/example-api-test.py index 104f2d55..d6b48ffd 100644 --- a/bindings/python/examples/example-api-test.py +++ b/bindings/python/examples/example-api-test.py @@ -1,18 +1,19 @@ +#!/usr/bin/env python3 # example_api_test.py -# +# # Babeltrace example script based on the Babeltrace API test script -# +# # Copyright 2012 EfficiOS Inc. -# +# # Author: Danny Serres -# +# # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell # copies of the Software, and to permit persons to whom the Software is # furnished to do so, subject to the following conditions: -# +# # The above copyright notice and this permission notice shall be included in # all copies or substantial portions of the Software. @@ -49,24 +50,22 @@ while(event is not None): event.get_cycles(), event.get_name())) if event.get_name() == "sched_switch": - sco = event.get_top_level_scope(ctf.scope.EVENT_FIELDS) - prev_field = event.get_field(sco, "_prev_comm") - prev_comm = prev_field.get_char_array() - - if ctf.field_error(): + prev_field = event.get_field("prev_comm") + if prev_field is None: print("ERROR: Missing prev_comm context info") else: - print("sched_switch prev_comm: {}".format(prev_comm)) + prev_comm = prev_field[0].get_value() + if prev_comm is not None: + print("sched_switch prev_comm: {}".format(prev_comm)) if event.get_name() == "exit_syscall": - sco = event.get_top_level_scope(ctf.scope.EVENT_FIELDS) - ret_field = event.get_field(sco, "_ret") - ret_code = ret_field.get_int64() - - if ctf.field_error(): + ret_field = event.get_field("ret") + if ret_field is None: print("ERROR: Unable to extract ret") else: - print("exit_syscall ret: {}".format(ret_code)) + ret_code = ret_field[0].get_value() + if ret_code is not None: + print("exit_syscall ret: {}".format(ret_code)) ret = ctf_it.next() if ret < 0: