diff options
author | jeromemarchand <38073585+jeromemarchand@users.noreply.github.com> | 2018-10-13 01:01:22 +0200 |
---|---|---|
committer | yonghong-song <ys114321@gmail.com> | 2018-10-12 16:01:22 -0700 |
commit | 09f9d3c8dd016ee10dc8b57057763dc25b0d2208 (patch) | |
tree | 010370346b9f38e25da0f8fd4d455f45285e0445 | |
parent | 1d2348027404307b6cd51c0c452207be27c64863 (diff) | |
download | bcc-09f9d3c8dd016ee10dc8b57057763dc25b0d2208.zip bcc-09f9d3c8dd016ee10dc8b57057763dc25b0d2208.tar.gz bcc-09f9d3c8dd016ee10dc8b57057763dc25b0d2208.tar.bz2 |
Tools fixes (#2009)
* tools: the argument of get_kprobe_functions() should be a bytes object
It fixes the following error:
Traceback (most recent call last):
File "/usr/share/bcc/tools/ext4dist", line 189, in <module>
if BPF.get_kprobe_functions('ext4_file_read_iter'):
File "/usr/lib/python3.6/site-packages/bcc/__init__.py", line 519, in get_kprobe_functions
if (t.lower() in [b't', b'w']) and re.match(event_re, fn) \
File "/usr/lib64/python3.6/re.py", line 172, in match
return _compile(pattern, flags).match(string)
TypeError: cannot use a string pattern on a bytes-like object
* tools: fix freeze in offwaketime
Since commit 47cecb65ce6e, the sigint signal is ignored
unconditionally which prevents offwaketime to be stopped by
pressing Ctrl-C when run without a specified duration.
-rwxr-xr-x | tools/ext4dist.py | 4 | ||||
-rwxr-xr-x | tools/offwaketime.py | 10 |
2 files changed, 8 insertions, 6 deletions
diff --git a/tools/ext4dist.py b/tools/ext4dist.py index 1806953..bc797fb 100755 --- a/tools/ext4dist.py +++ b/tools/ext4dist.py @@ -183,10 +183,10 @@ b = BPF(text=bpf_text) # Comment by Joe Yin # From Linux 4.10, the function .read_iter at the ext4_file_operations has # changed to ext4_file_read_iter. -# So, I add get_kprobe_functions('ext4_file_read_iter'),it will first to attach ext4_file_read_iter, +# So, I add get_kprobe_functions(b'ext4_file_read_iter'),it will first to attach ext4_file_read_iter, # if fails and will attach the generic_file_read_iter which used to pre-4.10. -if BPF.get_kprobe_functions('ext4_file_read_iter'): +if BPF.get_kprobe_functions(b'ext4_file_read_iter'): b.attach_kprobe(event="ext4_file_read_iter", fn_name="trace_entry") else: b.attach_kprobe(event="generic_file_read_iter", fn_name="trace_read_entry") diff --git a/tools/offwaketime.py b/tools/offwaketime.py index 674be22..0e4f35e 100755 --- a/tools/offwaketime.py +++ b/tools/offwaketime.py @@ -277,11 +277,13 @@ if not folded: else: print("... Hit Ctrl-C to end.") -# as cleanup can take many seconds, trap Ctrl-C: -# print a newline for folded output on Ctrl-C -signal.signal(signal.SIGINT, signal_ignore) +try: + sleep(duration) +except KeyboardInterrupt: + # as cleanup can take many seconds, trap Ctrl-C: + # print a newline for folded output on Ctrl-C + signal.signal(signal.SIGINT, signal_ignore) -sleep(duration) if not folded: print() |