Skip to content

Commit

Permalink
ucalls: use replace error handler (iovisor#1888)
Browse files Browse the repository at this point in the history
Prevents the following error when tracing a java program that contains
non-ascii method name:

Traceback (most recent call last):
  File "/usr/share/bcc/tools/lib/ucalls", line 305, in <module>
    data = get_data()   # [(function, (num calls, latency in ns))]
  File "/usr/share/bcc/tools/lib/ucalls", line 266, in get_data
    bpf["counts"].items()))
  File "/usr/share/bcc/tools/lib/ucalls", line 264, in <lambda>
    kv[0].method.decode(),
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc4 in position 11: ordinal not in range(128)

Signed-off-by: Jerome Marchand <[email protected]>
  • Loading branch information
jeromemarchand authored and yonghong-song committed Jul 19, 2018
1 parent e36f9e1 commit 4e4c9e0
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions tools/lib/ucalls.py
Original file line number Diff line number Diff line change
Expand Up @@ -255,13 +255,15 @@
def get_data():
# Will be empty when no language was specified for tracing
if args.latency:
data = list(map(lambda kv: (kv[0].clazz.decode() + "." + \
kv[0].method.decode(),
data = list(map(lambda kv: (kv[0].clazz.decode('utf-8', 'replace') \
+ "." + \
kv[0].method.decode('utf-8', 'replace'),
(kv[1].num_calls, kv[1].total_ns)),
bpf["times"].items()))
else:
data = list(map(lambda kv: (kv[0].clazz.decode() + "." + \
kv[0].method.decode(),
data = list(map(lambda kv: (kv[0].clazz.decode('utf-8', 'replace') \
+ "." + \
kv[0].method.decode('utf-8', 'replace'),
(kv[1].value, 0)),
bpf["counts"].items()))

Expand Down

0 comments on commit 4e4c9e0

Please sign in to comment.