Commit dd8181f0 authored by Teng Qin's avatar Teng Qin Committed by Facebook Github Bot

Fix StaticTracepoint argument size type identification

Summary:
We need to determine the size of the Tracepoint arguments in the Macro. The only exception that we can not simply take `sizeof` is arrays, where `sizeof` will return size of the array where we really want is size of a pointer. Before we specifically check this with `FOLLY_SDT_ISARRAY` which checks if `__builtin_classify_type` of the argument is 14. However in recent update of LLVM, some arrays will be reported with type 5 (pointer type). Originally we didn't add that because we thought if the type of the argument is already a pointer then just take a `sizeof` on it would still be correct. This Diff fixes the issue.

LLVM change in question is https://reviews.llvm.org/rL333126

Reviewed By: taewookoh

Differential Revision: D10453657

fbshipit-source-id: 154fdfc78fe6438cd66cf256203c8d174773c1a8
parent 36bad07f
......@@ -50,8 +50,11 @@
#define FOLLY_SDT_ASM_STRING(x) FOLLY_SDT_ASM_1(.asciz FOLLY_SDT_S(x))
// Helper to determine the size of an argument.
#define FOLLY_SDT_ISARRAY(x) (__builtin_classify_type(x) == 14)
#define FOLLY_SDT_ARGSIZE(x) (FOLLY_SDT_ISARRAY(x) ? sizeof(void*) : sizeof(x))
#define FOLLY_SDT_IS_ARRAY_POINTER(x) ((__builtin_classify_type(x) == 14) || \
(__builtin_classify_type(x) == 5))
#define FOLLY_SDT_ARGSIZE(x) (FOLLY_SDT_IS_ARRAY_POINTER(x) \
? sizeof(void*) \
: sizeof(x))
// Format of each probe arguments as operand.
// Size of the arugment tagged with FOLLY_SDT_Sn, with "n" constraint.
......
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