Lines Matching refs:ctx

318 				 struct traceprobe_parse_context *ctx)  in parse_trace_event_arg()  argument
323 head = trace_get_fields(ctx->event); in parse_trace_event_arg()
380 struct traceprobe_parse_context *ctx) in check_prepare_btf_string_fetch() argument
382 struct btf *btf = ctx->btf; in check_prepare_btf_string_fetch()
384 if (!btf || !ctx->last_type) in check_prepare_btf_string_fetch()
388 if (btf_type_is_char_array(btf, ctx->last_type)) in check_prepare_btf_string_fetch()
392 if (btf_type_is_char_ptr(btf, ctx->last_type)) { in check_prepare_btf_string_fetch()
396 trace_probe_log_err(ctx->offset, TOO_MANY_OPS); in check_prepare_btf_string_fetch()
408 trace_probe_log_err(ctx->offset, BAD_TYPE4STR); in check_prepare_btf_string_fetch()
414 struct traceprobe_parse_context *ctx) in fetch_type_from_btf_type() argument
456 ctx->last_bitsize = BTF_INT_BITS(intdata); in fetch_type_from_btf_type()
457 ctx->last_bitoffs += BTF_INT_OFFSET(intdata); in fetch_type_from_btf_type()
466 static int query_btf_context(struct traceprobe_parse_context *ctx) in query_btf_context() argument
473 if (ctx->btf) in query_btf_context()
476 if (!ctx->funcname) in query_btf_context()
479 type = btf_find_func_proto(ctx->funcname, &btf); in query_btf_context()
483 ctx->btf = btf; in query_btf_context()
484 ctx->proto = type; in query_btf_context()
491 if (ctx->flags & TPARG_FL_TPOINT) { in query_btf_context()
498 ctx->nr_params = nr; in query_btf_context()
499 ctx->params = param; in query_btf_context()
501 ctx->nr_params = 0; in query_btf_context()
502 ctx->params = NULL; in query_btf_context()
508 static void clear_btf_context(struct traceprobe_parse_context *ctx) in clear_btf_context() argument
510 if (ctx->btf) { in clear_btf_context()
511 btf_put(ctx->btf); in clear_btf_context()
512 ctx->btf = NULL; in clear_btf_context()
513 ctx->proto = NULL; in clear_btf_context()
514 ctx->params = NULL; in clear_btf_context()
515 ctx->nr_params = 0; in clear_btf_context()
521 struct traceprobe_parse_context *ctx) in split_next_field() argument
536 trace_probe_log_err(ctx->offset + field - varname, BAD_HYPHEN); in split_next_field()
551 struct traceprobe_parse_context *ctx) in parse_btf_field() argument
563 trace_probe_log_err(ctx->offset, NO_PTR_STRCT); in parse_btf_field()
567 type = btf_type_skip_modifiers(ctx->btf, type->type, &tid); in parse_btf_field()
569 trace_probe_log_err(ctx->offset, BAD_BTF_TID); in parse_btf_field()
577 is_ptr = split_next_field(fieldname, &next, ctx); in parse_btf_field()
582 field = btf_find_struct_member(ctx->btf, type, fieldname, in parse_btf_field()
585 trace_probe_log_err(ctx->offset, BAD_BTF_TID); in parse_btf_field()
589 trace_probe_log_err(ctx->offset, NO_BTF_FIELD); in parse_btf_field()
598 ctx->last_bitsize = BTF_MEMBER_BITFIELD_SIZE(field->offset); in parse_btf_field()
601 ctx->last_bitsize = 0; in parse_btf_field()
604 type = btf_type_skip_modifiers(ctx->btf, field->type, &tid); in parse_btf_field()
606 trace_probe_log_err(ctx->offset, BAD_BTF_TID); in parse_btf_field()
610 ctx->offset += next - fieldname; in parse_btf_field()
615 trace_probe_log_err(ctx->offset, TOO_MANY_OPS); in parse_btf_field()
622 ctx->last_bitoffs = bitoffs % 8; in parse_btf_field()
623 ctx->last_type = type; in parse_btf_field()
633 struct traceprobe_parse_context *ctx) in parse_btf_arg() argument
642 if (WARN_ON_ONCE(!ctx->funcname)) in parse_btf_arg()
645 is_ptr = split_next_field(varname, &field, ctx); in parse_btf_arg()
650 trace_probe_log_err(ctx->offset + field - varname, in parse_btf_arg()
655 if (ctx->flags & TPARG_FL_RETURN && !strcmp(varname, "$retval")) { in parse_btf_arg()
658 if (query_btf_context(ctx) == 0) { in parse_btf_arg()
659 if (ctx->proto->type == 0) { in parse_btf_arg()
660 trace_probe_log_err(ctx->offset, NO_RETVAL); in parse_btf_arg()
663 tid = ctx->proto->type; in parse_btf_arg()
667 trace_probe_log_err(ctx->offset + field - varname, in parse_btf_arg()
674 if (!ctx->btf) { in parse_btf_arg()
675 ret = query_btf_context(ctx); in parse_btf_arg()
676 if (ret < 0 || ctx->nr_params == 0) { in parse_btf_arg()
677 trace_probe_log_err(ctx->offset, NO_BTF_ENTRY); in parse_btf_arg()
681 params = ctx->params; in parse_btf_arg()
683 for (i = 0; i < ctx->nr_params; i++) { in parse_btf_arg()
684 const char *name = btf_name_by_offset(ctx->btf, params[i].name_off); in parse_btf_arg()
687 if (tparg_is_function_entry(ctx->flags)) { in parse_btf_arg()
689 if (ctx->flags & TPARG_FL_TPOINT) in parse_btf_arg()
693 } else if (tparg_is_function_return(ctx->flags)) { in parse_btf_arg()
695 ret = __store_entry_arg(ctx->tp, i); in parse_btf_arg()
706 trace_probe_log_err(ctx->offset, NO_BTFARG); in parse_btf_arg()
710 type = btf_type_skip_modifiers(ctx->btf, tid, &tid); in parse_btf_arg()
712 trace_probe_log_err(ctx->offset, BAD_BTF_TID); in parse_btf_arg()
716 ctx->last_type = type; in parse_btf_arg()
717 ctx->last_bitoffs = 0; in parse_btf_arg()
718 ctx->last_bitsize = 0; in parse_btf_arg()
720 ctx->offset += field - varname; in parse_btf_arg()
721 return parse_btf_field(field, type, pcode, end, ctx); in parse_btf_arg()
727 struct traceprobe_parse_context *ctx) in find_fetch_type_from_btf_type() argument
729 struct btf *btf = ctx->btf; in find_fetch_type_from_btf_type()
732 if (btf && ctx->last_type) in find_fetch_type_from_btf_type()
733 typestr = fetch_type_from_btf_type(btf, ctx->last_type, ctx); in find_fetch_type_from_btf_type()
735 return find_fetch_type(typestr, ctx->flags); in find_fetch_type_from_btf_type()
739 struct traceprobe_parse_context *ctx) in parse_btf_bitfield() argument
743 if ((ctx->last_bitsize % 8 == 0) && ctx->last_bitoffs == 0) in parse_btf_bitfield()
748 trace_probe_log_err(ctx->offset, TOO_MANY_OPS); in parse_btf_bitfield()
754 code->lshift = 64 - (ctx->last_bitsize + ctx->last_bitoffs); in parse_btf_bitfield()
755 code->rshift = 64 - ctx->last_bitsize; in parse_btf_bitfield()
761 static void clear_btf_context(struct traceprobe_parse_context *ctx) in clear_btf_context() argument
763 ctx->btf = NULL; in clear_btf_context()
766 static int query_btf_context(struct traceprobe_parse_context *ctx) in query_btf_context() argument
773 struct traceprobe_parse_context *ctx) in parse_btf_arg() argument
775 trace_probe_log_err(ctx->offset, NOSUP_BTFARG); in parse_btf_arg()
780 struct traceprobe_parse_context *ctx) in parse_btf_bitfield() argument
782 trace_probe_log_err(ctx->offset, NOSUP_BTFARG); in parse_btf_bitfield()
786 #define find_fetch_type_from_btf_type(ctx) \ argument
787 find_fetch_type(NULL, ctx->flags)
791 struct traceprobe_parse_context *ctx) in check_prepare_btf_string_fetch() argument
946 struct traceprobe_parse_context *ctx) in NOKPROBE_SYMBOL()
955 if (ctx->flags & TPARG_FL_TEVENT) { in NOKPROBE_SYMBOL()
958 ret = parse_trace_event_arg(arg, code, ctx); in NOKPROBE_SYMBOL()
966 ctx->offset = 0; in NOKPROBE_SYMBOL()
971 if (!(ctx->flags & TPARG_FL_RETURN)) { in NOKPROBE_SYMBOL()
975 if (!(ctx->flags & TPARG_FL_KERNEL) || in NOKPROBE_SYMBOL()
980 return parse_btf_arg(orig_arg, pcode, end, ctx); in NOKPROBE_SYMBOL()
996 if ((ctx->flags & TPARG_FL_KERNEL) && in NOKPROBE_SYMBOL()
1026 if (tparg_is_function_entry(ctx->flags)) { in NOKPROBE_SYMBOL()
1033 if (ctx->flags & TPARG_FL_TPOINT) in NOKPROBE_SYMBOL()
1035 } else if (tparg_is_function_return(ctx->flags)) { in NOKPROBE_SYMBOL()
1037 ret = __store_entry_arg(ctx->tp, param); in NOKPROBE_SYMBOL()
1052 __trace_probe_log_err(ctx->offset, err); in NOKPROBE_SYMBOL()
1085 struct traceprobe_parse_context *ctx) in parse_probe_arg() argument
1096 ret = parse_probe_vars(arg, type, pcode, end, ctx); in parse_probe_arg()
1100 if (ctx->flags & (TPARG_FL_TEVENT | TPARG_FL_FPROBE)) { in parse_probe_arg()
1102 trace_probe_log_err(ctx->offset, BAD_VAR); in parse_probe_arg()
1111 trace_probe_log_err(ctx->offset, BAD_REG_NAME); in parse_probe_arg()
1118 trace_probe_log_err(ctx->offset, BAD_MEM_ADDR); in parse_probe_arg()
1126 if (ctx->flags & TPARG_FL_KERNEL) { in parse_probe_arg()
1127 trace_probe_log_err(ctx->offset, FILE_ON_KPROBE); in parse_probe_arg()
1132 trace_probe_log_err(ctx->offset, BAD_FILE_OFFS); in parse_probe_arg()
1140 if (!(ctx->flags & TPARG_FL_KERNEL)) { in parse_probe_arg()
1141 trace_probe_log_err(ctx->offset, SYM_ON_UPROBE); in parse_probe_arg()
1150 trace_probe_log_err(ctx->offset, TOO_MANY_OPS); in parse_probe_arg()
1158 trace_probe_log_err(ctx->offset, TOO_MANY_OPS); in parse_probe_arg()
1177 trace_probe_log_err(ctx->offset, DEREF_NEED_BRACE); in parse_probe_arg()
1183 trace_probe_log_err(ctx->offset, BAD_DEREF_OFFS); in parse_probe_arg()
1186 ctx->offset += (tmp + 1 - arg) + (arg[0] != '-' ? 1 : 0); in parse_probe_arg()
1190 trace_probe_log_err(ctx->offset + strlen(arg), in parse_probe_arg()
1194 const struct fetch_type *t2 = find_fetch_type(NULL, ctx->flags); in parse_probe_arg()
1195 int cur_offs = ctx->offset; in parse_probe_arg()
1198 ret = parse_probe_arg(arg, t2, &code, end, ctx); in parse_probe_arg()
1201 ctx->offset = cur_offs; in parse_probe_arg()
1204 trace_probe_log_err(ctx->offset, COMM_CANT_DEREF); in parse_probe_arg()
1208 trace_probe_log_err(ctx->offset, TOO_MANY_OPS); in parse_probe_arg()
1216 ctx->last_type = NULL; in parse_probe_arg()
1221 ret = __parse_imm_string(arg + 2, &tmp, ctx->offset + 2); in parse_probe_arg()
1229 trace_probe_log_err(ctx->offset + 1, BAD_IMM); in parse_probe_arg()
1236 if (!tparg_is_function_entry(ctx->flags) && in parse_probe_arg()
1237 !tparg_is_function_return(ctx->flags)) { in parse_probe_arg()
1238 trace_probe_log_err(ctx->offset, NOSUP_BTFARG); in parse_probe_arg()
1241 ret = parse_btf_arg(arg, pcode, end, ctx); in parse_probe_arg()
1247 trace_probe_log_err(ctx->offset, BAD_FETCH_ARG); in parse_probe_arg()
1290 struct traceprobe_parse_context *ctx) in parse_probe_arg_type() argument
1305 trace_probe_log_err(ctx->offset + offs, in parse_probe_arg_type()
1309 trace_probe_log_err(ctx->offset + t3 + 1 - arg, in parse_probe_arg_type()
1315 trace_probe_log_err(ctx->offset + t2 - arg, in parse_probe_arg_type()
1320 trace_probe_log_err(ctx->offset + t2 - arg, in parse_probe_arg_type()
1332 if (!(ctx->flags & TPARG_FL_TEVENT) && in parse_probe_arg_type()
1337 trace_probe_log_err(ctx->offset + offs, NEED_STRING_TYPE); in parse_probe_arg_type()
1340 parg->type = find_fetch_type("string", ctx->flags); in parse_probe_arg_type()
1342 parg->type = find_fetch_type(t, ctx->flags); in parse_probe_arg_type()
1345 trace_probe_log_err(ctx->offset + offs, BAD_TYPE); in parse_probe_arg_type()
1357 struct traceprobe_parse_context *ctx) in finalize_fetch_insn() argument
1369 trace_probe_log_err(ctx->offset + type_offset, in finalize_fetch_insn()
1377 trace_probe_log_err(ctx->offset + type_offset, in finalize_fetch_insn()
1397 trace_probe_log_err(ctx->offset, TOO_MANY_OPS); in finalize_fetch_insn()
1421 trace_probe_log_err(ctx->offset, TOO_MANY_OPS); in finalize_fetch_insn()
1436 trace_probe_log_err(ctx->offset + type_offset, BAD_BITFIELD); in finalize_fetch_insn()
1440 ctx->last_type) { in finalize_fetch_insn()
1442 ret = parse_btf_bitfield(&code, ctx); in finalize_fetch_insn()
1452 trace_probe_log_err(ctx->offset + type_offset, BAD_STRING); in finalize_fetch_insn()
1457 trace_probe_log_err(ctx->offset, TOO_MANY_OPS); in finalize_fetch_insn()
1474 struct traceprobe_parse_context *ctx) in traceprobe_parse_probe_arg_body() argument
1482 trace_probe_log_err(ctx->offset, ARG_TOO_LONG); in traceprobe_parse_probe_arg_body()
1485 trace_probe_log_err(ctx->offset, NO_ARG_BODY); in traceprobe_parse_probe_arg_body()
1497 type = parse_probe_arg_type(arg, parg, ctx); in traceprobe_parse_probe_arg_body()
1506 ctx->last_type = NULL; in traceprobe_parse_probe_arg_body()
1508 ctx); in traceprobe_parse_probe_arg_body()
1514 ctx->last_type) { in traceprobe_parse_probe_arg_body()
1516 parg->type = find_fetch_type_from_btf_type(ctx); in traceprobe_parse_probe_arg_body()
1518 ret = check_prepare_btf_string_fetch(type, &code, ctx); in traceprobe_parse_probe_arg_body()
1537 ret = finalize_fetch_insn(code, parg, type, type ? type - arg : 0, ctx); in traceprobe_parse_probe_arg_body()
1608 struct traceprobe_parse_context *ctx) in traceprobe_parse_probe_arg() argument
1613 ctx->tp = tp; in traceprobe_parse_probe_arg()
1640 ctx->offset = body - arg; in traceprobe_parse_probe_arg()
1642 return traceprobe_parse_probe_arg_body(body, &tp->size, parg, ctx); in traceprobe_parse_probe_arg()
1662 struct traceprobe_parse_context *ctx) in argv_has_var_arg() argument
1670 if (!tparg_is_function_entry(ctx->flags) && in argv_has_var_arg()
1671 !tparg_is_function_return(ctx->flags)) { in argv_has_var_arg()
1699 struct traceprobe_parse_context *ctx) in sprint_nth_btf_arg() argument
1704 if (idx >= ctx->nr_params) { in sprint_nth_btf_arg()
1708 name = btf_name_by_offset(ctx->btf, ctx->params[idx].name_off); in sprint_nth_btf_arg()
1724 struct traceprobe_parse_context *ctx) in traceprobe_expand_meta_args() argument
1730 ret = argv_has_var_arg(argc, argv, &args_idx, ctx); in traceprobe_expand_meta_args()
1739 ret = query_btf_context(ctx); in traceprobe_expand_meta_args()
1740 if (ret < 0 || ctx->nr_params == 0) { in traceprobe_expand_meta_args()
1751 *new_argc = argc + ctx->nr_params - 1; in traceprobe_expand_meta_args()
1763 for (n = 0; n < ctx->nr_params; n++) { in traceprobe_expand_meta_args()
1765 bufsize - used, ctx); in traceprobe_expand_meta_args()
1785 bufsize - used, ctx); in traceprobe_expand_meta_args()
1855 void traceprobe_finish_parse(struct traceprobe_parse_context *ctx) in traceprobe_finish_parse() argument
1857 clear_btf_context(ctx); in traceprobe_finish_parse()