mirror of
https://github.com/ARM-software/devlib.git
synced 2025-01-31 10:10:46 +00:00
ftrace: Report unavailable events all at once
Emit one warning message or one exception referring to the whole list of unavailable events, rather than spreading it through multiple calls. In strict mode, this allows the user to fix the whole list of bogus events at once rather than incrementally. Signed-off-by: Douglas RAILLARD <douglas.raillard@arm.com>
This commit is contained in:
parent
bbe3bb6adb
commit
43673e3fc5
@ -125,21 +125,33 @@ class FtraceCollector(TraceCollector):
|
|||||||
self.target_binary = 'trace-cmd'
|
self.target_binary = 'trace-cmd'
|
||||||
|
|
||||||
# Validate required events to be traced
|
# Validate required events to be traced
|
||||||
selected_events = []
|
def event_to_regex(event):
|
||||||
for event in self.events:
|
if not event.startswith('*'):
|
||||||
# Convert globs supported by FTrace into valid regexp globs
|
event = '*' + event
|
||||||
_event = event
|
|
||||||
if event[0] != '*':
|
return re.compile(event.replace('*', '.*'))
|
||||||
_event = '*' + event
|
|
||||||
event_re = re.compile(_event.replace('*', '.*'))
|
def event_is_in_list(event, events):
|
||||||
# Select events matching the required ones
|
return any(
|
||||||
if not list(filter(event_re.match, self.available_events)):
|
event_to_regex(event).match(_event)
|
||||||
message = 'Event [{}] not available for tracing'.format(event)
|
for _event in events
|
||||||
|
)
|
||||||
|
|
||||||
|
unavailable_events = [
|
||||||
|
event
|
||||||
|
for event in self.events
|
||||||
|
if not event_is_in_list(event, self.available_events)
|
||||||
|
]
|
||||||
|
if unavailable_events:
|
||||||
|
message = 'Events not available for tracing: {}'.format(
|
||||||
|
', '.join(unavailable_events)
|
||||||
|
)
|
||||||
if strict:
|
if strict:
|
||||||
raise TargetStableError(message)
|
raise TargetStableError(message)
|
||||||
self.target.logger.warning(message)
|
|
||||||
else:
|
else:
|
||||||
selected_events.append(event)
|
self.target.logger.warning(message)
|
||||||
|
|
||||||
|
selected_events = sorted(set(self.events) - set(unavailable_events))
|
||||||
|
|
||||||
if self.tracer and self.tracer not in self.available_tracers:
|
if self.tracer and self.tracer not in self.available_tracers:
|
||||||
raise TargetStableError('Unsupported tracer "{}". Available tracers: {}'.format(
|
raise TargetStableError('Unsupported tracer "{}". Available tracers: {}'.format(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user