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

Commit b5a80b7e authored by Ingo Molnar's avatar Ingo Molnar
Browse files

Merge branch 'perf' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux-2.6 into perf/core

parents 84b13fd5 f6c903f5
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -41,6 +41,8 @@ Synopsis of kprobe_events
  $retval	: Fetch return value.(*)
  +|-offs(FETCHARG) : Fetch memory at FETCHARG +|- offs address.(**)
  NAME=FETCHARG : Set NAME as the argument name of FETCHARG.
  FETCHARG:TYPE : Set TYPE as the type of FETCHARG. Currently, basic types
		  (u8/u16/u32/u64/s8/s16/s32/s64) are supported.

  (*) only for return probe.
  (**) this is useful for fetching a field of data structures.
+2 −14
Original line number Diff line number Diff line
@@ -102,29 +102,17 @@ struct syscall_trace_exit {
	long			ret;
};

struct kprobe_trace_entry {
struct kprobe_trace_entry_head {
	struct trace_entry	ent;
	unsigned long		ip;
	int			nargs;
	unsigned long		args[];
};

#define SIZEOF_KPROBE_TRACE_ENTRY(n)			\
	(offsetof(struct kprobe_trace_entry, args) +	\
	(sizeof(unsigned long) * (n)))

struct kretprobe_trace_entry {
struct kretprobe_trace_entry_head {
	struct trace_entry	ent;
	unsigned long		func;
	unsigned long		ret_ip;
	int			nargs;
	unsigned long		args[];
};

#define SIZEOF_KRETPROBE_TRACE_ENTRY(n)			\
	(offsetof(struct kretprobe_trace_entry, args) +	\
	(sizeof(unsigned long) * (n)))

/*
 * trace_flag_type is an enumeration that holds different
 * states when a trace occurs. These are:
+329 −206

File changed.

Preview size limit exceeded, changes collapsed.

+10 −1
Original line number Diff line number Diff line
@@ -79,7 +79,16 @@ Probe points are defined by following syntax.
'EVENT' specifies the name of new event, if omitted, it will be set the name of the probed function. Currently, event group name is set as 'probe'.
'FUNC' specifies a probed function name, and it may have one of the following options; '+OFFS' is the offset from function entry address in bytes, ':RLN' is the relative-line number from function entry line, and '%return' means that it probes function return. And ';PTN' means lazy matching pattern (see LAZY MATCHING). Note that ';PTN' must be the end of the probe point definition.  In addition, '@SRC' specifies a source file which has that function.
It is also possible to specify a probe point by the source line number or lazy matching by using 'SRC:ALN' or 'SRC;PTN' syntax, where 'SRC' is the source file path, ':ALN' is the line number and ';PTN' is the lazy matching pattern.
'ARG' specifies the arguments of this probe point. You can use the name of local variable, or kprobe-tracer argument format (e.g. $retval, %ax, etc).
'ARG' specifies the arguments of this probe point, (see PROBE ARGUMENT).

PROBE ARGUMENT
--------------
Each probe argument follows below syntax.

 [NAME=]LOCALVAR|$retval|%REG|@SYMBOL[:TYPE]

'NAME' specifies the name of this argument (optional). You can use the name of local variable, local data structure member (e.g. var->field, var.field2), or kprobe-tracer argument format (e.g. $retval, %ax, etc). Note that the name of this argument will be set as the last member name if you specify a local data structure member (e.g. field2 for 'var->field1.field2'.)
'TYPE' casts the type of this argument (optional). If omitted, perf probe automatically set the type based on debuginfo.

LINE SYNTAX
-----------
+50 −28
Original line number Diff line number Diff line
@@ -40,7 +40,6 @@
#include "util/debug.h"
#include "util/debugfs.h"
#include "util/parse-options.h"
#include "util/parse-events.h"	/* For debugfs_path */
#include "util/probe-finder.h"
#include "util/probe-event.h"

@@ -59,23 +58,25 @@ static struct {


/* Parse an event definition. Note that any error must die. */
static void parse_probe_event(const char *str)
static int parse_probe_event(const char *str)
{
	struct perf_probe_event *pev = &params.events[params.nevents];
	int ret;

	pr_debug("probe-definition(%d): %s\n", params.nevents, str);
	if (++params.nevents == MAX_PROBES)
		die("Too many probes (> %d) are specified.", MAX_PROBES);

	/* Parse a perf-probe command into event */
	parse_perf_probe_command(str, pev);

	ret = parse_perf_probe_command(str, pev);
	pr_debug("%d arguments\n", pev->nargs);

	return ret;
}

static void parse_probe_event_argv(int argc, const char **argv)
static int parse_probe_event_argv(int argc, const char **argv)
{
	int i, len;
	int i, len, ret;
	char *buf;

	/* Bind up rest arguments */
@@ -86,15 +87,17 @@ static void parse_probe_event_argv(int argc, const char **argv)
	len = 0;
	for (i = 0; i < argc; i++)
		len += sprintf(&buf[len], "%s ", argv[i]);
	parse_probe_event(buf);
	ret = parse_probe_event(buf);
	free(buf);
	return ret;
}

static int opt_add_probe_event(const struct option *opt __used,
			      const char *str, int unset __used)
{
	if (str)
		parse_probe_event(str);
		return parse_probe_event(str);
	else
		return 0;
}

@@ -113,11 +116,14 @@ static int opt_del_probe_event(const struct option *opt __used,
static int opt_show_lines(const struct option *opt __used,
			  const char *str, int unset __used)
{
	int ret = 0;

	if (str)
		parse_line_range_desc(str, &params.line_range);
		ret = parse_line_range_desc(str, &params.line_range);
	INIT_LIST_HEAD(&params.line_range.line_list);
	params.show_lines = true;
	return 0;

	return ret;
}
#endif

@@ -142,9 +148,9 @@ static const struct option options[] = {
	OPT_CALLBACK('a', "add", NULL,
#ifdef DWARF_SUPPORT
		"[EVENT=]FUNC[@SRC][+OFF|%return|:RL|;PT]|SRC:AL|SRC;PT"
		" [ARG ...]",
		" [[NAME=]ARG ...]",
#else
		"[EVENT=]FUNC[+OFF|%return] [ARG ...]",
		"[EVENT=]FUNC[+OFF|%return] [[NAME=]ARG ...]",
#endif
		"probe point definition, where\n"
		"\t\tGROUP:\tGroup name (optional)\n"
@@ -178,6 +184,8 @@ static const struct option options[] = {

int cmd_probe(int argc, const char **argv, const char *prefix __used)
{
	int ret;

	argc = parse_options(argc, argv, options, probe_usage,
			     PARSE_OPT_STOP_AT_NON_OPTION);
	if (argc > 0) {
@@ -185,28 +193,31 @@ int cmd_probe(int argc, const char **argv, const char *prefix __used)
			pr_warning("  Error: '-' is not supported.\n");
			usage_with_options(probe_usage, options);
		}
		parse_probe_event_argv(argc, argv);
		ret = parse_probe_event_argv(argc, argv);
		if (ret < 0) {
			pr_err("  Error: Parse Error.  (%d)\n", ret);
			return ret;
		}
	}

	if ((!params.nevents && !params.dellist && !params.list_events &&
	     !params.show_lines))
		usage_with_options(probe_usage, options);

	if (debugfs_valid_mountpoint(debugfs_path) < 0)
		die("Failed to find debugfs path.");

	if (params.list_events) {
		if (params.nevents != 0 || params.dellist) {
			pr_warning("  Error: Don't use --list with"
				   " --add/--del.\n");
			pr_err("  Error: Don't use --list with --add/--del.\n");
			usage_with_options(probe_usage, options);
		}
		if (params.show_lines) {
			pr_warning("  Error: Don't use --list with --line.\n");
			pr_err("  Error: Don't use --list with --line.\n");
			usage_with_options(probe_usage, options);
		}
		show_perf_probe_events();
		return 0;
		ret = show_perf_probe_events();
		if (ret < 0)
			pr_err("  Error: Failed to show event list. (%d)\n",
			       ret);
		return ret;
	}

#ifdef DWARF_SUPPORT
@@ -217,19 +228,30 @@ int cmd_probe(int argc, const char **argv, const char *prefix __used)
			usage_with_options(probe_usage, options);
		}

		show_line_range(&params.line_range);
		return 0;
		ret = show_line_range(&params.line_range);
		if (ret < 0)
			pr_err("  Error: Failed to show lines. (%d)\n", ret);
		return ret;
	}
#endif

	if (params.dellist) {
		del_perf_probe_events(params.dellist);
		ret = del_perf_probe_events(params.dellist);
		strlist__delete(params.dellist);
		if (params.nevents == 0)
			return 0;
		if (ret < 0) {
			pr_err("  Error: Failed to delete events. (%d)\n", ret);
			return ret;
		}
	}

	add_perf_probe_events(params.events, params.nevents, params.force_add);
	if (params.nevents) {
		ret = add_perf_probe_events(params.events, params.nevents,
					    params.force_add);
		if (ret < 0) {
			pr_err("  Error: Failed to add events. (%d)\n", ret);
			return ret;
		}
	}
	return 0;
}
Loading