def finder(fd, filter=None, ps=None): """finder entry function""" sys_log = Parse.Parser(fd) #process related pTable = PTable.ProcessTable() if ps: # complete the process name if has ps file pTable.readFromPs(ps) pAdaptor = PAdaptor.ProcessAdaptor(pTable) #loaders iLoader = ILoader.InterfaceLoader(os.path.join(Config.Path.OUT, Config.System.VERSION, "interface")) sSolver = StructureSolver.Solver("Stubs") #transaction manger tManager = TrManager.TransactionManager(pTable, iLoader, sSolver) if filter: tManager.registFilter(filter) #finder start hook point Module.getModule().call("FINDER_START") #start to parse log for flag in sys_log: if flag == Parse.INFO: # handle system INFO info = sys_log.getInfo() try: pAdaptor.action(info) except PAdaptor.UnknownRule: logging.warn("unknown rule: " + str(info)) elif flag == Parse.WRITE_READ: try: tra = Transaction.Transaction(sys_log.getInfo()) tManager.addTransaction(tra) tManager.solve(tra) except Transaction.TransactionError as e: logger.warn("transaction error: " + e.args[0]) # dump unfound descriptor with code logger.info(tManager.getMissedTransaction()) #finder end hook point Module.getModule().call("FINDER_END") print ( __builtin__.json_output )
#show log info parser.add_argument("--info", action="store_true", help="show log info", default=False) parser.add_argument("--not-solve", action="store_true", help="not to solve ICC data", default=False) #ps file to complete process name parser.add_argument("--ps", metavar="CHROME.PS", type=file, help="ps cmd result") args = parser.parse_args() #setup debug flag Config.DEBUG = args.debug #setup not solve flag Config.NOT_SOLVE = args.not_solve return args if __name__ == '__main__': logging.basicConfig(level = logging.INFO) logger = logging.getLogger(__name__) args = parseArgument() filter = FilterAdaptor(args).getFilter() #loaded modules Module.getModule().add("Statistic") Module.getModule().add("TimeSlicer") finder(args.input, filter=filter, ps=args.ps)