Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e63cc239 authored by Masami Hiramatsu's avatar Masami Hiramatsu Committed by Ingo Molnar
Browse files

tracing/kprobes: Add failure messages for debugging



Add verbose failure messages to kprobe-tracer for debugging.

Signed-off-by: default avatarMasami Hiramatsu <mhiramat@redhat.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
LKML-Reference: <20091017000728.16556.16713.stgit@dhcp-100-2-132.bos.redhat.com>
Signed-off-by: default avatarIngo Molnar <mingo@elte.hu>
parent f397af06
Loading
Loading
Loading
Loading
+27 −8
Original line number Original line Diff line number Diff line
@@ -597,15 +597,19 @@ static int create_trace_probe(int argc, char **argv)
	void *addr = NULL;
	void *addr = NULL;
	char buf[MAX_EVENT_NAME_LEN];
	char buf[MAX_EVENT_NAME_LEN];


	if (argc < 2)
	if (argc < 2) {
		pr_info("Probe point is not specified.\n");
		return -EINVAL;
		return -EINVAL;
	}


	if (argv[0][0] == 'p')
	if (argv[0][0] == 'p')
		is_return = 0;
		is_return = 0;
	else if (argv[0][0] == 'r')
	else if (argv[0][0] == 'r')
		is_return = 1;
		is_return = 1;
	else
	else {
		pr_info("Probe definition must be started with 'p' or 'r'.\n");
		return -EINVAL;
		return -EINVAL;
	}


	if (argv[0][1] == ':') {
	if (argv[0][1] == ':') {
		event = &argv[0][2];
		event = &argv[0][2];
@@ -625,22 +629,30 @@ static int create_trace_probe(int argc, char **argv)
	}
	}


	if (isdigit(argv[1][0])) {
	if (isdigit(argv[1][0])) {
		if (is_return)
		if (is_return) {
			pr_info("Return probe point must be a symbol.\n");
			return -EINVAL;
			return -EINVAL;
		}
		/* an address specified */
		/* an address specified */
		ret = strict_strtoul(&argv[0][2], 0, (unsigned long *)&addr);
		ret = strict_strtoul(&argv[0][2], 0, (unsigned long *)&addr);
		if (ret)
		if (ret) {
			pr_info("Failed to parse address.\n");
			return ret;
			return ret;
		}
	} else {
	} else {
		/* a symbol specified */
		/* a symbol specified */
		symbol = argv[1];
		symbol = argv[1];
		/* TODO: support .init module functions */
		/* TODO: support .init module functions */
		ret = split_symbol_offset(symbol, &offset);
		ret = split_symbol_offset(symbol, &offset);
		if (ret)
		if (ret) {
			pr_info("Failed to parse symbol.\n");
			return ret;
			return ret;
		if (offset && is_return)
		}
		if (offset && is_return) {
			pr_info("Return probe must be used without offset.\n");
			return -EINVAL;
			return -EINVAL;
		}
		}
	}
	argc -= 2; argv += 2;
	argc -= 2; argv += 2;


	/* setup a probe */
	/* setup a probe */
@@ -658,8 +670,11 @@ static int create_trace_probe(int argc, char **argv)
	}
	}
	tp = alloc_trace_probe(group, event, addr, symbol, offset, argc,
	tp = alloc_trace_probe(group, event, addr, symbol, offset, argc,
			       is_return);
			       is_return);
	if (IS_ERR(tp))
	if (IS_ERR(tp)) {
		pr_info("Failed to allocate trace_probe.(%d)\n",
			(int)PTR_ERR(tp));
		return PTR_ERR(tp);
		return PTR_ERR(tp);
	}


	/* parse arguments */
	/* parse arguments */
	ret = 0;
	ret = 0;
@@ -672,6 +687,8 @@ static int create_trace_probe(int argc, char **argv)
			arg = argv[i];
			arg = argv[i];


		if (conflict_field_name(argv[i], tp->args, i)) {
		if (conflict_field_name(argv[i], tp->args, i)) {
			pr_info("Argument%d name '%s' conflicts with "
				"another field.\n", i, argv[i]);
			ret = -EINVAL;
			ret = -EINVAL;
			goto error;
			goto error;
		}
		}
@@ -685,9 +702,11 @@ static int create_trace_probe(int argc, char **argv)
			goto error;
			goto error;
		}
		}
		ret = parse_probe_arg(arg, &tp->args[i].fetch, is_return);
		ret = parse_probe_arg(arg, &tp->args[i].fetch, is_return);
		if (ret)
		if (ret) {
			pr_info("Parse error at argument%d. (%d)\n", i, ret);
			goto error;
			goto error;
		}
		}
	}
	tp->nr_args = i;
	tp->nr_args = i;


	ret = register_trace_probe(tp);
	ret = register_trace_probe(tp);