aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/trace/ftrace.c
diff options
context:
space:
mode:
Diffstat (limited to 'kernel/trace/ftrace.c')
-rw-r--r--kernel/trace/ftrace.c64
1 files changed, 5 insertions, 59 deletions
diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
index cc615f84751b..ddf23a225b52 100644
--- a/kernel/trace/ftrace.c
+++ b/kernel/trace/ftrace.c
@@ -1655,60 +1655,6 @@ ftrace_regex_lseek(struct file *file, loff_t offset, int origin)
1655 return ret; 1655 return ret;
1656} 1656}
1657 1657
1658enum {
1659 MATCH_FULL,
1660 MATCH_FRONT_ONLY,
1661 MATCH_MIDDLE_ONLY,
1662 MATCH_END_ONLY,
1663};
1664
1665/*
1666 * (static function - no need for kernel doc)
1667 *
1668 * Pass in a buffer containing a glob and this function will
1669 * set search to point to the search part of the buffer and
1670 * return the type of search it is (see enum above).
1671 * This does modify buff.
1672 *
1673 * Returns enum type.
1674 * search returns the pointer to use for comparison.
1675 * not returns 1 if buff started with a '!'
1676 * 0 otherwise.
1677 */
1678static int
1679ftrace_setup_glob(char *buff, int len, char **search, int *not)
1680{
1681 int type = MATCH_FULL;
1682 int i;
1683
1684 if (buff[0] == '!') {
1685 *not = 1;
1686 buff++;
1687 len--;
1688 } else
1689 *not = 0;
1690
1691 *search = buff;
1692
1693 for (i = 0; i < len; i++) {
1694 if (buff[i] == '*') {
1695 if (!i) {
1696 *search = buff + 1;
1697 type = MATCH_END_ONLY;
1698 } else {
1699 if (type == MATCH_END_ONLY)
1700 type = MATCH_MIDDLE_ONLY;
1701 else
1702 type = MATCH_FRONT_ONLY;
1703 buff[i] = 0;
1704 break;
1705 }
1706 }
1707 }
1708
1709 return type;
1710}
1711
1712static int ftrace_match(char *str, char *regex, int len, int type) 1658static int ftrace_match(char *str, char *regex, int len, int type)
1713{ 1659{
1714 int matched = 0; 1660 int matched = 0;
@@ -1757,7 +1703,7 @@ static void ftrace_match_records(char *buff, int len, int enable)
1757 int not; 1703 int not;
1758 1704
1759 flag = enable ? FTRACE_FL_FILTER : FTRACE_FL_NOTRACE; 1705 flag = enable ? FTRACE_FL_FILTER : FTRACE_FL_NOTRACE;
1760 type = ftrace_setup_glob(buff, len, &search, &not); 1706 type = filter_parse_regex(buff, len, &search, &not);
1761 1707
1762 search_len = strlen(search); 1708 search_len = strlen(search);
1763 1709
@@ -1825,7 +1771,7 @@ static void ftrace_match_module_records(char *buff, char *mod, int enable)
1825 } 1771 }
1826 1772
1827 if (strlen(buff)) { 1773 if (strlen(buff)) {
1828 type = ftrace_setup_glob(buff, strlen(buff), &search, &not); 1774 type = filter_parse_regex(buff, strlen(buff), &search, &not);
1829 search_len = strlen(search); 1775 search_len = strlen(search);
1830 } 1776 }
1831 1777
@@ -1990,7 +1936,7 @@ register_ftrace_function_probe(char *glob, struct ftrace_probe_ops *ops,
1990 int count = 0; 1936 int count = 0;
1991 char *search; 1937 char *search;
1992 1938
1993 type = ftrace_setup_glob(glob, strlen(glob), &search, &not); 1939 type = filter_parse_regex(glob, strlen(glob), &search, &not);
1994 len = strlen(search); 1940 len = strlen(search);
1995 1941
1996 /* we do not support '!' for function probes */ 1942 /* we do not support '!' for function probes */
@@ -2067,7 +2013,7 @@ __unregister_ftrace_function_probe(char *glob, struct ftrace_probe_ops *ops,
2067 else if (glob) { 2013 else if (glob) {
2068 int not; 2014 int not;
2069 2015
2070 type = ftrace_setup_glob(glob, strlen(glob), &search, &not); 2016 type = filter_parse_regex(glob, strlen(glob), &search, &not);
2071 len = strlen(search); 2017 len = strlen(search);
2072 2018
2073 /* we do not support '!' for function probes */ 2019 /* we do not support '!' for function probes */
@@ -2520,7 +2466,7 @@ ftrace_set_func(unsigned long *array, int *idx, char *buffer)
2520 return -ENODEV; 2466 return -ENODEV;
2521 2467
2522 /* decode regex */ 2468 /* decode regex */
2523 type = ftrace_setup_glob(buffer, strlen(buffer), &search, &not); 2469 type = filter_parse_regex(buffer, strlen(buffer), &search, &not);
2524 if (not) 2470 if (not)
2525 return -EINVAL; 2471 return -EINVAL;
2526 2472