os/graphics/fbs/fontandbitmapserver/utils/threadname.py
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
sl@0
     1
# Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
sl@0
     2
# All rights reserved.
sl@0
     3
# This component and the accompanying materials are made available
sl@0
     4
# under the terms of "Eclipse Public License v1.0"
sl@0
     5
# which accompanies this distribution, and is available
sl@0
     6
# at the URL "http://www.eclipse.org/legal/epl-v10.html".
sl@0
     7
#
sl@0
     8
# Initial Contributors:
sl@0
     9
# Nokia Corporation - initial contribution.
sl@0
    10
#
sl@0
    11
# Contributors:
sl@0
    12
#
sl@0
    13
# Description:
sl@0
    14
# Utility function to append thread names where the Thread Id maps to a known thread/process name.
sl@0
    15
sl@0
    16
import re
sl@0
    17
sl@0
    18
# Takes as input list <data> which contains OST traces from the SYMBIAN_KERNEL_THREAD_IDENTIFICATION trace group in Symbian
sl@0
    19
# BTrace Hooks OST dictionary. Returns a list with the same content as <data> with thread names appended.
sl@0
    20
def addnames(data):
sl@0
    21
	result = []
sl@0
    22
	processNames = {}
sl@0
    23
	threadNames = {}
sl@0
    24
	rthreadIds = {}
sl@0
    25
	
sl@0
    26
	for line in data:		
sl@0
    27
		pattern = "^.*Thread:Process name assigned;NThread:(.*);DProcess:(.*);Name:(.*)$"
sl@0
    28
		matched = re.search(pattern, line)
sl@0
    29
		if matched:
sl@0
    30
			processNames[matched.group(2)] = matched.group(3)	
sl@0
    31
			
sl@0
    32
		pattern = "^.*Thread:Thread created;NThread:(.*);DProcess:(.*);Name:(.*)$"
sl@0
    33
		matched = re.search(pattern, line)
sl@0
    34
		if matched:
sl@0
    35
			threadNames[matched.group(1)] = processNames[matched.group(2)]+":"+matched.group(3)
sl@0
    36
		
sl@0
    37
		pattern = "^.*Thread:Thread name assigned;NThread:(.*);DProcess:(.*);Name:(.*)$"
sl@0
    38
		matched = re.search(pattern, line)
sl@0
    39
		if matched:
sl@0
    40
			threadNames[matched.group(1)] = processNames[matched.group(2)]+":"+matched.group(3)
sl@0
    41
sl@0
    42
		pattern = "^.*Thread:Thread ID assigned;NThread:(.*);DProcess:(.*);RThread ID:(\d*)$"
sl@0
    43
		matched = re.search(pattern, line)
sl@0
    44
		if matched:
sl@0
    45
			rthreadIds[matched.group(3)] = matched.group(1)
sl@0
    46
			
sl@0
    47
		pattern = "(^.*Thread ID:)(\w*)(.*)$"
sl@0
    48
		matched = re.search(pattern, line)
sl@0
    49
		if matched:
sl@0
    50
			threadId = matched.group(2)
sl@0
    51
			if threadNames.has_key(threadId):
sl@0
    52
				line = matched.group(1)+threadId+":"+threadNames[threadId]+matched.group(3)
sl@0
    53
	
sl@0
    54
		pattern = "(^.*clientThreadId )(\w*)(.*)$"
sl@0
    55
		matched = re.search(pattern, line)
sl@0
    56
		if matched:
sl@0
    57
			rthreadIdHex = matched.group(2)
sl@0
    58
			rthreadId = hex(rthreadIdHex)
sl@0
    59
			if rthreadIds.has_key(rthreadId):
sl@0
    60
				threadId = rthreadIds[rthreadId]
sl@0
    61
				threadName = threadNames[threadId]
sl@0
    62
				line = matched.group(1)+rthreadId+":"+threadName+matched.group(3)
sl@0
    63
				
sl@0
    64
		pattern = "(^.*threadId )(\w*)(.*)$"
sl@0
    65
		matched = re.search(pattern, line)
sl@0
    66
		if matched:
sl@0
    67
			rthreadIdHex = matched.group(2)
sl@0
    68
			rthreadId = hex(rthreadIdHex)
sl@0
    69
			if rthreadIds.has_key(rthreadId):
sl@0
    70
				threadId = rthreadIds[rthreadId]
sl@0
    71
				threadName = threadNames[threadId]
sl@0
    72
				line = matched.group(1)+rthreadId+":"+threadName+matched.group(3)
sl@0
    73
				
sl@0
    74
		result.append(line)
sl@0
    75
				
sl@0
    76
	return result