Commit 339587fa authored by Teng Qin's avatar Teng Qin Committed by GitHub

Merge pull request #2182 from boat0/enhance-examples

examples/tracing: some minor fixes
parents 8b48206e 922f1ab4
...@@ -99,4 +99,7 @@ def trigger_alert_event(cpu, data, size): ...@@ -99,4 +99,7 @@ def trigger_alert_event(cpu, data, size):
# loop with callback to trigger_alert_event # loop with callback to trigger_alert_event
b["events"].open_perf_buffer(trigger_alert_event) b["events"].open_perf_buffer(trigger_alert_event)
while 1: while 1:
b.perf_buffer_poll() try:
b.perf_buffer_poll()
except KeyboardInterrupt:
exit()
...@@ -51,15 +51,18 @@ print("%-18s %-2s %-7s %8s" % ("TIME(s)", "T", "BYTES", "LAT(ms)")) ...@@ -51,15 +51,18 @@ print("%-18s %-2s %-7s %8s" % ("TIME(s)", "T", "BYTES", "LAT(ms)"))
# format output # format output
while 1: while 1:
(task, pid, cpu, flags, ts, msg) = b.trace_fields() try:
(bytes_s, bflags_s, us_s) = msg.split() (task, pid, cpu, flags, ts, msg) = b.trace_fields()
(bytes_s, bflags_s, us_s) = msg.split()
if int(bflags_s, 16) & REQ_WRITE: if int(bflags_s, 16) & REQ_WRITE:
type_s = "W" type_s = "W"
elif bytes_s == "0": # see blk_fill_rwbs() for logic elif bytes_s == "0": # see blk_fill_rwbs() for logic
type_s = "M" type_s = "M"
else: else:
type_s = "R" type_s = "R"
ms = float(int(us_s, 10)) / 1000 ms = float(int(us_s, 10)) / 1000
print("%-18.9f %-2s %-7s %8.2f" % (ts, type_s, bytes_s, ms)) print("%-18.9f %-2s %-7s %8.2f" % (ts, type_s, bytes_s, ms))
except KeyboardInterrupt:
exit()
...@@ -58,4 +58,7 @@ def print_event(cpu, data, size): ...@@ -58,4 +58,7 @@ def print_event(cpu, data, size):
# loop with callback to print_event # loop with callback to print_event
b["events"].open_perf_buffer(print_event) b["events"].open_perf_buffer(print_event)
while 1: while 1:
b.perf_buffer_poll() try:
b.perf_buffer_poll()
except KeyboardInterrupt:
exit()
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
...@@ -120,4 +120,7 @@ def print_event(cpu, data, size): ...@@ -120,4 +120,7 @@ def print_event(cpu, data, size):
b["events"].open_perf_buffer(print_event) b["events"].open_perf_buffer(print_event)
while 1: while 1:
b.perf_buffer_poll() try:
b.perf_buffer_poll()
except KeyboardInterrupt:
exit()
...@@ -53,4 +53,7 @@ def print_counter(): ...@@ -53,4 +53,7 @@ def print_counter():
print("Tracing " + event_name + ", try `dd if=/dev/zero of=/dev/null`") print("Tracing " + event_name + ", try `dd if=/dev/zero of=/dev/null`")
print("Tracing... Hit Ctrl-C to end.") print("Tracing... Hit Ctrl-C to end.")
while 1: while 1:
b.perf_buffer_poll() try:
b.perf_buffer_poll()
except KeyboardInterrupt:
exit()
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment