Esempio n. 1
0
def translateUserType(xmlType):
    global xmlTypesMap
    if not pemTypes.isBasicPemType(xmlType):
        if xmlTypesMap.has_key(xmlType):
            return xmlTypesMap[xmlType]
        else:
            raise xml.parsers.expat.error('Non-mapped user type: ' + xmlType)

    return xmlType
Esempio n. 2
0
def startElementHandler(name, attrs):
    global currentEvent
    global classesLayer, classesMap, classIds
    global traceLayout

    if pemGlobals.debugLevel > 2:
        print 'startElementHandler(', name, ',', attrs, ')'

    if name == "event":
        currentEvent = pemEvent.event()
        currentEvent._name = attrs['name']
        currentEvent._traceLayout = traceLayout
        if attrs.has_key('description'):
            currentEvent._description = attrs['description']
        if attrs.has_key('AIXID'):
            currentEvent._aixId = attrs['AIXID']
        if attrs.has_key('traceLayout'):  # overwrite the global setting
            currentEvent._traceLayout = string.lower(attrs['traceLayout'])

    elif name == "field":
        if attrs.has_key('description'): descr = attrs['description']
        else: descr = None
        if attrs.has_key('size'): listSize = attrs['size']
        else: listSize = None
        if not attrs.has_key('type'):
            raise xml.parsers.expat.error(
                'type attribute is mandatory for fields')
        if attrs['type'] == "list":
            currentEvent.addListField(attrs['name'], 'list',
                                      translateUserType(attrs['eltType']),
                                      listSize, descr)
        else:
            currentEvent.addField(attrs['name'],
                                  translateUserType(attrs['type']), descr)
        if attrs.has_key('vtype'):
            currentEvent._fieldsVisSize[attrs['name']] = attrs['vtype']
        if attrs.has_key('AIXOffset'):
            currentEvent.setAIXOffset(attrs['name'], attrs['AIXOffset'])
        if attrs.has_key('format'):
            currentEvent.setFieldFormat(attrs['name'], attrs['format'])

    elif name == "layerId" and attrs.has_key('value'):
        if not pemEvent.PEMLayers.has_key(attrs['value']):
            raise xml.parsers.expat.error("Invalid LayerId " + attrs['value'])
        currentEvent._layerId = attrs['value']

    elif name == "classId" and attrs.has_key('value'):
        currentEvent._classId = attrs['value']

    elif name == "specifier" and attrs.has_key('value'):
        currentEvent._specifier = attrs['value']

    elif name == "printfString":
        currentEvent._recPrintData = 1

    elif name == "javaFormat":
        raise xml.parsers.expat.error("javaFormat tag is obsolete")

    elif name == "k42Format":
        if pemGlobals.debugLevel > 0:
            print "k42Format tag soon will become obsolete"
        currentEvent._printFormat = convertK42Format(attrs['value'])

    elif name == "printFormat":
        currentEvent._printFormat = attrs['value']

    elif name == "stateChange":
        currentEvent._stateChange = attrs['type'], attrs['value']

    elif name == "sourceCodeInfo":
        if attrs.has_key('pc'):
            currentEvent._sourceCode = attrs['type'], attrs['pc']
        else:
            currentEvent._sourceCode = attrs['type'], attrs['file'], attrs[
                'line']
    # currentEvent._sourceCode = attrs['type'], attrs['file'], attrs['line']

    elif name == "computedField":
        if attrs.has_key('description'): descr = attrs['description']
        else: descr = None
        currentEvent.addComputedField(attrs['name'],
                                      translateUserType(attrs['type']),
                                      attrs['expr'], descr)

    elif name == "inflatedField":
        if attrs.has_key('description'): descr = attrs['description']
        else: descr = None
        if attrs.has_key('value'): value = attrs['value']
        else: value = None
        if attrs.has_key('size'): listSize = attrs['size']
        else: listSize = None
        if not attrs.has_key('type'):
            raise xml.parsers.expat.error(
                'type attribute is mandatory for fields')
        if attrs['type'] == "list":
            currentEvent.addInflatedListField(
                attrs['name'], 'list', translateUserType(attrs['eltType']),
                listSize, descr)
        else:
            currentEvent.addInflatedField(attrs['name'],
                                          translateUserType(attrs['type']),
                                          value, descr)

    elif name == "interval":
        if attrs.has_key('fields'): fields = attrs['fields']
        else: fields = None
        if attrs.has_key('match'): match = attrs['match']
        else: match = None
        currentEvent.addInterval(attrs['name'], attrs['type'], attrs['pair'],
                                 match, fields)

    elif name == 'classList':
        classesLayer = attrs['layerId']
        if not classesMap.has_key(classesLayer):
            classesMap[classesLayer] = {}
        classIds[classesLayer] = []

    elif name == "class":
        if classesLayer == None: raise "missing layerId in <classList>"
        classesMap[classesLayer][attrs['value']] = attrs['id']

    elif name == 'hwEventList':
        global currentHWProcessor
        currentHWProcessor = attrs['processor']
        pemGlobals.hasHWEventList = 1
    elif name == 'hwEvent':
        global procEvents
        procEvents.append((attrs['value'], attrs['description']))

    elif name == 'map':
        global xmlTypesMap
        if not pemTypes.isBasicPemType(attrs['to']):
            raise xml.parsers.expat.error('Invalid user type map ' + \
                                          attrs['type'])
        xmlTypesMap[attrs['type']] = attrs['to']

    elif name == 'PEM_Events':
        if attrs.has_key('traceLayout'): traceLayout = attrs['traceLayout']

    elif name == 'property':
        # mechanism to pass values between trace records
        field = None
        name = None
        if attrs.has_key('name'): field = attrs['name']
        if attrs.has_key('field'): name = attrs['field']
        currentEvent.addProperty(name, field)