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>
This commit is contained in:
committed by
Arnaldo Carvalho de Melo
parent
50d8f9e393
commit
7582732f57
@ -383,21 +383,31 @@ parse_breakpoint_type(const char *type, struct perf_event_attr *attr)
|
||||
if (!type || !type[i])
|
||||
break;
|
||||
|
||||
#define CHECK_SET_TYPE(bit) \
|
||||
do { \
|
||||
if (attr->bp_type & bit) \
|
||||
return -EINVAL; \
|
||||
else \
|
||||
attr->bp_type |= bit; \
|
||||
} while (0)
|
||||
|
||||
switch (type[i]) {
|
||||
case 'r':
|
||||
attr->bp_type |= HW_BREAKPOINT_R;
|
||||
CHECK_SET_TYPE(HW_BREAKPOINT_R);
|
||||
break;
|
||||
case 'w':
|
||||
attr->bp_type |= HW_BREAKPOINT_W;
|
||||
CHECK_SET_TYPE(HW_BREAKPOINT_W);
|
||||
break;
|
||||
case 'x':
|
||||
attr->bp_type |= HW_BREAKPOINT_X;
|
||||
CHECK_SET_TYPE(HW_BREAKPOINT_X);
|
||||
break;
|
||||
default:
|
||||
return -EINVAL;
|
||||
}
|
||||
}
|
||||
|
||||
#undef CHECK_SET_TYPE
|
||||
|
||||
if (!attr->bp_type) /* Default */
|
||||
attr->bp_type = HW_BREAKPOINT_R | HW_BREAKPOINT_W;
|
||||
|
||||
|
Reference in New Issue
Block a user