aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYonghong Song <yhs@fb.com>2018-10-27 23:34:23 -0700
committerYonghong Song <yhs@fb.com>2018-10-27 23:47:13 -0700
commit0e02fec896ff54ff562d8a253d38817ed2dfafb3 (patch)
tree835de6e266b3af8ab4f0f6f39483c186dcd4945f
parentf3fc87aab83ce3e4f1ca227e33853df21147255a (diff)
downloadbcc-0e02fec896ff54ff562d8a253d38817ed2dfafb3.zip
bcc-0e02fec896ff54ff562d8a253d38817ed2dfafb3.tar.gz
bcc-0e02fec896ff54ff562d8a253d38817ed2dfafb3.tar.bz2
correct certain tracepoint types in tp frontend action
Fix issue #2010. Alastair reported some missing cases in tp frontend action where certain types are not adjusted. For example, for tracepoint syscalls:sys_enter_kill, the kernel format: ... field:int __syscall_nr; offset:8; size:4; signed:1; field:pid_t pid; offset:16; size:8; signed:0; field:int sig; offset:24; size:8; signed:0; The size for "pid_t pid" is 8 bytes, but the kernel pid_t is "int", so it is needed to change its type to "s64" to be consistent to its size. This patch also added conversion for gid_t and uid_t as Alastair discovered that they are also used in some tracepoints with size 8. For type gid_t and uid_t, the corresponding kernel type is "unsigned int", so it should be converted to "u64". Signed-off-by: Yonghong Song <yhs@fb.com>
-rw-r--r--src/cc/frontends/clang/tp_frontend_action.cc6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/cc/frontends/clang/tp_frontend_action.cc b/src/cc/frontends/clang/tp_frontend_action.cc
index 9047400..d6faf01 100644
--- a/src/cc/frontends/clang/tp_frontend_action.cc
+++ b/src/cc/frontends/clang/tp_frontend_action.cc
@@ -121,11 +121,13 @@ static inline field_kind_t _get_field_kind(string const& line,
} else if (size == 8) {
if (field_type == "char" || field_type == "short" || field_type == "int" ||
field_type == "int8_t" || field_type == "int16_t" ||
- field_type == "int32_t")
+ field_type == "int32_t" || field_type == "pid_t")
field_type = "s64";
if (field_type == "unsigned char" || field_type == "unsigned short" ||
field_type == "unsigned int" || field_type == "uint8_t" ||
- field_type == "uint16_t" || field_type == "uint32_t")
+ field_type == "uint16_t" || field_type == "uint32_t" ||
+ field_type == "unsigned" || field_type == "u32" ||
+ field_type == "uid_t" || field_type == "gid_t")
field_type = "u64";
}