Exemplo n.º 1
0
ErrorStack EnginePimpl::uninitialize_once() {
  LOG(INFO) << "================================================================================";
  LOG(INFO) << "=================== FOEDUS ENGINE ("
    << describe_short() << ") EXITTING...... ================";
  LOG(INFO) << "================================================================================";
  if (is_master() && soc_manager_.is_initialized()) {
    soc_manager_.get_shared_memory_repo()->change_master_status(
      soc::MasterEngineStatus::kWaitingForChildTerminate);
  }
  ErrorStackBatch batch;
  // uninit in reverse order of initialization
  auto modules = get_modules();
  std::reverse(modules.begin(), modules.end());
  for (ModulePtr& module : modules) {
    if (!module.ptr_->is_initialized()) {
      continue;
    }
    // During uninitialization, master waits for SOCs' uninitialization before its uninit.
    if (is_master()) {
      batch.emprace_back(soc_manager_.wait_for_children_module(false, module.type_));
    }
    batch.emprace_back(module.ptr_->uninitialize());
    on_module_uninitialized(module.type_);
    // Then SOCs wait for master before moving on to next module.
    if (!is_master()) {
      batch.emprace_back(soc_manager_.wait_for_master_module(false, module.type_));
    }
  }

  // SOC manager is special. We must uninitialize it at last.
  batch.emprace_back(soc_manager_.uninitialize());
  // after that, we can't even set status. shared memory has been detached.
  return SUMMARIZE_ERROR_BATCH(batch);
}
Exemplo n.º 2
0
void websockets_binding_open(node *state)
{
  node *modules = get_modules(state);
  node *block_class = get_block_class(state);
  node *websockets = websockets_bind(modules);
  node *proxy = create_proxy_object(state,websockets,"websockets");
  inc_obj_refcount(websockets);
  add_member(block_class,proxy);
  inc_obj_refcount(proxy);
  sys_add_module(state,"websockets");
}
Exemplo n.º 3
0
void curl_binding_open(node *state)
{
  node *modules = get_modules(state);
  node *block_class = get_block_class(state);
  node *curl = curl_bind(modules);
  node *proxy = create_proxy_object(state,curl,"curl");
  inc_obj_refcount(curl);
  add_member(block_class,proxy);
  inc_obj_refcount(proxy);
  sys_add_module(state,"curl");
}
Exemplo n.º 4
0
/* Initialize context->hostrealm_handles with a list of module handles. */
static krb5_error_code
load_hostrealm_modules(krb5_context context)
{
    krb5_error_code ret;
    struct hostrealm_module_handle **list = NULL, *handle;
    krb5_plugin_initvt_fn *modules = NULL, *mod;
    size_t count;

    ret = get_modules(context, &modules);
    if (ret != 0)
        goto cleanup;

    /* Allocate a large enough list of handles. */
    for (count = 0; modules[count] != NULL; count++);
    list = k5alloc((count + 1) * sizeof(*list), &ret);
    if (list == NULL)
        goto cleanup;

    /* Initialize each module, ignoring ones that fail. */
    count = 0;
    for (mod = modules; *mod != NULL; mod++) {
        handle = k5alloc(sizeof(*handle), &ret);
        if (handle == NULL)
            goto cleanup;
        ret = (*mod)(context, 1, 1, (krb5_plugin_vtable)&handle->vt);
        if (ret != 0) {
            TRACE_HOSTREALM_VTINIT_FAIL(context, ret);
            free(handle);
            continue;
        }

        handle->data = NULL;
        if (handle->vt.init != NULL) {
            ret = handle->vt.init(context, &handle->data);
            if (ret != 0) {
                TRACE_HOSTREALM_INIT_FAIL(context, handle->vt.name, ret);
                free(handle);
                continue;
            }
        }
        list[count++] = handle;
        list[count] = NULL;
    }
    list[count] = NULL;

    ret = 0;
    context->hostrealm_handles = list;
    list = NULL;

cleanup:
    k5_plugin_free_modules(context, modules);
    free_handles(context, list);
    return ret;
}
Exemplo n.º 5
0
void file_binding_open(node *state)
{
  node *modules = get_modules(state);
  node *base_class = get_base_class(state);
  node *block_class = get_block_class(state);
  node *file = file_bind(base_class,modules);
  node *proxy = create_proxy_object(state,file,"file");
  inc_obj_refcount(file);
  add_member(block_class,proxy);
  inc_obj_refcount(proxy);
  sys_add_module(state,"file");
}
Exemplo n.º 6
0
int before_block_exec(CPUState *env, TranslationBlock *tb) {
    int i;

    OsiProc *current = get_current_process(env);
    printf("Current process: %s PID:" TARGET_FMT_ld " PPID:" TARGET_FMT_ld "\n", current->name, current->pid, current->ppid);

    OsiModules *ms = get_libraries(env, current);
    if (ms == NULL) {
        printf("No mapped dynamic libraries.\n");
    }
    else {
        printf("Dynamic libraries list (%d libs):\n", ms->num);
        for (i = 0; i < ms->num; i++)
            printf("\t0x" TARGET_FMT_lx "\t" TARGET_FMT_ld "\t%-24s %s\n", ms->module[i].base, ms->module[i].size, ms->module[i].name, ms->module[i].file);
    }

    printf("\n");

    OsiProcs *ps = get_processes(env);
    if (ps == NULL) {
        printf("Process list not available.\n");
    }
    else {
        printf("Process list (%d procs):\n", ps->num);
        for (i = 0; i < ps->num; i++)
            printf("  %-16s\t" TARGET_FMT_ld "\t" TARGET_FMT_ld "\n", ps->proc[i].name, ps->proc[i].pid, ps->proc[i].ppid);
    }

    printf("\n");

    OsiModules *kms = get_modules(env);
    if (kms == NULL) {
        printf("No mapped kernel modules.\n");
    }
    else {
        printf("Kernel module list (%d modules):\n", kms->num);
        for (i = 0; i < kms->num; i++)
            printf("\t0x" TARGET_FMT_lx "\t" TARGET_FMT_ld "\t%-24s %s\n", kms->module[i].base, kms->module[i].size, kms->module[i].name, kms->module[i].file);
    }

    printf("\n-------------------------------------------------\n\n");

    // Cleanup
    free_osiproc(current);
    free_osiprocs(ps);
    free_osimodules(ms);

    return 0;
}
Exemplo n.º 7
0
ErrorStack EnginePimpl::initialize_modules() {
  ASSERT_ND(soc_manager_.is_initialized());
  for (ModulePtr& module : get_modules()) {
    // During initialization, SOCs wait for master's initialization before their init.
    if (!is_master()) {
      CHECK_ERROR(soc_manager_.wait_for_master_module(true, module.type_));
    }
    CHECK_ERROR(module.ptr_->initialize());
    on_module_initialized(module.type_);
    // Then master waits for SOCs before moving on to next module.
    if (is_master()) {
      CHECK_ERROR(soc_manager_.wait_for_children_module(true, module.type_));
    }
  }
  return kRetOk;
}
Exemplo n.º 8
0
static void	init_core(t_core *core, struct termios *term)
{
  core->shutdown = 0;
  core->term = term;
  core->is_tcaps = TRUE;
  core->cut_tab = NULL;
  core->packet = NULL;
  core->name_term = NULL;
  core->jump = FALSE;
  core->err_open = NO_ERR;
  core->buf_caps = NULL;
  core->jobs = NULL;
  core->prompt = NULL;
  core->mods = get_modules();
  if (signal(SIGINT, SIG_IGN) == SIG_ERR)
    my_puterr(ERR_SIGNAL);
  if (signal(SIGTTOU, SIG_IGN) == SIG_ERR)
    my_puterr(ERR_SIGNAL);
}
Exemplo n.º 9
0
int main(int argc, char *argv[])
{
	DWORD dwPid = 7668;//GetCurrentProcessId();
	HANDLE hProcess = OpenProcess(PROCESS_ALL_ACCESS, FALSE, dwPid);
	 
	for (auto region : get_regions(hProcess))
		print_range((ULONG_PTR)region.BaseAddress, (ULONG_PTR)region.BaseAddress + region.RegionSize); 

	printf("\nDLLs:\n"); 

	for (auto module : get_modules(hProcess))
		print_range((ULONG_PTR)module.lpBaseOfDll, (ULONG_PTR)module.lpBaseOfDll + (ULONG_PTR)module.lpBaseOfDll);

	printf("\nThreads:\n");
	for (auto thread : get_threads(dwPid))
		print_range((ULONG_PTR)thread.Eip, (ULONG_PTR)thread.Esp);

	getchar();
	return 0;
}
Exemplo n.º 10
0
Arquivo: modfs.c Projeto: jgraef/aNXT
int main(int argc,char *argv[]) {
  int ret = 0;
  struct fuse_args args = FUSE_ARGS_INIT(argc,argv);
  memset(&options,0,sizeof(struct options));
  if (fuse_opt_parse(&args,&options,nxtfs_opts,NULL)==-1) return 1;

  nxt = nxt_open(options.name);
  if (nxt!=NULL) {
    get_modules();
#ifdef FUSE_VERSION_2_5
    ret = fuse_main(args.argc,args.argv,&nxtfs_oper);
#else
    ret = fuse_main(args.argc,args.argv,&nxtfs_oper,NULL);
#endif
    nxt_close(nxt);
  }
  else ret = 1;

  fuse_opt_free_args(&args);
  return ret;
}
Exemplo n.º 11
0
bool cbmc_parseoptionst::get_goto_program(
  const optionst &options,
  bmct &bmc,
  goto_functionst &goto_functions)
{
  if(cmdline.args.size()==0)
  {
    error("Please provide a program to verify");
    return true;
  }

  try
  {
    if(cmdline.args.size()==1 &&
       is_goto_binary(cmdline.args[0]))
    {
      status("Reading GOTO program from file");

      if(read_goto_binary(cmdline.args[0],
           context, goto_functions, get_message_handler()))
        return true;
        
      config.ansi_c.set_from_context(context);

      if(cmdline.isset("show-symbol-table"))
      {
        show_symbol_table();
        return true;
      }
      
      if(context.symbols.find(ID_main)==context.symbols.end())
      {
        error("The goto binary has no entry point; please complete linking");
        return true;
      }
    }
    else
    {
      if(parse()) return true;
      if(typecheck()) return true;
      if(get_modules(bmc)) return true;    
      if(final()) return true;

      // we no longer need any parse trees or language files
      clear_parse();

      if(cmdline.isset("show-symbol-table"))
      {
        show_symbol_table();
        return true;
      }

      if(context.symbols.find(ID_main)==context.symbols.end())
      {
        error("No entry point; please provide a main function");
        return true;
      }

      status("Generating GOTO Program");

      goto_convert(
        context, options, goto_functions,
        ui_message_handler);
    }

    // finally add the library
    status("Adding CPROVER library");      
    link_to_library(
      context, goto_functions, options, ui_message_handler);

    if(process_goto_program(options, goto_functions))
      return true;
  }

  catch(const char *e)
  {
    error(e);
    return true;
  }

  catch(const std::string e)
  {
    error(e);
    return true;
  }
  
  catch(int)
  {
    return true;
  }
  
  catch(std::bad_alloc)
  {
    error("Out of memory");
    return true;
  }
  
  return false;
}
Exemplo n.º 12
0
int cbmc_parse_optionst::get_goto_program(
  const optionst &options,
  bmct &bmc, // for get_modules
  goto_functionst &goto_functions)
{
  if(cmdline.args.empty())
  {
    error() << "Please provide a program to verify" << eom;
    return 6;
  }

  try
  {
    if(cmdline.isset("show-parse-tree"))
    {
      if(cmdline.args.size()!=1 ||
         is_goto_binary(cmdline.args[0]))
      {
        error() << "Please give exactly one source file" << eom;
        return 6;
      }
      
      std::string filename=cmdline.args[0];
      
      #ifdef _MSC_VER
      std::ifstream infile(widen(filename).c_str());
      #else
      std::ifstream infile(filename.c_str());
      #endif
                
      if(!infile)
      {
        error() << "failed to open input file `" << filename << "'" << eom;
        return 6;
      }
                              
      languaget *language=get_language_from_filename(filename);
      
      if(language==NULL)
      {
        error() << "failed to figure out type of file `" <<  filename << "'" << eom;
        return 6;
      }
      
      language->set_message_handler(get_message_handler());
                                                                
      status("Parsing", filename);
  
      if(language->parse(infile, filename))
      {
        error() << "PARSING ERROR" << eom;
        return 6;
      }
      
      language->show_parse(std::cout);
      return 0;
    }

    cmdlinet::argst binaries;
    binaries.reserve(cmdline.args.size());

    for(cmdlinet::argst::iterator
        it=cmdline.args.begin();
        it!=cmdline.args.end();
        ) // no ++it
    {
      if(is_goto_binary(*it))
      {
        binaries.push_back(*it);
        it=cmdline.args.erase(it);
        continue;
      }

      ++it;
    }

    if(!cmdline.args.empty())
    {
      if(parse()) return 6;
      if(typecheck()) return 6;
      int get_modules_ret=get_modules(bmc);
      if(get_modules_ret!=-1) return get_modules_ret;
      if(binaries.empty() && final()) return 6;

      // we no longer need any parse trees or language files
      clear_parse();
    }

    for(cmdlinet::argst::const_iterator
        it=binaries.begin();
        it!=binaries.end();
        ++it)
    {
      status() << "Reading GOTO program from file " << eom;

      if(read_object_and_link(*it, symbol_table, goto_functions, *this))
        return 6;
    }

    if(!binaries.empty())
      config.set_from_symbol_table(symbol_table);

    if(cmdline.isset("show-symbol-table"))
    {
      show_symbol_table();
      return 0;
    }

    if(entry_point(symbol_table, "main", get_message_handler()))
      return 6;

    status() << "Generating GOTO Program" << eom;

    goto_convert(symbol_table, goto_functions, ui_message_handler);

    if(process_goto_program(options, goto_functions))
      return 6;
  }

  catch(const char *e)
  {
    error() << e << eom;
    return 6;
  }

  catch(const std::string e)
  {
    error() << e << eom;
    return 6;
  }
  
  catch(int)
  {
    return 6;
  }
  
  catch(std::bad_alloc)
  {
    error() << "Out of memory" << eom;
    return 6;
  }
  
  return -1; // no error, continue
}