Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 169757
b: refs/heads/master
c: 1b290d6
h: refs/heads/master
i:
  169755: 69bd898
v: v3
  • Loading branch information
Frederic Weisbecker authored and Ingo Molnar committed Nov 23, 2009
1 parent 0c3812e commit d652302
Show file tree
Hide file tree
Showing 3 changed files with 96 additions and 6 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: f5ffe02e5046003ae7e2ce70d3d1c2a73331268b
refs/heads/master: 1b290d670ffa883b7e062177463a8efd00eaa2c1
16 changes: 12 additions & 4 deletions trunk/tools/perf/Documentation/perf-record.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,19 @@ OPTIONS

-e::
--event=::
Select the PMU event. Selection can be a symbolic event name
(use 'perf list' to list all events) or a raw PMU
event (eventsel+umask) in the form of rNNN where NNN is a
hexadecimal event descriptor.
Select the PMU event. Selection can be:

- a symbolic event name (use 'perf list' to list all events)

- a raw PMU event (eventsel+umask) in the form of rNNN where NNN is a
hexadecimal event descriptor.

- a hardware breakpoint event in the form of '\mem:addr[:access]'
where addr is the address in memory you want to break in.
Access is the memory access type (read, write, execute) it can
be passed as follows: '\mem:addr[:[r][w][x]]'.
If you want to profile read-write accesses in 0x1000, just set
'mem:0x1000:rw'.
-a::
System-wide collection.

Expand Down
84 changes: 83 additions & 1 deletion trunk/tools/perf/util/parse-events.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@

#include "../../../include/linux/hw_breakpoint.h"
#include "util.h"
#include "../perf.h"
#include "parse-options.h"
Expand Down Expand Up @@ -540,6 +540,81 @@ static enum event_result parse_tracepoint_event(const char **strp,
attr, strp);
}

static enum event_result
parse_breakpoint_type(const char *type, const char **strp,
struct perf_event_attr *attr)
{
int i;

for (i = 0; i < 3; i++) {
if (!type[i])
break;

switch (type[i]) {
case 'r':
attr->bp_type |= HW_BREAKPOINT_R;
break;
case 'w':
attr->bp_type |= HW_BREAKPOINT_W;
break;
case 'x':
attr->bp_type |= HW_BREAKPOINT_X;
break;
default:
return EVT_FAILED;
}
}
if (!attr->bp_type) /* Default */
attr->bp_type = HW_BREAKPOINT_R | HW_BREAKPOINT_W;

*strp = type + i;

return EVT_HANDLED;
}

static enum event_result
parse_breakpoint_event(const char **strp, struct perf_event_attr *attr)
{
const char *target;
const char *type;
char *endaddr;
u64 addr;
enum event_result err;

target = strchr(*strp, ':');
if (!target)
return EVT_FAILED;

if (strncmp(*strp, "mem", target - *strp) != 0)
return EVT_FAILED;

target++;

addr = strtoull(target, &endaddr, 0);
if (target == endaddr)
return EVT_FAILED;

attr->bp_addr = addr;
*strp = endaddr;

type = strchr(target, ':');

/* If no type is defined, just rw as default */
if (!type) {
attr->bp_type = HW_BREAKPOINT_R | HW_BREAKPOINT_W;
} else {
err = parse_breakpoint_type(++type, strp, attr);
if (err == EVT_FAILED)
return EVT_FAILED;
}

/* We should find a nice way to override the access type */
attr->bp_len = HW_BREAKPOINT_LEN_4;
attr->type = PERF_TYPE_BREAKPOINT;

return EVT_HANDLED;
}

static int check_events(const char *str, unsigned int i)
{
int n;
Expand Down Expand Up @@ -673,6 +748,10 @@ parse_event_symbols(const char **str, struct perf_event_attr *attr)
if (ret != EVT_FAILED)
goto modifier;

ret = parse_breakpoint_event(str, attr);
if (ret != EVT_FAILED)
goto modifier;

fprintf(stderr, "invalid or unsupported event: '%s'\n", *str);
fprintf(stderr, "Run 'perf list' for a list of valid events\n");
return EVT_FAILED;
Expand Down Expand Up @@ -859,6 +938,9 @@ void print_events(void)
"rNNN");
printf("\n");

printf(" %-42s [hardware breakpoint]\n", "mem:<addr>[:access]");
printf("\n");

print_tracepoint_events();

exit(129);
Expand Down

0 comments on commit d652302

Please sign in to comment.