mirror of
				https://github.com/ARM-software/workload-automation.git
				synced 2025-10-29 22:24:51 +00:00 
			
		
		
		
	utils/trace_cmd: expect ': ' in task name
': ' is used as the delimiter for the different parts of of the event line; unfortunately, it is also a valid character sequence to appear in a task name. This change attempts to perform the event line split correctly by ensuring that the cpu id is present in the first part.
This commit is contained in:
		| @@ -239,6 +239,28 @@ DROPPED_EVENTS_REGEX = re.compile(r'CPU:(?P<cpu_id>\d+) \[\d*\s*EVENTS DROPPED\] | ||||
| EMPTY_CPU_REGEX = re.compile(r'CPU \d+ is empty') | ||||
|  | ||||
|  | ||||
| def split_trace_event_line(line): | ||||
|     """ | ||||
|     Split a trace-cmd event line into the preamble (containing the task, cpu id | ||||
|     and timestamp), the event name, and the event body. Each of these is | ||||
|     delimited by a ': ' (optionally followed by more whitespace), however ': ' | ||||
|     may also appear in the body of the event and in the thread name. This | ||||
|     attempts to identify the correct split by ensureing the there is a '[' | ||||
|     (used to mark the cpu id and not a valid character for a task name) in the | ||||
|     peramble. | ||||
|  | ||||
|     """ | ||||
|     parts = line.split(': ') | ||||
|     if len(parts) <= 3: | ||||
|         return parts | ||||
|  | ||||
|     preamble = parts.pop(0) | ||||
|     while '[' not in preamble: | ||||
|         preamble += ': ' + parts.pop(0) | ||||
|     event_name = parts.pop(0) | ||||
|     return (preamble, event_name, ': '.join(parts)) | ||||
|  | ||||
|  | ||||
| class TraceCmdTrace(object): | ||||
|  | ||||
|     @property | ||||
| @@ -293,7 +315,7 @@ class TraceCmdTrace(object): | ||||
|                         continue | ||||
|  | ||||
|                 # <thread/cpu/timestamp>: <event name>: <event body> | ||||
|                 parts = line.split(': ', 2) | ||||
|                 parts = split_trace_event_line(line) | ||||
|                 if len(parts) != 3: | ||||
|                     continue | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user