Exemplo n.º 1
0
    def packFields(self):
        args = {}
        filled = 0
        i = 0
        for field in self.getTraceFields():

            fieldType = self.getFieldType(field)
            if self.isListField(field):
                if filled > 0:
                    args[i] = args[i] + ")"
                    i = i+1
                    filled = 0
                # for C we need an extra argument, the size of the list, which
                # is computed in pemGenPEMAPI
                if pemGlobals.language == 'C':
                    #args[i] = string.replace(self.getListCount(field), '_', '', 1) + \
                    #          "* (" + pemTypes.getTypeBitSize(fieldType) + " >> 3)"
                    #args[i+1] = field
                    args[i] = '___listLength'
                    args[i+1] = '(void *)___tmpBuffer'
                    i = i+2
                else:
                    args[i] = field
                    i = i+1
            
            elif fieldType == 'uint64' or fieldType == 'string':
                if filled > 0:
                    args[i] = args[i] + ")"
                    i = i+1
                    filled = 0
                args[i] = field
                i = i+1
            else:
                typeBitSize = int(pemTypes.getTypeBitSize(fieldType))
                if (filled + typeBitSize) <= 64:
                    if not args.has_key(i):
                        args[i] = "("+pemTypes.getCType('uint64')+ ")("
                    if filled > 0:
                        args[i] = args[i] + "|"
                    args[i] = args[i] + \
                              "((("+pemTypes.getCType('uint64')+")"+field+")<<"+\
                              str(64-filled-typeBitSize) + ")"
                else:
                    i = i + 1
                    args[i] = "("+pemTypes.getCType('uint64')+ ")(" + \
                              "((("+pemTypes.getCType('uint64')+")"+field+")<<"+\
                              str(64-filled-typeBitSize) + ")"
                    filled = 0
                filled = filled + typeBitSize
                
                if filled == 64: 
                    args[i] = args[i] + ")"
                    i = i+1
                    filled = 0 

        if filled > 0:
            args[i] = args[i] + ")"

        return args
Exemplo n.º 2
0
    def packFields(self):
        args = {}
        filled = 0
        i = 0
        for field in self.getTraceFields():

            fieldType = self.getFieldType(field)
            if self.isListField(field):
                if filled > 0:
                    args[i] = args[i] + ")"
                    i = i + 1
                    filled = 0
                # for C we need an extra argument, the size of the list, which
                # is computed in pemGenPEMAPI
                if pemGlobals.language == 'C':
                    #args[i] = string.replace(self.getListCount(field), '_', '', 1) + \
                    #          "* (" + pemTypes.getTypeBitSize(fieldType) + " >> 3)"
                    #args[i+1] = field
                    args[i] = '___listLength'
                    args[i + 1] = '(void *)___tmpBuffer'
                    i = i + 2
                else:
                    args[i] = field
                    i = i + 1

            elif fieldType == 'uint64' or fieldType == 'string':
                if filled > 0:
                    args[i] = args[i] + ")"
                    i = i + 1
                    filled = 0
                args[i] = field
                i = i + 1
            else:
                typeBitSize = int(pemTypes.getTypeBitSize(fieldType))
                if (filled + typeBitSize) <= 64:
                    if not args.has_key(i):
                        args[i] = "(" + pemTypes.getCType('uint64') + ")("
                    if filled > 0:
                        args[i] = args[i] + "|"
                    args[i] = args[i] + \
                              "((("+pemTypes.getCType('uint64')+")"+field+")<<"+\
                              str(64-filled-typeBitSize) + ")"
                else:
                    i = i + 1
                    args[i] = "("+pemTypes.getCType('uint64')+ ")(" + \
                              "((("+pemTypes.getCType('uint64')+")"+field+")<<"+\
                              str(64-filled-typeBitSize) + ")"
                    filled = 0
                filled = filled + typeBitSize

                if filled == 64:
                    args[i] = args[i] + ")"
                    i = i + 1
                    filled = 0

        if filled > 0:
            args[i] = args[i] + ")"

        return args
Exemplo n.º 3
0
def genInlineMethods(events, classId):

    # generate the generic inlines
    if pemGlobals.dialect == 'K42':
        print '_XLC_INLINE uval'
        print "trace" + classId + "Enabled() {"
        if pemGlobals.genTraceStubs > 0:
            print "#ifdef TRACE_STUBS"
            print "\tfprintf(stderr, \"trace" + classId + "Enabled()\\n\");"
            print "#else"
        print "\treturn (kernelInfoLocal.traceInfo.mask & " + \
          pemEvent.getEventMaskMacro(classId) + ");"
        if pemGlobals.genTraceStubs > 0: print "#endif"
        print "}"
        print '\n'

    for anEvent in events:

        print '_XLC_INLINE void'
        print "Trace" + anEvent.getQualifiedSpecifier(),
        print "(",
        # print "TimestampT timestamp",

        hasListFields = 0
        printComma = 0
        for field in anEvent._fieldSeq:
            fieldType = anEvent.getFieldType(field)
            if printComma == 1: print ",",
            else: printComma = 1
            if fieldType == 'string': print "const",
            if anEvent.isListField(field):
                print pemTypes.getCType(fieldType), '*', field,
                hasListFields = 1
            else:
                print pemTypes.getCType(fieldType), field,
        print ") {"

        if pemGlobals.genTraceStubs > 0:
            print "#ifdef TRACE_STUBS"
            genPrintStatement(anEvent)
            print "#else"

        #if pemGlobals.dialect == 'K42':
        #    genK42MethodBody(anEvent, hasListFields)
        #else:
        #    genAPIMethodBody(anEvent, hasListFields)
        if pemGlobals.dialect == 'AIX':
            genAIXMethodBody(anEvent, hasListFields)
        else:
            genMethodBody(anEvent, hasListFields)

        if pemGlobals.genTraceStubs > 0: print "#endif"
        print "}\n"
Exemplo n.º 4
0
def genInlineMethods(events, classId):

    # generate the generic inlines
    if pemGlobals.dialect == 'K42':
        print '_XLC_INLINE uval'
        print "trace" + classId + "Enabled() {"
        if pemGlobals.genTraceStubs > 0:
            print "#ifdef TRACE_STUBS"
            print "\tfprintf(stderr, \"trace" + classId + "Enabled()\\n\");"
            print "#else"
        print "\treturn (kernelInfoLocal.traceInfo.mask & " + \
         	pemEvent.getEventMaskMacro(classId) + ");"
        if pemGlobals.genTraceStubs > 0: print "#endif"
        print "}"
        print '\n'

    for anEvent in events:

        print '_XLC_INLINE void'
        print "Trace" + anEvent.getQualifiedSpecifier(),
        print "(",
        # print "TimestampT timestamp",

        hasListFields = 0
        printComma = 0
        for field in anEvent._fieldSeq:
            fieldType = anEvent.getFieldType(field)
            if printComma == 1: print ",",
            else:               printComma = 1
            if fieldType == 'string': print "const",
            if anEvent.isListField(field):
                print pemTypes.getCType(fieldType), '*', field,
                hasListFields = 1
            else:
                print pemTypes.getCType(fieldType), field,
        print ") {"

        if pemGlobals.genTraceStubs > 0:
            print "#ifdef TRACE_STUBS"
            genPrintStatement(anEvent)
            print "#else"

        #if pemGlobals.dialect == 'K42':
        #    genK42MethodBody(anEvent, hasListFields)
        #else:
        #    genAPIMethodBody(anEvent, hasListFields)
        if pemGlobals.dialect == 'AIX':
            genAIXMethodBody(anEvent, hasListFields)
        else:
            genMethodBody(anEvent, hasListFields)
        
        if pemGlobals.genTraceStubs > 0: print "#endif"
        print "}\n"
Exemplo n.º 5
0
def genAixCWrappers(layerId, classId, layerEvents):

    wrappers = []
    classIdUpper = string.upper(classId)
    genCPreamble()
    print '#include "trace' + classId + '.h"\n'

    for anEvent in layerEvents[classId]:
        args = []
        for field in anEvent._fieldSeq:
            args.append(anEvent.getFieldType(field))

        fName = "Trace" + anEvent.getQualifiedSpecifier()
        wrappers.append(fName)
        fNameLower = string.lower(fName)
        print fNameLower + " ( ",
        whichArg = 0
        printComma = 0
        for arg in args:
            if printComma == 1: print ", ",
            else:               printComma = 1
            if arg == 'string':
                print pemTypes.getCType(arg) + " data" + str(whichArg),
                print ", int len" + str(whichArg),
            else:
                print pemTypes.getCType(arg) +" * data"+ str(whichArg),
            whichArg = whichArg+1
        print ") {"
        # add a NULL if there are string args
        whichArg = 0
        for arg in args:
            if arg == 'string':
                print "\t((char *)data"+str(whichArg) + ")[len"+str(whichArg) + \
                      "] = '\\0';"
            whichArg = whichArg + 1
        # now call the mixed case C function
        print "\t" + fName + " ( ",
        whichArg = 0
        printComma = 0
        for arg in args:
            if printComma == 1: print ", ",
            else:               printComma = 1
            if arg == 'string':
                print "data" + str(whichArg),
            else:
                print "*data"+ str(whichArg),
            whichArg = whichArg+1
Exemplo n.º 6
0
def genK42Wrappers(layerId, classId, layerEvents):

    wrappers = []
    classIdUpper = string.upper(classId)
    print "#include <trace/trace" + classId + ".h>\n"
        
    # generate the trace event macros/inlines
    fName = "trace" + classId + "Enabled"
    wrappers.append(fName)
    fName = string.lower(fName)	
    print 'inline uval'
    print fName + "() {"
    print "\treturn (kernelInfoLocal.traceInfo.mask & " + \
          pemEvent.getEventMaskMacro(classId) + ");"
    print "}"
    print '\n'
    
    # generate the generic inline functions
    # genGenericInlines(classId) 

    # a list of lists of data arguments
    dataArgs = []
    for anEvent in layerEvents[classId]:
        args = []
        for field in anEvent._fieldSeq:
            args.append(anEvent.getFieldType(field))
        if dataArgs.count(args) == 0:
            dataArgs.append(args)

    # generate all the inlines
    for args in dataArgs:
        (words, strings) = countWordsAndStrings(args)

        print 'inline void'
        fName = getMethodName(classId, args)
        wrappers.append(fName)
	fName = string.lower(fName)
        print fName + "(uval16 * minorId",
        whichArg = 0
        for arg in args:
            if arg == 'string':
                print ", "+ pemTypes.getCType(arg) + " data" + str(whichArg),
                print ", int len" + str(whichArg),
            else:
                print ", "+ pemTypes.getCType(arg) +" * data"+ str(whichArg),
            whichArg = whichArg+1
        print ") {"
        print "\t if(unlikely(kernelInfoLocal.traceInfo.mask & " + \
              pemEvent.getEventMaskMacro(classId) + ")) {"
        if strings == 0:
            print "\t\ttraceDefault" + str(len(args)),
            print "(TRACE_" + classIdUpper + "_MAJOR_ID, *minorId," + \
                  pemEvent.getLayerIdMacro(layerId),
        else:
            # add a NULL if there are string args
            whichArg = 0
            for arg in args:
                if arg == 'string':
                    print "\t\t((char *)data"+str(whichArg) + ")[len"+str(whichArg) + \
                          "] = '\\0';"
                whichArg = whichArg + 1
            print "\t\ttraceDefaultGeneric (",
            print "TRACE_" + classIdUpper + "_MAJOR_ID, *minorId," + \
                  pemEvent.getLayerIdMacro(layerId) + ",",
            print str(words) + ", " + str(strings),
        whichArg = 0
        for arg in args:
            if arg == 'string':  print ", data" + str(whichArg),
            else:                print ", *data" + str(whichArg),
            whichArg = whichArg + 1
        print ");"
        print "\t}"
        print "}\n"
Exemplo n.º 7
0
def genGenericWrappers(layerId, classId, layerEvents):

    print '#define uval unsigned int'
    print '#define uval16 unsigned short'
    print '#define uval32 unsigned long'
    print '#define uval64 unsigned long long'
    print "#include <trace" + classId + ".h>\n"
        
    wrappers = []
    classIdUpper = string.upper(classId)
    # a list of lists of data arguments
    dataArgs = []
    for anEvent in layerEvents[classId]:
        args = []
        for field in anEvent._fieldSeq:
            args.append(anEvent.getFieldType(field))
        if dataArgs.count(args) == 0:
            dataArgs.append(args)

    # generate all the inlines
    for args in dataArgs:
        (words, strings) = countWordsAndStrings(args)

        print 'inline void'
        fName = getMethodName(classId, args)
        wrappers.append(fName)
	fName = string.lower(fName)
        print fName + "(uval16 * minorId",
        whichArg = 0
        for arg in args:
            if arg == 'string':
                print ", "+ pemTypes.getCType(arg) + " data" + str(whichArg),
                print ", int len" + str(whichArg),
            else:
                print ", "+ pemTypes.getCType(arg) +" * data"+ str(whichArg),
            whichArg = whichArg+1
        print ") {"

        if strings == 0:
            print "\t\tnotifyEvent" + str(len(args)) + "(",
            print "(("+pemEvent.getLayerIdMacro(layerId) + "<<20)|(TRACE_"\
                  + classIdUpper + "_MAJOR_ID<<14)|(*minorId))",
                  
        else:
            print "\t\tnotifyEventGeneric (",
            print "(("+pemEvent.getLayerIdMacro(layerId) + "<<20)|(TRACE_"\
                  + classIdUpper + "_MAJOR_ID<<14)|(*minorId))" + ",",
            print str(words) + ", " + str(strings),
        whichArg = 0
        for arg in args:
            if arg == 'string':  print ", data" + str(whichArg),
            else:                print ", *data" + str(whichArg),
            whichArg = whichArg + 1
        print ");"
        print "}"

        print "#ifdef __GNUC__"
        print "void "+fName+"_() __attribute__ ((weak,alias(\""+fName+"\")));"
        print "#endif"

        print '\n'