trace_probe.h 19 KB

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