aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/util/parse-events.c
diff options
context:
space:
mode:
authorJiri Olsa <jolsa@redhat.com>2012-06-29 03:22:54 -0400
committerArnaldo Carvalho de Melo <acme@redhat.com>2012-06-29 12:28:13 -0400
commit7582732f57e547929d4c65ad8e38f3446e0538d8 (patch)
tree1445f53d5e467f8e20da4cb100bc646cd3748336 /tools/perf/util/parse-events.c
parent50d8f9e393c5a1a8864fda75e3a9f2b800497a61 (diff)
perf tools: Fix hw breakpoint's type modifier parsing
Fixing the hw breakpoint's type modifier parsing to allow all possible combinations of 'rwx' characters. Adding automated tests to the parsing test suite. Reported-by: Jovi Zhang <bookjovi@gmail.com> Original-patch-by: Namhyung Kim <namhyung@kernel.org> Signed-off-by: Jiri Olsa <jolsa@redhat.com> Cc: Jovi Zhang <bookjovi@gmail.com> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Paul Mackerras <paulus@samba.org> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Link: http://lkml.kernel.org/r/20120629072254.GA940@krava.brq.redhat.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/util/parse-events.c')
-rw-r--r--tools/perf/util/parse-events.c16
1 files changed, 13 insertions, 3 deletions
diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c
index 0cc27da30ddb..7ae76af709f1 100644
--- a/tools/perf/util/parse-events.c
+++ b/tools/perf/util/parse-events.c
@@ -383,21 +383,31 @@ parse_breakpoint_type(const char *type, struct perf_event_attr *attr)
383 if (!type || !type[i]) 383 if (!type || !type[i])
384 break; 384 break;
385 385
386#define CHECK_SET_TYPE(bit) \
387do { \
388 if (attr->bp_type & bit) \
389 return -EINVAL; \
390 else \
391 attr->bp_type |= bit; \
392} while (0)
393
386 switch (type[i]) { 394 switch (type[i]) {
387 case 'r': 395 case 'r':
388 attr->bp_type |= HW_BREAKPOINT_R; 396 CHECK_SET_TYPE(HW_BREAKPOINT_R);
389 break; 397 break;
390 case 'w': 398 case 'w':
391 attr->bp_type |= HW_BREAKPOINT_W; 399 CHECK_SET_TYPE(HW_BREAKPOINT_W);
392 break; 400 break;
393 case 'x': 401 case 'x':
394 attr->bp_type |= HW_BREAKPOINT_X; 402 CHECK_SET_TYPE(HW_BREAKPOINT_X);
395 break; 403 break;
396 default: 404 default:
397 return -EINVAL; 405 return -EINVAL;
398 } 406 }
399 } 407 }
400 408
409#undef CHECK_SET_TYPE
410
401 if (!attr->bp_type) /* Default */ 411 if (!attr->bp_type) /* Default */
402 attr->bp_type = HW_BREAKPOINT_R | HW_BREAKPOINT_W; 412 attr->bp_type = HW_BREAKPOINT_R | HW_BREAKPOINT_W;
403 413