コード例 #1
0
ファイル: GenStatsData.py プロジェクト: clccc/xpoint
    def ConvertOutData_Detail(self, callsopsinfolist):
        dbcalls = DataStruct_D.DbCalls()
        dbcalls.numofcalls = len(callsopsinfolist)
        dbcalls.callinfolist = [
            DataStruct_D.CallInfo(a[0], a[1], a[2], [
                DataStruct_D.CallSiteInfo(
                    b[0], b[1], b[2], [DataStruct_D.ArgInfo(*c) for c in b[3]])
                for b in a[3]
            ]) for a in callsopsinfolist
        ]

        filename = "../Data/ConvertedOutData_Detail_%s.data" % time.strftime(
            '%Y%m%d-%H%M%S')
        print "生成ConvertOutData_Detail转换后的数据文件:%s" % filename
        objfile = ObjDataAndBinFile.ObjDataAndBinFile()
        objfile.objdata2file(dbcalls, filename)

        return dbcalls
コード例 #2
0
    def GenVectorD_10(self, filename):
        # 将callsite的各参数对应的度量值累加,参数之间存在重复的度量也多次计算;对一个call,将callsites的度量取平均值

        objfile = ObjDataAndBinFile()
        dbcalls = DataStruct_D.DbCalls()
        dbcalls = objfile.binfile2objdata(filename)
        callinfo = []

        for call in dbcalls.callinfolist:
            tmp_call_cnd_num = 0
            tmp_args_stmtsleft_num = 0
            tmp_args_stmtsright_num = 0
            tmp_args_stmtscall_num = 0
            tmp_args_cnd_num = 0
            tmp_args_coleaves_num = 0
            tmp_args_cocnds_num = 0
            tmp_args_cocnds_list = []

            for callsite in call.callsiteinfolist:
                flag_args_stmtsleft = False
                flag_args_stmtsright = False
                flag_args_stmtscall = False
                flag_args_cnd = False
                flag_coleaves = False
                flag_args_cocnds = False
                if (len(callsite.callsite_conditionslist) > 0):
                    tmp_call_cnd_num += 1
                for arginfo in callsite.callsite_argsinfolist:
                    if (len(arginfo.arg_stmtsleftlist) >= 1):
                        flag_args_stmtsleft = True
                    if (len(arginfo.arg_stmtsrightlist) >= 1):
                        flag_args_stmtsright = True
                    if (len(arginfo.arg_stmtiscalllist) >= 1):
                        flag_args_stmtscall = True
                    if (len(arginfo.arg_condidlist) >= 1):
                        flag_args_cnd = True

                if (flag_args_stmtsleft):
                    tmp_args_stmtsleft_num += 1
                if (flag_args_stmtsright):
                    tmp_args_stmtsright_num += 1
                if (flag_args_stmtscall):
                    tmp_args_stmtscall_num += 1
                if (flag_args_cnd):
                    tmp_args_cnd_num += 1

                for i in range(0, len(callsite.callsite_argsinfolist)):
                    for j in range(i + 1, len(callsite.callsite_argsinfolist)):
                        for val_leaf in callsite.callsite_argsinfolist[
                                i].arg_stmtsleftlist:
                            if val_leaf in callsite.callsite_argsinfolist[
                                    j].arg_stmtsrightlist:
                                flag_coleaves = True
                        #如果处于共同的call中,也视为相互定义
                        for val_call in callsite.callsite_argsinfolist[
                                i].arg_stmtiscalllist:
                            if val_call in callsite.callsite_argsinfolist[
                                    j].arg_stmtiscalllist:
                                flag_coleaves = True

                        for val_cnd in callsite.callsite_argsinfolist[
                                i].arg_condidlist:
                            if val_cnd in callsite.callsite_argsinfolist[
                                    j].arg_condidlist:
                                flag_args_cocnds = True

                if (flag_coleaves):
                    tmp_args_coleaves_num += 1
                    flag_coleaves = False
                if (flag_args_cocnds):
                    tmp_args_cocnds_num += 1
                    flag_args_cocnds = False

            #有些类的内部的函数,没能正确获取相关数据,占少数,比例,如370:6596
            '''
            if (call.callsiteNums != 0):
                callinfo.append([call.call_id,
                                 call.call_code,
                                 call.callsiteNums,
                                 tmp_call_cnd_num,
                                 tmp_args_stmtsleft_num ,
                                 tmp_args_stmtsright_num ,
                                 tmp_args_stmtscall_num ,
                                 tmp_args_cnd_num ,
                                 tmp_args_coleaves_num ,
                                 tmp_args_cocnds_num
                                 ])
            '''
            '''
            if (call.callsiteNums != 0):
                callinfo.append([call.call_id,
                                 call.call_code,
                                 call.callsiteNums,
                                 1 if tmp_args_cnd_num > call.callsiteNums/2 else 0,
                                 1 if tmp_args_coleaves_num > call.callsiteNums/2 else 0,
                                 1 if tmp_args_cocnds_num > call.callsiteNums/2 else 0
                                 ])
            '''
            '''
            if (call.callsiteNums != 0):
                callinfo.append([call.call_id,
                                 call.call_code,
                                 call.callsiteNums,
                                 round(tmp_call_cnd_num/float(call.callsiteNums),3),
                                 round(tmp_args_stmtsleft_num/float(call.callsiteNums),3) ,
                                 round(tmp_args_stmtsright_num/float(call.callsiteNums),3) ,
                                 round(tmp_args_stmtscall_num/float(call.callsiteNums),3) ,
                                 round(tmp_args_cnd_num/float(call.callsiteNums),3) ,
                                 round(tmp_args_coleaves_num/float(call.callsiteNums),3) ,
                                 round(tmp_args_cocnds_num/float(call.callsiteNums),3)
                                 ])
            '''
            if (call.callsiteNums != 0):
                callinfo.append([
                    call.call_id, call.call_code, call.callsiteNums,
                    round(tmp_args_cnd_num / float(call.callsiteNums), 3),
                    round(tmp_args_coleaves_num / float(call.callsiteNums), 3),
                    round(tmp_args_cocnds_num / float(call.callsiteNums), 3)
                ])

        return callinfo