From: Hengqi Chen Date: Mon, 3 Jan 2022 13:36:48 +0000 (+0800) Subject: bcc: Fix array type handling due to llvm changes X-Git-Tag: v0.24.0~22 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=ca1d3fd07a8483270041ef2899ed72fa28473811;p=platform%2Fupstream%2Fbcc.git bcc: Fix array type handling due to llvm changes The llvm commit aee49255074f ([0]) changes array type from `int [4]` to `int[4]` (with space removed), which breaks the assumption in BCC. This commit fixes this issue and adds a comment to the related code. While at it, also remove execution permission of file `table.py`. [0]: https://github.com/llvm/llvm-project/commit/aee49255074fd4ef38d97e6e70cbfbf2f9fd0fa7 Signed-off-by: Hengqi Chen --- diff --git a/src/cc/frontends/clang/b_frontend_action.cc b/src/cc/frontends/clang/b_frontend_action.cc index 27b19360..9a6e510e 100644 --- a/src/cc/frontends/clang/b_frontend_action.cc +++ b/src/cc/frontends/clang/b_frontend_action.cc @@ -946,6 +946,9 @@ bool BTypeVisitor::VisitCallExpr(CallExpr *Call) { std::vector perf_event; for (auto it = r->field_begin(); it != r->field_end(); ++it) { + // After LLVM commit aee49255074f + // (https://github.com/llvm/llvm-project/commit/aee49255074fd4ef38d97e6e70cbfbf2f9fd0fa7) + // array type change from `comm#char [16]` to `comm#char[16]` perf_event.push_back(it->getNameAsString() + "#" + it->getType().getAsString()); //"pid#u32" } fe_.perf_events_[name] = perf_event; diff --git a/src/python/bcc/table.py b/src/python/bcc/table.py old mode 100755 new mode 100644 index 91e0ab16..1ff24114 --- a/src/python/bcc/table.py +++ b/src/python/bcc/table.py @@ -227,8 +227,8 @@ def _get_event_class(event_map): 'unsigned __int128' : (ct.c_ulonglong * 2), 'void *' : ct.c_void_p } - # handle array types e.g. "int [16] foo" - array_type = re.compile(r"(.+) \[([0-9]+)\]$") + # handle array types e.g. "int [16]" or "char[16]" + array_type = re.compile(r"([^ ]+) ?\[([0-9]+)\]$") fields = [] num_fields = lib.bpf_perf_event_fields(event_map.bpf.module, event_map._name)