Lines Matching defs:pattern
29 * The disassembly of each program is then compared with the pattern
68 /* Sign extension on s390 changes the pattern */
290 static int find_field_offset(struct btf *btf, char *pattern, regmatch_t *matches)
294 char *type = pattern + matches[1].rm_so;
295 char *field = pattern + matches[2].rm_so;
301 PRINT_FAIL("Malformed pattern: type ident is too long: %d\n", type_sz);
306 PRINT_FAIL("Malformed pattern: field ident is too long: %d\n", field_sz);
385 * Can't match disassembly(left) with pattern(right):
395 char *pattern = pattern_origin;
399 fprintf(out, "Can't match disassembly(left) with pattern(right):\n");
400 while (*pattern || *text) {
424 /* Print one line from pattern, pattern lines are terminated by ';' */
425 while (*pattern && *pattern != ';') {
426 if (pattern == pattern_pos)
428 fputc(*pattern, out);
429 ++pattern;
432 if (pattern == pattern_pos)
436 if (*pattern)
437 ++pattern;
441 /* If pattern and text diverge at this line, print an
457 /* Test if `text` matches `pattern`. Pattern consists of the following elements:
476 * If a substring of pattern is equal to `reg_map[i][0]` the `text` is
479 * - Whitespace is ignored, ';' counts as whitespace for `pattern`.
481 * - Any other characters, `pattern` and `text` should match one-to-one.
483 * Example of a pattern:
491 static bool match_pattern(struct btf *btf, char *pattern, char *text, char *reg_map[][2])
493 char *pattern_origin = pattern;
498 while (*pattern) {
503 if (isspace(*pattern) || *pattern == ';') {
506 pattern = skip_space_and_semi(pattern);
515 pattern_next = match_str(pattern, reg_map[i][0]);
523 pattern = pattern_next;
531 if (strncmp(pattern, "$(", 2) == 0) {
532 char *group_start = pattern, *text_next;
535 pattern += 2;
540 pattern = skip_space(pattern);
541 if (!*pattern) {
542 PRINT_FAIL("Unexpected end of pattern\n");
546 if (*pattern == ')') {
547 ++pattern;
551 if (*pattern == '+') {
552 ++pattern;
556 printf("pattern: %s\n", pattern);
557 if (regexec(field_regex, pattern, 3, matches, 0) != 0) {
562 field_offset = find_field_offset(btf, pattern, matches);
566 pattern += matches[0].rm_eo;
573 (int)(pattern - group_start),
584 if (regexec(field_regex, pattern, 3, matches, 0) == 0) {
588 field_offset = find_field_offset(btf, pattern, matches);
595 (int)matches[0].rm_eo, pattern, field_offset);
599 pattern += matches[0].rm_eo;
604 /* If pattern points to identifier not followed by '::'
608 if (regexec(ident_regex, pattern, 1, matches, 0) == 0) {
609 if (strncmp(pattern, text, matches[0].rm_eo) != 0)
612 pattern += matches[0].rm_eo;
618 if (*pattern != *text)
621 ++pattern;
629 print_match_error(stdout, pattern_origin, text_origin, pattern, text);
643 char *pattern,
696 ASSERT_TRUE(match_pattern(btf, pattern, text, reg_map),
778 char *pattern = test->write_stx ? test->write_stx : test->write;
783 match_program(btf, &pinfo, pattern, stx_reg_map, true);
787 char *pattern = test->write_st ? test->write_st : test->write;
792 match_program(btf, &pinfo, pattern, st_reg_map, false);