def forkat(forknum, clnum, pending): global program print "forkat",forknum,clnum,pending REGSIZE = program.tregs[1] dat = [] for p in pending: daddr = fhex(p['daddr']) ddata = fhex(p['ddata']) if len(p['ddata']) > 4: # ugly hack dsize = REGSIZE else: dsize = 1 flags = qira_log.IS_VALID | qira_log.IS_WRITE if daddr >= 0x1000: flags |= qira_log.IS_MEM flags |= dsize*8 dat.append((daddr, ddata, clnum-1, flags)) next_run_id = qira_socat.get_next_run_id() if len(dat) > 0: qira_log.write_log(qira_config.TRACE_FILE_BASE+str(next_run_id)+"_mods", dat) if args.server: qira_socat.start_bindserver(program, qira_config.FORK_PORT, forknum, clnum) else: if os.fork() == 0: program.execqira(["-qirachild", "%d %d %d" % (forknum, clnum, next_run_id)])
# qemu args from command line qemu_args = [] if args.gate_trace != None: qemu_args.append("-gatetrace") qemu_args.append(args.gate_trace) # creates the file symlink, program is constant through server run program = qira_program.Program(args.binary, args.args, qemu_args) is_qira_running = 1 try: socket.create_connection(('127.0.0.1', qira_config.WEB_PORT)) if args.server: raise Exception("can't run as server if QIRA is already running") except: is_qira_running = 0 print "no qira server found, starting it" program.clear() # start the binary runner if args.server: qira_socat.start_bindserver(program, qira_config.SOCAT_PORT, -1, 1, True) else: print "**** running " + program.program program.execqira(shouldfork=not is_qira_running) if not is_qira_running: # start the http server qira_webserver.run_server(args, program)
# qemu args from command line qemu_args = [] if args.gate_trace != None: qemu_args.append("-gatetrace") qemu_args.append(args.gate_trace) # creates the file symlink, program is constant through server run program = qira_program.Program(args.binary, args.args, qemu_args) is_qira_running = 1 try: socket.create_connection(('127.0.0.1', qira_config.WEB_PORT)) if args.server: raise Exception("can't run as server if QIRA is already running") except: is_qira_running = 0 print "no qira server found, starting it" program.clear() # start the binary runner if args.server: qira_socat.start_bindserver(program, qira_config.SOCAT_PORT, -1, 1, True) else: print "**** running "+program.program program.execqira(shouldfork=not is_qira_running) if not is_qira_running: # start the http server qira_webserver.run_server(args, program)