Commit 922f1ab4 authored by Xiaozhou Liu's avatar Xiaozhou Liu

examples/tracing: some minor fixes

- chmod +x dddos.py mallocstacks.py stack_buildid_example.py
- Handle Ctrl-C keyboard interrupt for dddos.py, disksnoop.py,
  hello_perf_output.py, stacksnoop.py and trace_perf_output.py
parent 5f7c8294
......@@ -99,4 +99,7 @@ def trigger_alert_event(cpu, data, size):
# loop with callback to trigger_alert_event
b["events"].open_perf_buffer(trigger_alert_event)
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)"))
# format output
while 1:
(task, pid, cpu, flags, ts, msg) = b.trace_fields()
(bytes_s, bflags_s, us_s) = msg.split()
try:
(task, pid, cpu, flags, ts, msg) = b.trace_fields()
(bytes_s, bflags_s, us_s) = msg.split()
if int(bflags_s, 16) & REQ_WRITE:
type_s = "W"
elif bytes_s == "0": # see blk_fill_rwbs() for logic
type_s = "M"
else:
type_s = "R"
ms = float(int(us_s, 10)) / 1000
if int(bflags_s, 16) & REQ_WRITE:
type_s = "W"
elif bytes_s == "0": # see blk_fill_rwbs() for logic
type_s = "M"
else:
type_s = "R"
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):
# loop with callback to print_event
b["events"].open_perf_buffer(print_event)
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):
b["events"].open_perf_buffer(print_event)
while 1:
b.perf_buffer_poll()
try:
b.perf_buffer_poll()
except KeyboardInterrupt:
exit()
......@@ -53,4 +53,7 @@ def print_counter():
print("Tracing " + event_name + ", try `dd if=/dev/zero of=/dev/null`")
print("Tracing... Hit Ctrl-C to end.")
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