def setup(): mem = MockMemory(fill=23) traps = MockTraps() cpu = MockCPU() alloc = MemoryAlloc(mem) ctx = LibCtx(cpu, mem) return mem, traps, alloc, ctx
def _create_vlib(self, lib_info, fake, lib_cfg=None): # get lib ctx name = lib_info.get_name() ctx = self.ctx_map.get(name, None) # create new context? if not ctx: ctx = LibCtx(self.machine) self.ctx_map[name] = ctx self._add_ctx_extra_attr(ctx) # get impl if fake: impl = None else: name = lib_info.get_name() impl_cls = self.lib_reg.get_lib_impl(name) if impl_cls: impl = impl_cls() # adjust version? if lib_info.version == 0: lib_info.version = impl.get_version() else: return None # create lib vlib = self.creator.create_lib(lib_info, ctx, impl, lib_cfg) # store vlib in context ctx.vlib = vlib return vlib
def setup(): machine = MockMachine(fill=23) mem = machine.get_mem() traps = machine.get_traps() cpu = machine.get_cpu() alloc = MemoryAlloc.for_machine(machine) ctx = LibCtx(machine) return mem, traps, alloc, ctx
def _setup_libcall_proxy(self, name, fd, base_addr, run_sp): type_name = self._get_proxy_type_name(name) # cached proxy? proxy_type = self.proxy_cache.get(type_name, None) if not proxy_type: log_libmgr.info("proxy: create libcall type '%s'", type_name) # no, create it proxy_type = self.proxy_gen.gen_proxy_for_libcall(type_name, fd) self.proxy_cache[type_name] = proxy_type # create instance ctx = LibCtx(self.lib_mgr.machine) log_libmgr.info("proxy: create libcall proxy %s@%08x", type_name, base_addr) return proxy_type(ctx, base_addr, run_sp=run_sp)
def _create_ctx(): machine = MockMachine() return LibCtx(machine)
def _create_ctx(): cpu = MockCPU() mem = MockMemory() return LibCtx(cpu, mem)
def _create_ctx(): machine = MockMachine() # prepare PrintString() machine.mem.w_cstr(0x10, "hello, world!") machine.cpu.w_reg(REG_A0, 0x10) return LibCtx(machine)