Commit 4135be22 authored by 4ast's avatar 4ast

Merge pull request #183 from iovisor/bblanco_dev

Shorten trace_readline_fields to trace_fields
parents a789867d 819334ec
...@@ -25,7 +25,7 @@ print("%-18s %-2s %-7s %8s" % ("TIME(s)", "T", "BYTES", "LAT(ms)")) ...@@ -25,7 +25,7 @@ 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_readline_fields() (task, pid, cpu, flags, ts, msg) = b.trace_fields()
(bytes_s, bflags_s, us_s) = msg.split() (bytes_s, bflags_s, us_s) = msg.split()
if int(bflags_s, 16) & REQ_WRITE: if int(bflags_s, 16) & REQ_WRITE:
......
...@@ -492,8 +492,8 @@ class BPF(object): ...@@ -492,8 +492,8 @@ class BPF(object):
return tracefile return tracefile
@staticmethod @staticmethod
def trace_readline_fields(nonblocking=False): def trace_fields(nonblocking=False):
"""trace_readline_fields(nonblocking=False) """trace_fields(nonblocking=False)
Read from the kernel debug trace pipe and return a tuple of the Read from the kernel debug trace pipe and return a tuple of the
fields (task, pid, cpu, flags, timestamp, msg) or None if no fields (task, pid, cpu, flags, timestamp, msg) or None if no
...@@ -537,13 +537,13 @@ class BPF(object): ...@@ -537,13 +537,13 @@ class BPF(object):
Read from the kernel debug trace pipe and print on stdout. Read from the kernel debug trace pipe and print on stdout.
If fmt is specified, apply as a format string to the output. See If fmt is specified, apply as a format string to the output. See
trace_readline_fields for the members of the tuple trace_fields for the members of the tuple
example: trace_print(fmt="pid {1}, msg = {5}") example: trace_print(fmt="pid {1}, msg = {5}")
""" """
while True: while True:
if fmt: if fmt:
fields = BPF.trace_readline_fields(nonblocking=False) fields = BPF.trace_fields(nonblocking=False)
if not fields: continue if not fields: continue
line = fmt.format(*fields) line = fmt.format(*fields)
else: else:
......
...@@ -28,5 +28,5 @@ print("%-18s %s" % ("TIME(s)", "CALL")) ...@@ -28,5 +28,5 @@ print("%-18s %s" % ("TIME(s)", "CALL"))
# format output # format output
while 1: while 1:
(task, pid, cpu, flags, ts, msg) = b.trace_readline_fields() (task, pid, cpu, flags, ts, msg) = b.trace_fields()
print("%-18.9f %s" % (ts, msg)) print("%-18.9f %s" % (ts, msg))
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