projects
/
babeltrace.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Python bindings: sched_switch example clean-up
[babeltrace.git]
/
bindings
/
python
/
examples
/
example-api-test.py
diff --git
a/bindings/python/examples/example-api-test.py
b/bindings/python/examples/example-api-test.py
index 12cfb6eb7d1449a3ee202f5011965f45ae5fa4ad..56a8f88f4c84c1e58dad4a079eb47fca717b76b4 100644
(file)
--- a/
bindings/python/examples/example-api-test.py
+++ b/
bindings/python/examples/example-api-test.py
@@
-34,31
+34,27
@@
if trace_handle is None:
raise IOError("Error adding trace")
# Listing events
raise IOError("Error adding trace")
# Listing events
-lst = CTFReader.get_event_decl_list(trace_handle, traces)
print("--- Event list ---")
print("--- Event list ---")
-for item in lst:
- print("event : {}".format(item.get_name()))
+for event_declaration in trace_handle.events:
+ print("event : {}".format(event_declaration.name))
+ if event_declaration.name == "sched_switch":
+ for field_declaration in event_declaration.fields:
+ print(field_declaration)
print("--- Done ---")
for event in traces.events:
print("--- Done ---")
for event in traces.events:
- print("TS: {}, {} : {}".format(event.get_timestamp(),
- event.get_cycles(), event.get_name()))
+ print("TS: {}, {} : {}".format(event.timestamp, event.cycles, event.name))
- if event.
get_name()
== "sched_switch":
- prev_
field = event.get_field("prev_comm")
- if prev_
field
is None:
+ if event.
name
== "sched_switch":
+ prev_
comm = event["prev_comm"]
+ if prev_
comm
is None:
print("ERROR: Missing prev_comm context info")
else:
print("ERROR: Missing prev_comm context info")
else:
- prev_comm = prev_field[0].get_value()
- if prev_comm is not None:
- print("sched_switch prev_comm: {}".format(prev_comm))
+ print("sched_switch prev_comm: {}".format(prev_comm))
- if event.
get_name()
== "exit_syscall":
- ret_
field = event.get_field("ret")
- if ret_
field
is None:
+ if event.
name
== "exit_syscall":
+ ret_
code = event["ret"]
+ if ret_
code
is None:
print("ERROR: Unable to extract ret")
else:
print("ERROR: Unable to extract ret")
else:
- ret_code = ret_field[0].get_value()
- if ret_code is not None:
- print("exit_syscall ret: {}".format(ret_code))
-
+ print("exit_syscall ret: {}".format(ret_code))
This page took
0.0245 seconds
and
4
git commands to generate.