Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 140778
b: refs/heads/master
c: f9349a8
h: refs/heads/master
v: v3
  • Loading branch information
Frederic Weisbecker authored and Ingo Molnar committed Feb 20, 2009
1 parent 856813a commit e67b960
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 19 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 64b36ca7f408e0bd45487c8c28f168f11f3b6dcd
refs/heads/master: f9349a8f978929a0c71d2c42ae299f7d462c239d
56 changes: 38 additions & 18 deletions trunk/kernel/trace/ftrace.c
Original file line number Diff line number Diff line change
Expand Up @@ -1895,6 +1895,10 @@ static void *g_start(struct seq_file *m, loff_t *pos)

mutex_lock(&graph_lock);

/* Nothing, tell g_show to print all functions are enabled */
if (!ftrace_graph_count && !*pos)
return (void *)1;

p = g_next(m, p, pos);

return p;
Expand All @@ -1913,6 +1917,11 @@ static int g_show(struct seq_file *m, void *v)
if (!ptr)
return 0;

if (ptr == (unsigned long *)1) {
seq_printf(m, "#### all functions enabled ####\n");
return 0;
}

kallsyms_lookup(*ptr, NULL, NULL, NULL, str);

seq_printf(m, "%s\n", str);
Expand Down Expand Up @@ -1966,38 +1975,51 @@ ftrace_graph_read(struct file *file, char __user *ubuf,
}

static int
ftrace_set_func(unsigned long *array, int idx, char *buffer)
ftrace_set_func(unsigned long *array, int *idx, char *buffer)
{
char str[KSYM_SYMBOL_LEN];
struct dyn_ftrace *rec;
struct ftrace_page *pg;
int search_len;
int found = 0;
int j;
int type, not;
char *search;
bool exists;
int i;

if (ftrace_disabled)
return -ENODEV;

/* decode regex */
type = ftrace_setup_glob(buffer, strlen(buffer), &search, &not);
if (not)
return -EINVAL;

search_len = strlen(search);

mutex_lock(&ftrace_lock);
do_for_each_ftrace_rec(pg, rec) {

if (*idx >= FTRACE_GRAPH_MAX_FUNCS)
break;

if (rec->flags & (FTRACE_FL_FAILED | FTRACE_FL_FREE))
continue;

kallsyms_lookup(rec->ip, NULL, NULL, NULL, str);
if (strcmp(str, buffer) == 0) {
/* Return 1 if we add it to the array */
found = 1;
for (j = 0; j < idx; j++)
if (array[j] == rec->ip) {
found = 0;
if (ftrace_match_record(rec, search, search_len, type)) {
/* ensure it is not already in the array */
exists = false;
for (i = 0; i < *idx; i++)
if (array[i] == rec->ip) {
exists = true;
break;
}
if (found)
array[idx] = rec->ip;
goto out;
if (!exists) {
array[(*idx)++] = rec->ip;
found = 1;
}
}
} while_for_each_ftrace_rec();
out:

mutex_unlock(&ftrace_lock);

return found ? 0 : -EINVAL;
Expand Down Expand Up @@ -2066,13 +2088,11 @@ ftrace_graph_write(struct file *file, const char __user *ubuf,
}
buffer[index] = 0;

/* we allow only one at a time */
ret = ftrace_set_func(array, ftrace_graph_count, buffer);
/* we allow only one expression at a time */
ret = ftrace_set_func(array, &ftrace_graph_count, buffer);
if (ret)
goto out;

ftrace_graph_count++;

file->f_pos += read;

ret = read;
Expand Down

0 comments on commit e67b960

Please sign in to comment.