| @@ -356,61 +356,10 @@ parse_probe_arg(char *arg, const struct fetch_type *type, · 355 unmodified lines |
| 356 | struct fetch_insn **pcode, struct fetch_insn *end, | 356 | struct fetch_insn **pcode, struct fetch_insn *end, |
| 357 | struct traceprobe_parse_context *ctx); | 357 | struct traceprobe_parse_context *ctx); |
| 358 | | 358 | |
| 359 | /* handle dereference nested call */ | 359 | static int parse_this_cpu(char *arg, struct traceprobe_parse_context *ctx) |
| 360 | static inline int handle_dereference(char *arg, struct fetch_insn **pcode, | | |
| 361 | struct fetch_insn *end, struct traceprobe_parse_context *ctx, | | |
| 362 | int deref, long offset) | | |
| 363 | { | 360 | { |
| 364 | const struct fetch_type *type = find_fetch_type(NULL, ctx->flags); | 361 | bool is_read = false; |
| 365 | struct fetch_insn *code = *pcode; | | |
| 366 | int cur_offs = ctx->offset; | | |
| 367 | char *tmp; | 362 | char *tmp; |
| 368 | int ret; | | |
| 369 | | | |
| 370 | tmp = strrchr(arg, ')'); | | |
| 371 | if (!tmp) { | | |
| 372 | trace_probe_log_err(ctx->offset + strlen(arg), | | |
| 373 | DEREF_OPEN_BRACE); | | |
| 374 | return -EINVAL; | | |
| 375 | } | | |
| 376 | | | |
| 377 | *tmp = '\0'; | | |
| 378 | ret = parse_probe_arg(arg, type, &code, end, ctx); | | |
| 379 | if (ret) | | |
| 380 | return ret; | | |
| 381 | ctx->offset = cur_offs; | | |
| 382 | if (code->op == FETCH_OP_COMM || code->op == FETCH_OP_IMMSTR) { | | |
| 383 | trace_probe_log_err(ctx->offset, COMM_CANT_DEREF); | | |
| 384 | return -EINVAL; | | |
| 385 | } | | |
| 386 | | | |
| 387 | /* | | |
| 388 | * this_cpu_ptr(@SYM) does not use SYM value, but use SYM address. | | |
| 389 | * So we overwrite the last FETCH_OP_DEREF with FETCH_OP_CPU_PTR. | | |
| 390 | */ | | |
| 391 | if (!(deref == FETCH_OP_CPU_PTR && *arg == '@')) { | | |
| 392 | code++; | | |
| 393 | if (code == end) { | | |
| 394 | trace_probe_log_err(ctx->offset, TOO_MANY_OPS); | | |
| 395 | return -EINVAL; | | |
| 396 | } | | |
| 397 | } | | |
| 398 | *pcode = code; | | |
| 399 | | | |
| 400 | code->op = deref; | | |
| 401 | code->offset = offset; | | |
| 402 | /* Reset the last type if used */ | | |
| 403 | ctx->last_type = NULL; | | |
| 404 | return 0; | | |
| 405 | } | | |
| 406 | | | |
| 407 | static int parse_this_cpu(char *arg, struct fetch_insn **pcode, | | |
| 408 | struct fetch_insn *end, | | |
| 409 | struct traceprobe_parse_context *ctx) | | |
| 410 | { | | |
| 411 | struct fetch_insn *code; | | |
| 412 | bool is_ptr = false; | | |
| 413 | int ret; | | |
| 414 | | 363 | |
| 415 | /* | 364 | /* |
| 416 | * This is only for kernel probes, excluding eprobe, because per-cpu | 365 | * This is only for kernel probes, excluding eprobe, because per-cpu |
| @@ -424,27 +373,29 @@ static int parse_this_cpu(char *arg, struct fetch_insn **pcode, · 7 unmodified lines |
| 424 | if (str_has_prefix(arg, THIS_CPU_PTR_PREFIX)) { | 373 | if (str_has_prefix(arg, THIS_CPU_PTR_PREFIX)) { |
| 425 | arg += THIS_CPU_PTR_LEN; | 374 | arg += THIS_CPU_PTR_LEN; |
| 426 | ctx->offset += THIS_CPU_PTR_LEN; | 375 | ctx->offset += THIS_CPU_PTR_LEN; |
| 427 | is_ptr = true; | | |
| 428 | } else if (str_has_prefix(arg, THIS_CPU_READ_PREFIX)) { | 376 | } else if (str_has_prefix(arg, THIS_CPU_READ_PREFIX)) { |
| 429 | arg += THIS_CPU_READ_LEN; | 377 | arg += THIS_CPU_READ_LEN; |
| 430 | ctx->offset += THIS_CPU_READ_LEN; | 378 | ctx->offset += THIS_CPU_READ_LEN; |
| 431 | } else | 379 | is_read = true; |
| | 380 | } else { |
| | 381 | trace_probe_log_err(ctx->offset, BAD_FETCH_ARG); |
| 432 | return -EINVAL; | 382 | return -EINVAL; |
| | 383 | } |
| 433 | | 384 | |
| 434 | ret = handle_dereference(arg, pcode, end, ctx, FETCH_OP_CPU_PTR, 0); | 385 | tmp = strrchr(arg, ')'); |
| 435 | if (ret || is_ptr) | 386 | if (!tmp) { |
| 436 | return ret; | 387 | trace_probe_log_err(ctx->offset + strlen(arg), |
| 437 | | 388 | DEREF_OPEN_BRACE); |
| 438 | /* this_cpu_read(VAR) -> +0(this_cpu_ptr(VAR)) */ | | |
| 439 | code = *pcode; | | |
| 440 | code++; | | |
| 441 | if (code == end) { | | |
| 442 | trace_probe_log_err(ctx->offset, TOO_MANY_OPS); | | |
| 443 | return -EINVAL; | 389 | return -EINVAL; |
| 444 | } | 390 | } |
| 445 | code->op = FETCH_OP_DEREF; | 391 | *tmp = '\0'; |
| 446 | code->offset = 0; | 392 | |
| 447 | *pcode = code; | 393 | ctx->stack[ctx->depth].type = STATE_DEREF; |
| | 394 | ctx->stack[ctx->depth].deref.deref = FETCH_OP_CPU_PTR; |
| | 395 | ctx->stack[ctx->depth].deref.offset = 0; |
| | 396 | ctx->stack[ctx->depth].deref.cur_offs = ctx->offset; |
| | 397 | ctx->stack[ctx->depth].deref.inner_arg = arg; |
| | 398 | ctx->stack[ctx->depth].deref.is_cpu_read = is_read; |
| 448 | return 0; | 399 | return 0; |
| 449 | } | 400 | } |
| 450 | | 401 | |
| @@ -1007,14 +958,12 @@ static char *find_matched_close_paren(char *s) · 556 unmodified lines |
| 1007 | return NULL; | 958 | return NULL; |
| 1008 | } | 959 | } |
| 1009 | | 960 | |
| 1010 | static int handle_typecast(char *arg, struct fetch_insn **pcode, | 961 | static int handle_typecast(char *arg, struct traceprobe_parse_context *ctx) |
| 1011 | struct fetch_insn *end, | | |
| 1012 | struct traceprobe_parse_context *ctx) | | |
| 1013 | { | 962 | { |
| 1014 | int orig_offset = ctx->offset; | 963 | int orig_offset = ctx->offset; |
| 1015 | char *close; | 964 | char *close; |
| 1016 | char *tmp; | 965 | char *tmp; |
| 1017 | int ret; | 966 | char *fieldname; |
| 1018 | | 967 | |
| 1019 | if (!(tparg_is_event_probe(ctx->flags) || | 968 | if (!(tparg_is_event_probe(ctx->flags) || |
| 1020 | tparg_is_function_entry(ctx->flags) || | 969 | tparg_is_function_entry(ctx->flags) || |
| @@ -1028,12 +977,6 @@ static int handle_typecast(char *arg, struct fetch_insn **pcode, · 7 unmodified lines |
| 1028 | * For example: (STRUCT)VAR->FIELD and (STRUCT)(VAR)->FIELD are same. | 977 | * For example: (STRUCT)VAR->FIELD and (STRUCT)(VAR)->FIELD are same. |
| 1029 | * VAR is solved in the nested call. | 978 | * VAR is solved in the nested call. |
| 1030 | */ | 979 | */ |
| 1031 | ctx->nested_level++; | | |
| 1032 | if (ctx->nested_level > TRACEPROBE_MAX_NESTED_LEVEL) { | | |
| 1033 | trace_probe_log_err(ctx->offset, TOO_MANY_NESTED); | | |
| 1034 | return -E2BIG; | | |
| 1035 | } | | |
| 1036 | | | |
| 1037 | tmp = strchr(arg, ')'); | 980 | tmp = strchr(arg, ')'); |
| 1038 | if (!tmp) { | 981 | if (!tmp) { |
| 1039 | trace_probe_log_err(ctx->offset + strlen(arg), | 982 | trace_probe_log_err(ctx->offset + strlen(arg), |
| @@ -1103,30 +1046,19 @@ static int handle_typecast(char *arg, struct fetch_insn **pcode, · 63 unmodified lines |
| 1103 | } | 1046 | } |
| 1104 | *close = '\0'; | 1047 | *close = '\0'; |
| 1105 | | 1048 | |
| 1106 | /* We need to parse the nested one */ | 1049 | /* Let fieldname point the field name. */ |
| 1107 | ret = parse_probe_arg(tmp, find_fetch_type(NULL, ctx->flags), | | |
| 1108 | pcode, end, ctx); | | |
| 1109 | if (ret < 0) | | |
| 1110 | return ret; | | |
| 1111 | ctx->nested_level--; | | |
| 1112 | clear_struct_btf(ctx); | | |
| 1113 | | | |
| 1114 | /* Let tmp point the field name. */ | | |
| 1115 | if (close[1] == '-') | 1050 | if (close[1] == '-') |
| 1116 | tmp = close + 3; /* Skip "->" after closing parenthesis */ | 1051 | fieldname = close + 3; /* Skip "->" after closing parenthesis */ |
| 1117 | else | 1052 | else |
| 1118 | tmp = close + 2; /* Skip ">" after inner variable name */ | 1053 | fieldname = close + 2; /* Skip ">" after inner variable name */ |
| 1119 | | 1054 | |
| 1120 | /* resolve the typecast struct name */ | 1055 | ctx->stack[ctx->depth].type = STATE_TYPECAST; |
| 1121 | ctx->offset = orig_offset + 1; /* for the '(' */ | 1056 | ctx->stack[ctx->depth].typecast.casttype = arg + 1; |
| 1122 | ret = parse_btf_casttype(arg + 1, ctx); | 1057 | ctx->stack[ctx->depth].typecast.fieldname = fieldname; |
| 1123 | if (ret < 0) | 1058 | ctx->stack[ctx->depth].typecast.orig_offset = orig_offset; |
| 1124 | return ret; | 1059 | ctx->stack[ctx->depth].typecast.field_offset_diff = fieldname - arg; |
| 1125 | | 1060 | ctx->stack[ctx->depth].typecast.inner_arg = tmp; |
| 1126 | ctx->offset = orig_offset + tmp - arg; | 1061 | return 0; |
| 1127 | ret = parse_btf_field(tmp, ctx->last_struct, pcode, end, ctx); | | |
| 1128 | ctx->prefix_byteoffs = 0; | | |
| 1129 | return ret; | | |
| 1130 | } | 1062 | } |
| 1131 | | 1063 | |
| 1132 | #else /* !CONFIG_PROBE_EVENTS_BTF_ARGS */ | 1064 | #else /* !CONFIG_PROBE_EVENTS_BTF_ARGS */ |
| @@ -1171,9 +1103,20 @@ static int check_prepare_btf_string_fetch(char *typename, · 38 unmodified lines |
| 1171 | return 0; | 1103 | return 0; |
| 1172 | } | 1104 | } |
| 1173 | | 1105 | |
| 1174 | static int handle_typecast(char *arg, struct fetch_insn **pcode, | 1106 | static int parse_btf_casttype(char *casttype, |
| 1175 | struct fetch_insn *end, | 1107 | struct traceprobe_parse_context *ctx) |
| | 1108 | { |
| | 1109 | return -EOPNOTSUPP; |
| | 1110 | } |
| | 1111 | |
| | 1112 | static int parse_btf_field(char *fieldname, const struct btf_type *type, |
| | 1113 | struct fetch_insn **pcode, struct fetch_insn *end, |
| 1176 | struct traceprobe_parse_context *ctx) | 1114 | struct traceprobe_parse_context *ctx) |
| | 1115 | { |
| | 1116 | return -EOPNOTSUPP; |
| | 1117 | } |
| | 1118 | |
| | 1119 | static int handle_typecast(char *arg, struct traceprobe_parse_context *ctx) |
| 1177 | { | 1120 | { |
| 1178 | trace_probe_log_err(ctx->offset, NOSUP_BTFARG); | 1121 | trace_probe_log_err(ctx->offset, NOSUP_BTFARG); |
| 1179 | return -EOPNOTSUPP; | 1122 | return -EOPNOTSUPP; |
| @@ -1598,9 +1541,7 @@ static int parse_probe_arg_mem_symbol(char *arg, struct fetch_insn **pcode, · 418 unmodified lines |
| 1598 | return 0; | 1541 | return 0; |
| 1599 | } | 1542 | } |
| 1600 | | 1543 | |
| 1601 | static int parse_probe_arg_deref(char *arg, struct fetch_insn **pcode, | 1544 | static int parse_probe_arg_deref(char *arg, struct traceprobe_parse_context *ctx) |
| 1602 | struct fetch_insn *end, | | |
| 1603 | struct traceprobe_parse_context *ctx) | | |
| 1604 | { | 1545 | { |
| 1605 | int deref = FETCH_OP_DEREF; | 1546 | int deref = FETCH_OP_DEREF; |
| 1606 | long offset = 0; | 1547 | long offset = 0; |
| @@ -1627,7 +1568,22 @@ static int parse_probe_arg_deref(char *arg, struct fetch_insn **pcode, · 20 unmodified lines |
| 1627 | } | 1568 | } |
| 1628 | ctx->offset += (tmp + 1 - arg) + (arg[0] != '-' ? 1 : 0); | 1569 | ctx->offset += (tmp + 1 - arg) + (arg[0] != '-' ? 1 : 0); |
| 1629 | arg = tmp + 1; | 1570 | arg = tmp + 1; |
| 1630 | return handle_dereference(arg, pcode, end, ctx, deref, offset); | 1571 | |
| | 1572 | tmp = strrchr(arg, ')'); |
| | 1573 | if (!tmp) { |
| | 1574 | trace_probe_log_err(ctx->offset + strlen(arg), |
| | 1575 | DEREF_OPEN_BRACE); |
| | 1576 | return -EINVAL; |
| | 1577 | } |
| | 1578 | *tmp = '\0'; |
| | 1579 | |
| | 1580 | ctx->stack[ctx->depth].type = STATE_DEREF; |
| | 1581 | ctx->stack[ctx->depth].deref.deref = deref; |
| | 1582 | ctx->stack[ctx->depth].deref.offset = offset; |
| | 1583 | ctx->stack[ctx->depth].deref.cur_offs = ctx->offset; |
| | 1584 | ctx->stack[ctx->depth].deref.inner_arg = arg; |
| | 1585 | ctx->stack[ctx->depth].deref.is_cpu_read = false; |
| | 1586 | return 0; |
| 1631 | } | 1587 | } |
| 1632 | | 1588 | |
| 1633 | static int parse_probe_arg_imm(char *arg, struct fetch_insn *code, | 1589 | static int parse_probe_arg_imm(char *arg, struct fetch_insn *code, |
| @@ -1659,11 +1615,6 @@ static int parse_probe_arg_default(char *arg, struct fetch_insn **pcode, · 25 unmodified lines |
| 1659 | { | 1615 | { |
| 1660 | int ret; | 1616 | int ret; |
| 1661 | | 1617 | |
| 1662 | if (str_has_prefix(arg, THIS_CPU_PTR_PREFIX) || | | |
| 1663 | str_has_prefix(arg, THIS_CPU_READ_PREFIX)) { | | |
| 1664 | return parse_this_cpu(arg, pcode, end, ctx); | | |
| 1665 | } | | |
| 1666 | | | |
| 1667 | if (isalpha(arg[0]) || arg[0] == '_') { | 1618 | if (isalpha(arg[0]) || arg[0] == '_') { |
| 1668 | /* BTF variable or event field */ | 1619 | /* BTF variable or event field */ |
| 1669 | if (ctx->flags & TPARG_FL_TEVENT) { | 1620 | if (ctx->flags & TPARG_FL_TEVENT) { |
| @@ -1685,11 +1636,56 @@ static int parse_probe_arg_default(char *arg, struct fetch_insn **pcode, · 15 unmodified lines |
| 1685 | return 0; | 1636 | return 0; |
| 1686 | } | 1637 | } |
| 1687 | | 1638 | |
| 1688 | /* Recursive argument parser */ | 1639 | static int parse_probe_arg_nested(char **parg, struct traceprobe_parse_context *ctx) |
| 1689 | static int | 1640 | { |
| 1690 | parse_probe_arg(char *arg, const struct fetch_type *type, | 1641 | char *arg = *parg; |
| 1691 | struct fetch_insn **pcode, struct fetch_insn *end, | 1642 | int ret; |
| 1692 | struct traceprobe_parse_context *ctx) | 1643 | |
| | 1644 | while (true) { |
| | 1645 | /* Determine if this is a nested argument */ |
| | 1646 | if (arg[0] != '+' && arg[0] != '-' && arg[0] != '(' && |
| | 1647 | !str_has_prefix(arg, THIS_CPU_PTR_PREFIX) && |
| | 1648 | !str_has_prefix(arg, THIS_CPU_READ_PREFIX)) |
| | 1649 | break; |
| | 1650 | |
| | 1651 | /* If nested, check the maximum depth limit */ |
| | 1652 | if (ctx->depth >= TRACEPROBE_MAX_NESTED_LEVEL) { |
| | 1653 | trace_probe_log_err(ctx->offset, TOO_MANY_NESTED); |
| | 1654 | return -E2BIG; |
| | 1655 | } |
| | 1656 | |
| | 1657 | /* Perform the actual parsing subroutine calls */ |
| | 1658 | switch (arg[0]) { |
| | 1659 | case '+': |
| | 1660 | case '-': |
| | 1661 | ret = parse_probe_arg_deref(arg, ctx); |
| | 1662 | if (ret) |
| | 1663 | return ret; |
| | 1664 | arg = ctx->stack[ctx->depth].deref.inner_arg; |
| | 1665 | break; |
| | 1666 | case '(': |
| | 1667 | ret = handle_typecast(arg, ctx); |
| | 1668 | if (ret) |
| | 1669 | return ret; |
| | 1670 | arg = ctx->stack[ctx->depth].typecast.inner_arg; |
| | 1671 | break; |
| | 1672 | default: |
| | 1673 | ret = parse_this_cpu(arg, ctx); |
| | 1674 | if (ret) |
| | 1675 | return ret; |
| | 1676 | arg = ctx->stack[ctx->depth].deref.inner_arg; |
| | 1677 | break; |
| | 1678 | } |
| | 1679 | ctx->depth++; |
| | 1680 | } |
| | 1681 | |
| | 1682 | *parg = arg; |
| | 1683 | return 0; |
| | 1684 | } |
| | 1685 | |
| | 1686 | static int parse_probe_arg_leaf(char *arg, const struct fetch_type *type, |
| | 1687 | struct fetch_insn **pcode, struct fetch_insn *end, |
| | 1688 | struct traceprobe_parse_context *ctx) |
| 1693 | { | 1689 | { |
| 1694 | struct fetch_insn *code = *pcode; | 1690 | struct fetch_insn *code = *pcode; |
| 1695 | int ret; | 1691 | int ret; |
| @@ -1704,26 +1700,112 @@ parse_probe_arg(char *arg, const struct fetch_type *type, · 8 unmodified lines |
| 1704 | case '@': /* memory, file-offset or symbol */ | 1700 | case '@': /* memory, file-offset or symbol */ |
| 1705 | ret = parse_probe_arg_mem_symbol(arg, pcode, end, ctx); | 1701 | ret = parse_probe_arg_mem_symbol(arg, pcode, end, ctx); |
| 1706 | break; | 1702 | break; |
| 1707 | case '+': /* deref memory */ | | |
| 1708 | case '-': | | |
| 1709 | ret = parse_probe_arg_deref(arg, pcode, end, ctx); | | |
| 1710 | break; | | |
| 1711 | case '\\': /* Immediate value */ | 1703 | case '\\': /* Immediate value */ |
| 1712 | ret = parse_probe_arg_imm(arg, code, ctx); | 1704 | ret = parse_probe_arg_imm(arg, code, ctx); |
| 1713 | break; | 1705 | break; |
| 1714 | case '(': | | |
| 1715 | ret = handle_typecast(arg, pcode, end, ctx); | | |
| 1716 | break; | | |
| 1717 | default: | 1706 | default: |
| 1718 | ret = parse_probe_arg_default(arg, pcode, end, ctx); | 1707 | ret = parse_probe_arg_default(arg, pcode, end, ctx); |
| 1719 | break; | 1708 | break; |
| 1720 | } | 1709 | } |
| 1721 | if (!ret && code->op == FETCH_OP_NOP) { | 1710 | |
| | 1711 | if (ret) |
| | 1712 | return ret; |
| | 1713 | |
| | 1714 | if (code->op == FETCH_OP_NOP) { |
| 1722 | /* Parsed, but do not find fetch method */ | 1715 | /* Parsed, but do not find fetch method */ |
| 1723 | trace_probe_log_err(ctx->offset, BAD_FETCH_ARG); | 1716 | trace_probe_log_err(ctx->offset, BAD_FETCH_ARG); |
| 1724 | ret = -EINVAL; | 1717 | return -EINVAL; |
| 1725 | } | 1718 | } |
| 1726 | return ret; | 1719 | |
| | 1720 | return 0; |
| | 1721 | } |
| | 1722 | |
| | 1723 | static int unwind_parse_states(struct fetch_insn **pcode, struct fetch_insn *end, |
| | 1724 | struct traceprobe_parse_context *ctx) |
| | 1725 | { |
| | 1726 | struct parse_state *state; |
| | 1727 | struct fetch_insn *code; |
| | 1728 | int ret; |
| | 1729 | |
| | 1730 | while (ctx->depth > 0) { |
| | 1731 | ctx->depth--; |
| | 1732 | state = &ctx->stack[ctx->depth]; |
| | 1733 | |
| | 1734 | if (state->type == STATE_DEREF) { |
| | 1735 | code = *pcode; |
| | 1736 | ctx->offset = state->deref.cur_offs; |
| | 1737 | if (code->op == FETCH_OP_COMM || code->op == FETCH_OP_IMMSTR) { |
| | 1738 | trace_probe_log_err(ctx->offset, COMM_CANT_DEREF); |
| | 1739 | return -EINVAL; |
| | 1740 | } |
| | 1741 | |
| | 1742 | if (!(state->deref.deref == FETCH_OP_CPU_PTR && |
| | 1743 | *state->deref.inner_arg == '@')) { |
| | 1744 | code++; |
| | 1745 | if (code == end) { |
| | 1746 | trace_probe_log_err(ctx->offset, TOO_MANY_OPS); |
| | 1747 | return -EINVAL; |
| | 1748 | } |
| | 1749 | } |
| | 1750 | *pcode = code; |
| | 1751 | |
| | 1752 | code->op = state->deref.deref; |
| | 1753 | code->offset = state->deref.offset; |
| | 1754 | ctx->last_type = NULL; |
| | 1755 | |
| | 1756 | if (state->deref.is_cpu_read) { |
| | 1757 | code = *pcode; |
| | 1758 | code++; |
| | 1759 | if (code == end) { |
| | 1760 | trace_probe_log_err(ctx->offset, TOO_MANY_OPS); |
| | 1761 | return -EINVAL; |
| | 1762 | } |
| | 1763 | code->op = FETCH_OP_DEREF; |
| | 1764 | code->offset = 0; |
| | 1765 | *pcode = code; |
| | 1766 | } |
| | 1767 | } else if (state->type == STATE_TYPECAST) { |
| | 1768 | clear_struct_btf(ctx); |
| | 1769 | |
| | 1770 | /* resolve the typecast struct name */ |
| | 1771 | ctx->offset = state->typecast.orig_offset + 1; /* for the '(' */ |
| | 1772 | ret = parse_btf_casttype(state->typecast.casttype, ctx); |
| | 1773 | if (ret < 0) |
| | 1774 | return ret; |
| | 1775 | |
| | 1776 | ctx->offset = state->typecast.orig_offset + |
| | 1777 | state->typecast.field_offset_diff; |
| | 1778 | ret = parse_btf_field(state->typecast.fieldname, |
| | 1779 | ctx->last_struct, pcode, |
| | 1780 | end, ctx); |
| | 1781 | ctx->prefix_byteoffs = 0; |
| | 1782 | if (ret < 0) |
| | 1783 | return ret; |
| | 1784 | } |
| | 1785 | } |
| | 1786 | |
| | 1787 | return 0; |
| | 1788 | } |
| | 1789 | |
| | 1790 | /* Loop-based (non-recursive) argument parser */ |
| | 1791 | static int |
| | 1792 | parse_probe_arg(char *arg, const struct fetch_type *type, |
| | 1793 | struct fetch_insn **pcode, struct fetch_insn *end, |
| | 1794 | struct traceprobe_parse_context *ctx) |
| | 1795 | { |
| | 1796 | int ret; |
| | 1797 | |
| | 1798 | ctx->depth = 0; |
| | 1799 | |
| | 1800 | ret = parse_probe_arg_nested(&arg, ctx); |
| | 1801 | if (ret) |
| | 1802 | return ret; |
| | 1803 | |
| | 1804 | ret = parse_probe_arg_leaf(arg, type, pcode, end, ctx); |
| | 1805 | if (ret) |
| | 1806 | return ret; |
| | 1807 | |
| | 1808 | return unwind_parse_states(pcode, end, ctx); |
| 1727 | } | 1809 | } |
| 1728 | | 1810 | |
| 1729 | /* Bitfield type needs to be parsed into a fetch function */ | 1811 | /* Bitfield type needs to be parsed into a fetch function */ |
| @@ -1984,12 +2066,6 @@ static int traceprobe_parse_probe_arg_body(const char *argv, ssize_t *size, · 254 unmodified lines |
| 1984 | ctx); | 2066 | ctx); |
| 1985 | if (ret < 0) | 2067 | if (ret < 0) |
| 1986 | goto fail; | 2068 | goto fail; |
| 1987 | /* nested_level must be 0 here, otherwise there is a bug. */ | | |
| 1988 | if (WARN_ON_ONCE(ctx->nested_level)) { | | |
| 1989 | ret = -EINVAL; | | |
| 1990 | goto fail; | | |
| 1991 | } | | |
| 1992 | | | |
| 1993 | /* Update storing type if BTF is available */ | 2069 | /* Update storing type if BTF is available */ |
| 1994 | if (IS_ENABLED(CONFIG_PROBE_EVENTS_BTF_ARGS) && | 2070 | if (IS_ENABLED(CONFIG_PROBE_EVENTS_BTF_ARGS) && |
| 1995 | ctx->last_type) { | 2071 | ctx->last_type) { |