trace_probe.h 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580
  1. // SPDX-License-Identifier: GPL-2.0
  2. /*
  3. * Common header file for probe-based Dynamic events.
  4. *
  5. * This code was copied from kernel/trace/trace_kprobe.h written by
  6. * Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
  7. *
  8. * Updates to make this generic:
  9. * Copyright (C) IBM Corporation, 2010-2011
  10. * Author: Srikar Dronamraju
  11. */
  12. #include <linux/seq_file.h>
  13. #include <linux/slab.h>
  14. #include <linux/smp.h>
  15. #include <linux/tracefs.h>
  16. #include <linux/types.h>
  17. #include <linux/string.h>
  18. #include <linux/ptrace.h>
  19. #include <linux/perf_event.h>
  20. #include <linux/kprobes.h>
  21. #include <linux/stringify.h>
  22. #include <linux/limits.h>
  23. #include <linux/uaccess.h>
  24. #include <linux/bitops.h>
  25. #include <linux/btf.h>
  26. #include <asm/bitsperlong.h>
  27. #include "trace.h"
  28. #include "trace_output.h"
  29. #define MAX_TRACE_ARGS 128
  30. #define MAX_ARGSTR_LEN 63
  31. #define MAX_ARRAY_LEN 64
  32. #define MAX_ARG_NAME_LEN 32
  33. #define MAX_BTF_ARGS_LEN 128
  34. #define MAX_DENTRY_ARGS_LEN 256
  35. #define MAX_STRING_SIZE PATH_MAX
  36. /* Reserved field names */
  37. #define FIELD_STRING_IP "__probe_ip"
  38. #define FIELD_STRING_RETIP "__probe_ret_ip"
  39. #define FIELD_STRING_FUNC "__probe_func"
  40. #undef DEFINE_FIELD
  41. #define DEFINE_FIELD(type, item, name, is_signed) \
  42. do { \
  43. ret = trace_define_field(event_call, #type, name, \
  44. offsetof(typeof(field), item), \
  45. sizeof(field.item), is_signed, \
  46. FILTER_OTHER); \
  47. if (ret) \
  48. return ret; \
  49. } while (0)
  50. /* Flags for trace_probe */
  51. #define TP_FLAG_TRACE 1
  52. #define TP_FLAG_PROFILE 2
  53. /* data_loc: data location, compatible with u32 */
  54. #define make_data_loc(len, offs) \
  55. (((u32)(len) << 16) | ((u32)(offs) & 0xffff))
  56. #define get_loc_len(dl) ((u32)(dl) >> 16)
  57. #define get_loc_offs(dl) ((u32)(dl) & 0xffff)
  58. static nokprobe_inline void *get_loc_data(u32 *dl, void *ent)
  59. {
  60. return (u8 *)ent + get_loc_offs(*dl);
  61. }
  62. static nokprobe_inline u32 update_data_loc(u32 loc, int consumed)
  63. {
  64. u32 maxlen = get_loc_len(loc);
  65. u32 offset = get_loc_offs(loc);
  66. return make_data_loc(maxlen - consumed, offset + consumed);
  67. }
  68. /* Printing function type */
  69. typedef int (*print_type_func_t)(struct trace_seq *, void *, void *);
  70. enum fetch_op {
  71. FETCH_OP_NOP = 0,
  72. // Stage 1 (load) ops
  73. FETCH_OP_REG, /* Register : .param = offset */
  74. FETCH_OP_STACK, /* Stack : .param = index */
  75. FETCH_OP_STACKP, /* Stack pointer */
  76. FETCH_OP_RETVAL, /* Return value */
  77. FETCH_OP_IMM, /* Immediate : .immediate */
  78. FETCH_OP_COMM, /* Current comm */
  79. FETCH_OP_ARG, /* Function argument : .param */
  80. FETCH_OP_FOFFS, /* File offset: .immediate */
  81. FETCH_OP_DATA, /* Allocated data: .data */
  82. FETCH_OP_EDATA, /* Entry data: .offset */
  83. // Stage 2 (dereference) op
  84. FETCH_OP_DEREF, /* Dereference: .offset */
  85. FETCH_OP_UDEREF, /* User-space Dereference: .offset */
  86. // Stage 3 (store) ops
  87. FETCH_OP_ST_RAW, /* Raw: .size */
  88. FETCH_OP_ST_MEM, /* Mem: .offset, .size */
  89. FETCH_OP_ST_UMEM, /* Mem: .offset, .size */
  90. FETCH_OP_ST_STRING, /* String: .offset, .size */
  91. FETCH_OP_ST_USTRING, /* User String: .offset, .size */
  92. FETCH_OP_ST_SYMSTR, /* Kernel Symbol String: .offset, .size */
  93. FETCH_OP_ST_EDATA, /* Store Entry Data: .offset */
  94. // Stage 4 (modify) op
  95. FETCH_OP_MOD_BF, /* Bitfield: .basesize, .lshift, .rshift */
  96. // Stage 5 (loop) op
  97. FETCH_OP_LP_ARRAY, /* Array: .param = loop count */
  98. FETCH_OP_TP_ARG, /* Trace Point argument */
  99. FETCH_OP_END,
  100. FETCH_NOP_SYMBOL, /* Unresolved Symbol holder */
  101. };
  102. struct fetch_insn {
  103. enum fetch_op op;
  104. union {
  105. unsigned int param;
  106. struct {
  107. unsigned int size;
  108. int offset;
  109. };
  110. struct {
  111. unsigned char basesize;
  112. unsigned char lshift;
  113. unsigned char rshift;
  114. };
  115. unsigned long immediate;
  116. void *data;
  117. };
  118. };
  119. /* fetch + deref*N + store + mod + end <= 16, this allows N=12, enough */
  120. #define FETCH_INSN_MAX 16
  121. #define FETCH_TOKEN_COMM (-ECOMM)
  122. /* Fetch type information table */
  123. struct fetch_type {
  124. const char *name; /* Name of type */
  125. size_t size; /* Byte size of type */
  126. bool is_signed; /* Signed flag */
  127. bool is_string; /* String flag */
  128. print_type_func_t print; /* Print functions */
  129. const char *fmt; /* Format string */
  130. const char *fmttype; /* Name in format file */
  131. };
  132. /* For defining macros, define string/string_size types */
  133. typedef u32 string;
  134. typedef u32 string_size;
  135. #define PRINT_TYPE_FUNC_NAME(type) print_type_##type
  136. #define PRINT_TYPE_FMT_NAME(type) print_type_format_##type
  137. /* Printing in basic type function template */
  138. #define DECLARE_BASIC_PRINT_TYPE_FUNC(type) \
  139. int PRINT_TYPE_FUNC_NAME(type)(struct trace_seq *s, void *data, void *ent);\
  140. extern const char PRINT_TYPE_FMT_NAME(type)[]
  141. DECLARE_BASIC_PRINT_TYPE_FUNC(u8);
  142. DECLARE_BASIC_PRINT_TYPE_FUNC(u16);
  143. DECLARE_BASIC_PRINT_TYPE_FUNC(u32);
  144. DECLARE_BASIC_PRINT_TYPE_FUNC(u64);
  145. DECLARE_BASIC_PRINT_TYPE_FUNC(s8);
  146. DECLARE_BASIC_PRINT_TYPE_FUNC(s16);
  147. DECLARE_BASIC_PRINT_TYPE_FUNC(s32);
  148. DECLARE_BASIC_PRINT_TYPE_FUNC(s64);
  149. DECLARE_BASIC_PRINT_TYPE_FUNC(x8);
  150. DECLARE_BASIC_PRINT_TYPE_FUNC(x16);
  151. DECLARE_BASIC_PRINT_TYPE_FUNC(x32);
  152. DECLARE_BASIC_PRINT_TYPE_FUNC(x64);
  153. DECLARE_BASIC_PRINT_TYPE_FUNC(char);
  154. DECLARE_BASIC_PRINT_TYPE_FUNC(string);
  155. DECLARE_BASIC_PRINT_TYPE_FUNC(symbol);
  156. /* Default (unsigned long) fetch type */
  157. #define __DEFAULT_FETCH_TYPE(t) x##t
  158. #define _DEFAULT_FETCH_TYPE(t) __DEFAULT_FETCH_TYPE(t)
  159. #define DEFAULT_FETCH_TYPE _DEFAULT_FETCH_TYPE(BITS_PER_LONG)
  160. #define DEFAULT_FETCH_TYPE_STR __stringify(DEFAULT_FETCH_TYPE)
  161. #define __ADDR_FETCH_TYPE(t) u##t
  162. #define _ADDR_FETCH_TYPE(t) __ADDR_FETCH_TYPE(t)
  163. #define ADDR_FETCH_TYPE _ADDR_FETCH_TYPE(BITS_PER_LONG)
  164. #define __ASSIGN_FETCH_TYPE(_name, ptype, ftype, _size, sign, str, _fmttype) \
  165. {.name = _name, \
  166. .size = _size, \
  167. .is_signed = (bool)sign, \
  168. .is_string = (bool)str, \
  169. .print = PRINT_TYPE_FUNC_NAME(ptype), \
  170. .fmt = PRINT_TYPE_FMT_NAME(ptype), \
  171. .fmttype = _fmttype, \
  172. }
  173. /* Non string types can use these macros */
  174. #define _ASSIGN_FETCH_TYPE(_name, ptype, ftype, _size, sign, _fmttype) \
  175. __ASSIGN_FETCH_TYPE(_name, ptype, ftype, _size, sign, 0, #_fmttype)
  176. #define ASSIGN_FETCH_TYPE(ptype, ftype, sign) \
  177. _ASSIGN_FETCH_TYPE(#ptype, ptype, ftype, sizeof(ftype), sign, ptype)
  178. /* If ptype is an alias of atype, use this macro (show atype in format) */
  179. #define ASSIGN_FETCH_TYPE_ALIAS(ptype, atype, ftype, sign) \
  180. _ASSIGN_FETCH_TYPE(#ptype, ptype, ftype, sizeof(ftype), sign, atype)
  181. #define ASSIGN_FETCH_TYPE_END {}
  182. #define MAX_ARRAY_LEN 64
  183. #ifdef CONFIG_KPROBE_EVENTS
  184. bool trace_kprobe_on_func_entry(struct trace_event_call *call);
  185. bool trace_kprobe_error_injectable(struct trace_event_call *call);
  186. #else
  187. static inline bool trace_kprobe_on_func_entry(struct trace_event_call *call)
  188. {
  189. return false;
  190. }
  191. static inline bool trace_kprobe_error_injectable(struct trace_event_call *call)
  192. {
  193. return false;
  194. }
  195. #endif /* CONFIG_KPROBE_EVENTS */
  196. struct probe_arg {
  197. struct fetch_insn *code;
  198. bool dynamic;/* Dynamic array (string) is used */
  199. unsigned int offset; /* Offset from argument entry */
  200. unsigned int count; /* Array count */
  201. const char *name; /* Name of this argument */
  202. const char *comm; /* Command of this argument */
  203. char *fmt; /* Format string if needed */
  204. const struct fetch_type *type; /* Type of this argument */
  205. };
  206. struct probe_entry_arg {
  207. struct fetch_insn *code;
  208. unsigned int size; /* The entry data size */
  209. };
  210. struct trace_uprobe_filter {
  211. rwlock_t rwlock;
  212. int nr_systemwide;
  213. struct list_head perf_events;
  214. };
  215. /* Event call and class holder */
  216. struct trace_probe_event {
  217. unsigned int flags; /* For TP_FLAG_* */
  218. struct trace_event_class class;
  219. struct trace_event_call call;
  220. struct list_head files;
  221. struct list_head probes;
  222. struct trace_uprobe_filter filter[];
  223. };
  224. struct trace_probe {
  225. struct list_head list;
  226. struct trace_probe_event *event;
  227. ssize_t size; /* trace entry size */
  228. unsigned int nr_args;
  229. struct probe_entry_arg *entry_arg; /* This is only for return probe */
  230. struct probe_arg args[];
  231. };
  232. struct event_file_link {
  233. struct trace_event_file *file;
  234. struct list_head list;
  235. };
  236. static inline unsigned int trace_probe_load_flag(struct trace_probe *tp)
  237. {
  238. return smp_load_acquire(&tp->event->flags);
  239. }
  240. static inline bool trace_probe_test_flag(struct trace_probe *tp,
  241. unsigned int flag)
  242. {
  243. return !!(trace_probe_load_flag(tp) & flag);
  244. }
  245. static inline void trace_probe_set_flag(struct trace_probe *tp,
  246. unsigned int flag)
  247. {
  248. smp_store_release(&tp->event->flags, tp->event->flags | flag);
  249. }
  250. static inline void trace_probe_clear_flag(struct trace_probe *tp,
  251. unsigned int flag)
  252. {
  253. tp->event->flags &= ~flag;
  254. }
  255. static inline bool trace_probe_is_enabled(struct trace_probe *tp)
  256. {
  257. return trace_probe_test_flag(tp, TP_FLAG_TRACE | TP_FLAG_PROFILE);
  258. }
  259. static inline const char *trace_probe_name(struct trace_probe *tp)
  260. {
  261. return trace_event_name(&tp->event->call);
  262. }
  263. static inline const char *trace_probe_group_name(struct trace_probe *tp)
  264. {
  265. return tp->event->call.class->system;
  266. }
  267. static inline struct trace_event_call *
  268. trace_probe_event_call(struct trace_probe *tp)
  269. {
  270. return &tp->event->call;
  271. }
  272. static inline struct trace_probe_event *
  273. trace_probe_event_from_call(struct trace_event_call *event_call)
  274. {
  275. return container_of(event_call, struct trace_probe_event, call);
  276. }
  277. static inline struct trace_probe *
  278. trace_probe_primary_from_call(struct trace_event_call *call)
  279. {
  280. struct trace_probe_event *tpe = trace_probe_event_from_call(call);
  281. return list_first_entry_or_null(&tpe->probes, struct trace_probe, list);
  282. }
  283. static inline struct list_head *trace_probe_probe_list(struct trace_probe *tp)
  284. {
  285. return &tp->event->probes;
  286. }
  287. static inline bool trace_probe_has_sibling(struct trace_probe *tp)
  288. {
  289. struct list_head *list = trace_probe_probe_list(tp);
  290. return !list_empty(list) && !list_is_singular(list);
  291. }
  292. static inline int trace_probe_unregister_event_call(struct trace_probe *tp)
  293. {
  294. /* tp->event is unregistered in trace_remove_event_call() */
  295. return trace_remove_event_call(&tp->event->call);
  296. }
  297. static inline bool trace_probe_has_single_file(struct trace_probe *tp)
  298. {
  299. return !!list_is_singular(&tp->event->files);
  300. }
  301. int trace_probe_init(struct trace_probe *tp, const char *event,
  302. const char *group, bool alloc_filter, int nargs);
  303. void trace_probe_cleanup(struct trace_probe *tp);
  304. int trace_probe_append(struct trace_probe *tp, struct trace_probe *to);
  305. void trace_probe_unlink(struct trace_probe *tp);
  306. int trace_probe_register_event_call(struct trace_probe *tp);
  307. int trace_probe_add_file(struct trace_probe *tp, struct trace_event_file *file);
  308. int trace_probe_remove_file(struct trace_probe *tp,
  309. struct trace_event_file *file);
  310. struct event_file_link *trace_probe_get_file_link(struct trace_probe *tp,
  311. struct trace_event_file *file);
  312. int trace_probe_compare_arg_type(struct trace_probe *a, struct trace_probe *b);
  313. bool trace_probe_match_command_args(struct trace_probe *tp,
  314. int argc, const char **argv);
  315. int trace_probe_create(const char *raw_command, int (*createfn)(int, const char **));
  316. int trace_probe_print_args(struct trace_seq *s, struct probe_arg *args, int nr_args,
  317. u8 *data, void *field);
  318. #ifdef CONFIG_HAVE_FUNCTION_ARG_ACCESS_API
  319. int traceprobe_get_entry_data_size(struct trace_probe *tp);
  320. /* This is a runtime function to store entry data */
  321. void store_trace_entry_data(void *edata, struct trace_probe *tp, struct pt_regs *regs);
  322. #else /* !CONFIG_HAVE_FUNCTION_ARG_ACCESS_API */
  323. static inline int traceprobe_get_entry_data_size(struct trace_probe *tp)
  324. {
  325. return 0;
  326. }
  327. #define store_trace_entry_data(edata, tp, regs) do { } while (0)
  328. #endif
  329. #define trace_probe_for_each_link(pos, tp) \
  330. list_for_each_entry(pos, &(tp)->event->files, list)
  331. #define trace_probe_for_each_link_rcu(pos, tp) \
  332. list_for_each_entry_rcu(pos, &(tp)->event->files, list)
  333. /*
  334. * The flags used for parsing trace_probe arguments.
  335. * TPARG_FL_RETURN, TPARG_FL_FENTRY and TPARG_FL_TEVENT are mutually exclusive.
  336. * TPARG_FL_KERNEL and TPARG_FL_USER are also mutually exclusive.
  337. * TPARG_FL_FPROBE and TPARG_FL_TPOINT are optional but it should be with
  338. * TPARG_FL_KERNEL.
  339. */
  340. #define TPARG_FL_RETURN BIT(0)
  341. #define TPARG_FL_KERNEL BIT(1)
  342. #define TPARG_FL_FENTRY BIT(2)
  343. #define TPARG_FL_TEVENT BIT(3)
  344. #define TPARG_FL_USER BIT(4)
  345. #define TPARG_FL_FPROBE BIT(5)
  346. #define TPARG_FL_TPOINT BIT(6)
  347. #define TPARG_FL_LOC_MASK GENMASK(4, 0)
  348. static inline bool tparg_is_function_entry(unsigned int flags)
  349. {
  350. return (flags & TPARG_FL_LOC_MASK) == (TPARG_FL_KERNEL | TPARG_FL_FENTRY);
  351. }
  352. static inline bool tparg_is_function_return(unsigned int flags)
  353. {
  354. return (flags & TPARG_FL_LOC_MASK) == (TPARG_FL_KERNEL | TPARG_FL_RETURN);
  355. }
  356. struct traceprobe_parse_context {
  357. struct trace_event_call *event;
  358. /* BTF related parameters */
  359. const char *funcname; /* Function name in BTF */
  360. const struct btf_type *proto; /* Prototype of the function */
  361. const struct btf_param *params; /* Parameter of the function */
  362. s32 nr_params; /* The number of the parameters */
  363. struct btf *btf; /* The BTF to be used */
  364. const struct btf_type *last_type; /* Saved type */
  365. u32 last_bitoffs; /* Saved bitoffs */
  366. u32 last_bitsize; /* Saved bitsize */
  367. struct trace_probe *tp;
  368. unsigned int flags;
  369. int offset;
  370. };
  371. extern int traceprobe_parse_probe_arg(struct trace_probe *tp, int i,
  372. const char *argv,
  373. struct traceprobe_parse_context *ctx);
  374. const char **traceprobe_expand_meta_args(int argc, const char *argv[],
  375. int *new_argc, char *buf, int bufsize,
  376. struct traceprobe_parse_context *ctx);
  377. extern int traceprobe_expand_dentry_args(int argc, const char *argv[], char **buf);
  378. extern int traceprobe_update_arg(struct probe_arg *arg);
  379. extern void traceprobe_free_probe_arg(struct probe_arg *arg);
  380. /*
  381. * If either traceprobe_parse_probe_arg() or traceprobe_expand_meta_args() is called,
  382. * this MUST be called for clean up the context and return a resource.
  383. */
  384. void traceprobe_finish_parse(struct traceprobe_parse_context *ctx);
  385. extern int traceprobe_split_symbol_offset(char *symbol, long *offset);
  386. int traceprobe_parse_event_name(const char **pevent, const char **pgroup,
  387. char *buf, int offset);
  388. enum probe_print_type {
  389. PROBE_PRINT_NORMAL,
  390. PROBE_PRINT_RETURN,
  391. PROBE_PRINT_EVENT,
  392. };
  393. extern int traceprobe_set_print_fmt(struct trace_probe *tp, enum probe_print_type ptype);
  394. #ifdef CONFIG_PERF_EVENTS
  395. extern struct trace_event_call *
  396. create_local_trace_kprobe(char *func, void *addr, unsigned long offs,
  397. bool is_return);
  398. extern void destroy_local_trace_kprobe(struct trace_event_call *event_call);
  399. extern struct trace_event_call *
  400. create_local_trace_uprobe(char *name, unsigned long offs,
  401. unsigned long ref_ctr_offset, bool is_return);
  402. extern void destroy_local_trace_uprobe(struct trace_event_call *event_call);
  403. #endif
  404. extern int traceprobe_define_arg_fields(struct trace_event_call *event_call,
  405. size_t offset, struct trace_probe *tp);
  406. #undef ERRORS
  407. #define ERRORS \
  408. C(FILE_NOT_FOUND, "Failed to find the given file"), \
  409. C(NO_REGULAR_FILE, "Not a regular file"), \
  410. C(BAD_REFCNT, "Invalid reference counter offset"), \
  411. C(REFCNT_OPEN_BRACE, "Reference counter brace is not closed"), \
  412. C(BAD_REFCNT_SUFFIX, "Reference counter has wrong suffix"), \
  413. C(BAD_UPROBE_OFFS, "Invalid uprobe offset"), \
  414. C(BAD_MAXACT_TYPE, "Maxactive is only for function exit"), \
  415. C(BAD_MAXACT, "Invalid maxactive number"), \
  416. C(MAXACT_TOO_BIG, "Maxactive is too big"), \
  417. C(BAD_PROBE_ADDR, "Invalid probed address or symbol"), \
  418. C(NON_UNIQ_SYMBOL, "The symbol is not unique"), \
  419. C(BAD_RETPROBE, "Retprobe address must be an function entry"), \
  420. C(NO_TRACEPOINT, "Tracepoint is not found"), \
  421. C(BAD_TP_NAME, "Invalid character in tracepoint name"),\
  422. C(BAD_ADDR_SUFFIX, "Invalid probed address suffix"), \
  423. C(NO_GROUP_NAME, "Group name is not specified"), \
  424. C(GROUP_TOO_LONG, "Group name is too long"), \
  425. C(BAD_GROUP_NAME, "Group name must follow the same rules as C identifiers"), \
  426. C(NO_EVENT_NAME, "Event name is not specified"), \
  427. C(EVENT_TOO_LONG, "Event name is too long"), \
  428. C(BAD_EVENT_NAME, "Event name must follow the same rules as C identifiers"), \
  429. C(EVENT_EXIST, "Given group/event name is already used by another event"), \
  430. C(RETVAL_ON_PROBE, "$retval is not available on probe"), \
  431. C(NO_RETVAL, "This function returns 'void' type"), \
  432. C(BAD_STACK_NUM, "Invalid stack number"), \
  433. C(BAD_ARG_NUM, "Invalid argument number"), \
  434. C(BAD_VAR, "Invalid $-valiable specified"), \
  435. C(BAD_REG_NAME, "Invalid register name"), \
  436. C(BAD_MEM_ADDR, "Invalid memory address"), \
  437. C(BAD_IMM, "Invalid immediate value"), \
  438. C(IMMSTR_NO_CLOSE, "String is not closed with '\"'"), \
  439. C(FILE_ON_KPROBE, "File offset is not available with kprobe"), \
  440. C(BAD_FILE_OFFS, "Invalid file offset value"), \
  441. C(SYM_ON_UPROBE, "Symbol is not available with uprobe"), \
  442. C(TOO_MANY_OPS, "Dereference is too much nested"), \
  443. C(DEREF_NEED_BRACE, "Dereference needs a brace"), \
  444. C(BAD_DEREF_OFFS, "Invalid dereference offset"), \
  445. C(DEREF_OPEN_BRACE, "Dereference brace is not closed"), \
  446. C(COMM_CANT_DEREF, "$comm can not be dereferenced"), \
  447. C(BAD_FETCH_ARG, "Invalid fetch argument"), \
  448. C(ARRAY_NO_CLOSE, "Array is not closed"), \
  449. C(BAD_ARRAY_SUFFIX, "Array has wrong suffix"), \
  450. C(BAD_ARRAY_NUM, "Invalid array size"), \
  451. C(ARRAY_TOO_BIG, "Array number is too big"), \
  452. C(BAD_TYPE, "Unknown type is specified"), \
  453. C(BAD_STRING, "String accepts only memory argument"), \
  454. C(BAD_SYMSTRING, "Symbol String doesn't accept data/userdata"), \
  455. C(BAD_BITFIELD, "Invalid bitfield"), \
  456. C(ARG_NAME_TOO_LONG, "Argument name is too long"), \
  457. C(NO_ARG_NAME, "Argument name is not specified"), \
  458. C(BAD_ARG_NAME, "Argument name must follow the same rules as C identifiers"), \
  459. C(USED_ARG_NAME, "This argument name is already used"), \
  460. C(ARG_TOO_LONG, "Argument expression is too long"), \
  461. C(NO_ARG_BODY, "No argument expression"), \
  462. C(BAD_INSN_BNDRY, "Probe point is not an instruction boundary"),\
  463. C(FAIL_REG_PROBE, "Failed to register probe event"),\
  464. C(DIFF_PROBE_TYPE, "Probe type is different from existing probe"),\
  465. C(DIFF_ARG_TYPE, "Argument type or name is different from existing probe"),\
  466. C(SAME_PROBE, "There is already the exact same probe event"),\
  467. C(NO_EVENT_INFO, "This requires both group and event name to attach"),\
  468. C(BAD_ATTACH_EVENT, "Attached event does not exist"),\
  469. C(BAD_ATTACH_ARG, "Attached event does not have this field"),\
  470. C(NO_EP_FILTER, "No filter rule after 'if'"), \
  471. C(NOSUP_BTFARG, "BTF is not available or not supported"), \
  472. C(NO_BTFARG, "This variable is not found at this probe point"),\
  473. C(NO_BTF_ENTRY, "No BTF entry for this probe point"), \
  474. C(BAD_VAR_ARGS, "$arg* must be an independent parameter without name etc."),\
  475. C(NOFENTRY_ARGS, "$arg* can be used only on function entry or exit"), \
  476. C(DOUBLE_ARGS, "$arg* can be used only once in the parameters"), \
  477. C(ARGS_2LONG, "$arg* failed because the argument list is too long"), \
  478. C(ARGIDX_2BIG, "$argN index is too big"), \
  479. C(NO_PTR_STRCT, "This is not a pointer to union/structure."), \
  480. C(NOSUP_DAT_ARG, "Non pointer structure/union argument is not supported."),\
  481. C(BAD_HYPHEN, "Failed to parse single hyphen. Forgot '>'?"), \
  482. C(NO_BTF_FIELD, "This field is not found."), \
  483. C(BAD_BTF_TID, "Failed to get BTF type info."),\
  484. C(BAD_TYPE4STR, "This type does not fit for string."),\
  485. C(NEED_STRING_TYPE, "$comm and immediate-string only accepts string type"),
  486. #undef C
  487. #define C(a, b) TP_ERR_##a
  488. /* Define TP_ERR_ */
  489. enum { ERRORS };
  490. /* Error text is defined in trace_probe.c */
  491. struct trace_probe_log {
  492. const char *subsystem;
  493. const char **argv;
  494. int argc;
  495. int index;
  496. };
  497. void trace_probe_log_init(const char *subsystem, int argc, const char **argv);
  498. void trace_probe_log_set_index(int index);
  499. void trace_probe_log_clear(void);
  500. void __trace_probe_log_err(int offset, int err);
  501. #define trace_probe_log_err(offs, err) \
  502. __trace_probe_log_err(offs, TP_ERR_##err)
  503. struct uprobe_dispatch_data {
  504. struct trace_uprobe *tu;
  505. unsigned long bp_addr;
  506. };