int main(int argc, const char **argv) { // liang: setup signal handler for checkpointing int rc; struct sigaction sig_int_action; sig_int_action.sa_handler = checkpoint_signal_handler; sigemptyset(&sig_int_action.sa_mask); sig_int_action.sa_flags = 0; rc = sigaction(checkpoint_signal, &sig_int_action, NULL); assert(rc==0); // get MmapOverride installed before we need memory! MmapOverride mmapOverride; fprintf(stderr, "Parsing args.\n"); MonitorArgs args(argc, (char**) argv); fprintf(stderr, "Done parsing args.\n"); if (args.wait_for_debugger) { fprintf(stderr, "monitor starts; waiting for debugger.\n"); } while (args.wait_for_debugger) { sleep(1); } MallocFactory *mf = standard_malloc_factory_init(); malloc_factory_operator_new_init(mf); ambient_malloc_init(mf); // liang: resume process if (args.is_resume) { // zvm = new ZoogVM(mf, &mmapOverride, &args, args.wait_for_core, args.swap_file); zvm = new ZoogVM(mf, &mmapOverride, &args); zvm->resume(); } else { zvm = new ZoogVM(mf, &mmapOverride, &args); if (args.assign_in_address) { assign_address(zvm, args.assign_in_address); } zvm->set_swapfile(args.swap_file); load_elf_pal(zvm, (char*) ZOOG_ROOT "/monitors/linux_kvm/pal/build/zoog_kvm_pal"); load_app(zvm, args.image_file); if (args.delete_image_file) { rc = unlink(args.image_file); assert(rc==0); } zvm->start(); } }
void sal_op_set_route(SalOp *op, const char *route){ char* route_string=(void *)0; SalOpBase* op_base = (SalOpBase*)op; if (op_base->route_addresses) { ms_list_for_each(op_base->route_addresses,(void (*)(void *))sal_address_destroy); op_base->route_addresses=ms_list_free(op_base->route_addresses); } if (route) { op_base->route_addresses=ms_list_append(NULL,NULL); assign_address((SalAddress**)&(op_base->route_addresses->data),route); route_string=sal_address_as_string((SalAddress*)op_base->route_addresses->data); \ } assign_string(&op_base->route,route_string); \ if(route_string) ms_free(route_string); }
void Evaluator::set_address() { Cell addr(0, 0); Nodes & instructions = root->children; for (auto i : instructions) { Instruction * pi = get<Instruction>(LNFUN, i); bool curl = false; Cell save_addr; if (pi->typ == Instruction::eCurl) try { curl = true; save_addr = addr; addr = root->comp->proc.x2ts(root->comp->random()); } catch (const char * e) { throw Err(e, pi->tok()); } Nodes & lis = i->children; for (auto l : lis ) { Litem * pl = get<Litem>(LNFUN, l); try { assign_address(pl, addr); next_address(addr); } catch (string e) { throw Err(e, pl->tok()); } // finished with Litem - safe to remove labels pl->children.pop_back(); } // next litem // finished instruction, resore addr if curl if (curl) addr = save_addr; } // next instruction }
void __sal_op_set_remote_contact(SalOp *op, const char* remote_contact){ assign_address(&((SalOpBase*)op)->remote_contact_address,remote_contact);\ /*to preserve header params*/ assign_string(&((SalOpBase*)op)->remote_contact,remote_contact); \ }