__visible int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version) { int i; const char * const plugin_name = plugin_info->base_name; const int argc = plugin_info->argc; const struct plugin_argument * const argv = plugin_info->argv; PASS_INFO(cyc_complexity, "ssa", 1, PASS_POS_INSERT_AFTER); if (!plugin_default_version_check(version, &gcc_version)) { error_gcc_version(version); return 1; } for (i = 0; i < argc; ++i) { if (!strcmp(argv[i].key, "log_file")) { has_log_file = true; continue; } error(G_("unknown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key); } register_callback(plugin_name, PLUGIN_START_UNIT, &cyc_complexity_start_unit, NULL); register_callback (plugin_name, PLUGIN_FINISH_UNIT, &cyc_complexity_finish_unit, NULL); register_callback(plugin_name, PLUGIN_INFO, NULL, &cyc_complexity_plugin_info); register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &cyc_complexity_pass_info); return 0; }
/* module initialization and will be executed automatically when loading. */ void module_init(){ shutdown = malloc(sizeof(shutdown_config_t)); register_callback(max_insn_callback, Step_callback); register_callback(write_shutdown_callback, Bus_write_callback); if(register_option("shutdown_device", do_shutdown_option, "Used to stop machine by writing a special address or set the max executed instruction number.") != No_exp) fprintf(stderr,"Can not register shutdown_device option\n"); }
int plugin_init (struct plugin_name_args* info, struct plugin_gcc_version* ver) { struct register_pass_info pass; int i; if (strcmp (ver->basever, gcc_version.basever) != 0) { printf ("tsan: invalid gcc version (expected/actual: %s/%s)\n", gcc_version.basever, ver->basever); exit(1); } flag_tsan = 1; for (i = 0; i < info->argc; i++) { if (strcmp (info->argv[i].key, "ignore") == 0) flag_tsan_ignore = xstrdup (info->argv[i].value); } pass.pass = &pass_tsan.pass; pass.reference_pass_name = "loop"; pass.ref_pass_instance_number = 1; pass.pos_op = PASS_POS_INSERT_BEFORE; register_callback(info->base_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &pass); register_callback(info->base_name, PLUGIN_ALL_PASSES_END, finish_unit, NULL); return 0; }
int plugin_init (struct plugin_name_args *plugin_info, struct plugin_gcc_version *version) { register_callback ("start_unit", PLUGIN_START_UNIT, &start_unit_callback, NULL); register_callback ("finish_unit", PLUGIN_FINISH_UNIT, &finish_unit_callback, NULL); return 0; }
int plugin_init(struct plugin_name_args *info, struct plugin_gcc_version *ver) { if (strncmp(ver->basever, myplugin_ver.basever, strlen("X.Y"))) { fprintf(stderr, "Your compiler: %s\n", ver->basever); fprintf(stderr, "Sorry, you need to use GCC 4.7.\n"); return -1; } #ifdef DEBUG fprintf(stderr, "Initializing plugin\n"); #endif struct register_pass_info pass; pass.pass = &instrument_assignments_plugin_pass.pass; pass.reference_pass_name = "ssa"; pass.ref_pass_instance_number = 1; pass.pos_op = PASS_POS_INSERT_AFTER; // Tell gcc we want to be called after the first SSA pass register_callback("instrument_plugin", PLUGIN_PASS_MANAGER_SETUP, NULL, &pass); register_callback("instrument_plugin", PLUGIN_INFO, NULL, &instrument_assignments_plugin_info); register_callback("instrument_plugin", PLUGIN_ATTRIBUTES, register_attributes, NULL); return 0; }
void init_substitute_passes(const char* plugin_name) { // Check if j_out has already been created j_tmp = cJSON_GetObjectItem(j_ini, "input_file"); if (j_tmp==NULL) { printf("Alchemist error: input_filename is not defined in ini file\n"); exit(1); } strcpy(alc_input_file, j_tmp->valuestring); j_in=openme_load_json_file(alc_input_file); if (j_in==NULL) { printf("Alchemist error: problem loading input file %s ...\n", alc_input_file); exit(1); } j_in=openme_get_obj(j_in, ALC_PASSES); if (j_in==NULL) { printf("Alchemist error: can't find id '%s' in input file ...\n", ALC_PASSES); exit(1); } register_callback(plugin_name, PLUGIN_ALL_PASSES_START, &substitute_passes, NULL); register_callback(plugin_name, PLUGIN_ALL_PASSES_END, &substitute_passes_end, NULL); register_callback(plugin_name, PLUGIN_PASS_EXECUTION, &view_pass_execution, NULL); }
int plugin_init (struct plugin_name_args *plugin_info, struct plugin_gcc_version *version) { struct plugin_pass pass_info; const char *plugin_name = plugin_info->base_name; int argc = plugin_info->argc; struct plugin_argument *argv = plugin_info->argv; char *ref_pass_name = NULL; int ref_instance_number = 0; int i; /* Process the plugin arguments. This plugin takes the following arguments: ref-pass-name=<PASS_NAME> and ref-pass-instance-num=<NUM>. */ for (i = 0; i < argc; ++i) { if (!strcmp (argv[i].key, "ref-pass-name")) { if (argv[i].value) ref_pass_name = argv[i].value; else warning (0, G_("option '-fplugin-arg-%s-ref-pass-name'" " requires a pass name"), plugin_name); } else if (!strcmp (argv[i].key, "ref-pass-instance-num")) { if (argv[i].value) ref_instance_number = strtol (argv[i].value, NULL, 0); else warning (0, G_("option '-fplugin-arg-%s-ref-pass-instance-num'" " requires an integer value"), plugin_name); } else warning (0, G_("plugin %qs: unrecognized argument %qs ignored"), plugin_name, argv[i].key); } if (!ref_pass_name) { error (G_("plugin %qs requires a reference pass name"), plugin_name); return 1; } pass_info.pass = &pass_dumb_plugin_example.pass; pass_info.reference_pass_name = ref_pass_name; pass_info.ref_pass_instance_number = ref_instance_number; pass_info.pos_op = PASS_POS_INSERT_AFTER; register_callback (plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &pass_info); register_callback (plugin_name, PLUGIN_FINISH_TYPE, handle_struct, NULL); register_callback (plugin_name, PLUGIN_CXX_CP_PRE_GENERICIZE, handle_pre_generic, NULL); register_callback (plugin_name, PLUGIN_FINISH_UNIT, handle_end_of_compilation_unit, NULL); return 0; }
void _modinit(void) { mod_add_cmd(&privmsg_msgtab); mod_add_cmd(¬ice_msgtab); client_message = register_callback("client_message", NULL); channel_message = register_callback("channel_message", NULL); }
/* some initialization for log functionality */ int bus_log_init() { exception_t exp; /* register callback function */ register_callback(log_bus_callback, Bus_read_callback); register_callback(log_bus_callback, Bus_write_callback); /* add corresponding command */ add_command("log-bus", com_log_bus, "record every bus access to log file.\n"); }
__visible int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version) { const char * const plugin_name = plugin_info->base_name; const int argc = plugin_info->argc; const struct plugin_argument *argv = plugin_info->argv; int tso = 0; int i; if (!plugin_default_version_check(version, &gcc_version)) { error(G_("incompatible gcc/plugin versions")); return 1; } for (i = 0; i < argc; ++i) { if (!strcmp(argv[i].key, "disable")) return 0; /* all remaining options require a value */ if (!argv[i].value) { error(G_("no value supplied for option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key); return 1; } if (!strcmp(argv[i].key, "tso")) { tso = atoi(argv[i].value); continue; } if (!strcmp(argv[i].key, "offset")) { canary_offset = atoi(argv[i].value); continue; } error(G_("unknown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key); return 1; } /* create the mask that produces the base of the stack */ sp_mask = ~((1U << (12 + tso)) - 1); PASS_INFO(arm_pertask_ssp_rtl, "expand", 1, PASS_POS_INSERT_AFTER); register_callback(plugin_info->base_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &arm_pertask_ssp_rtl_pass_info); #if BUILDING_GCC_VERSION >= 9000 register_callback(plugin_info->base_name, PLUGIN_START_UNIT, arm_pertask_ssp_start_unit, NULL); #endif return 0; }
int plugin_init (struct plugin_name_args *plugin_info, struct plugin_gcc_version *version) { const char *plugin_name = plugin_info->base_name; register_callback (plugin_name, PLUGIN_PRE_GENERICIZE, handle_pre_generic, NULL); register_callback (plugin_name, PLUGIN_ATTRIBUTES, register_attributes, NULL); return 0; }
static void cov_state_on(char *arg) { if (cov_state == COV_START) { //run this function first time cov_init(prof_start, prof_end); register_callback(cov_readmem_callback, Mem_read_callback); register_callback(cov_writemem_callback, Mem_write_callback); register_callback(cov_execmem_callback, Step_callback); }else printf("code coverage state: on\n"); cov_state = COV_ON; }
int plugin_init (struct plugin_name_args *plugin_info, struct plugin_gcc_version *version) { const char *plugin_name = plugin_info->base_name; register_callback (plugin_name, PLUGIN_START_PARSE_FUNCTION, plugin_start_parse_function, NULL); register_callback (plugin_name, PLUGIN_FINISH_PARSE_FUNCTION, plugin_finish_parse_function, NULL); return 0; }
/* Non auto translated PV domain, ie, it's not PVH. */ static __init void xen_pvmmu_arch_setup(void) { HYPERVISOR_vm_assist(VMASST_CMD_enable, VMASST_TYPE_4gb_segments); HYPERVISOR_vm_assist(VMASST_CMD_enable, VMASST_TYPE_writable_pagetables); HYPERVISOR_vm_assist(VMASST_CMD_enable, VMASST_TYPE_pae_extended_cr3); if (register_callback(CALLBACKTYPE_event, xen_hypervisor_callback) || register_callback(CALLBACKTYPE_failsafe, xen_failsafe_callback)) BUG(); xen_enable_sysenter(); xen_enable_syscall(); }
static int create_register_callback (llist_t **list, /* {{{ */ const char *name, void *callback, user_data_t *ud) { callback_func_t *cf; cf = (callback_func_t *) malloc (sizeof (*cf)); if (cf == NULL) { ERROR ("plugin: create_register_callback: malloc failed."); return (-1); } memset (cf, 0, sizeof (*cf)); cf->cf_callback = callback; if (ud == NULL) { cf->cf_udata.data = NULL; cf->cf_udata.free_func = NULL; } else { cf->cf_udata = *ud; } return (register_callback (list, name, cf)); } /* }}} int create_register_callback */
/** * \brief Load and parse the Lua file of the requested shader. * \param path The path to the lua file, relative to the data folder. */ void Shader::load_lua_file(const std::string& path) { lua_State* l = luaL_newstate(); luaL_openlibs(l); // FIXME don't open the libs size_t size; char* buffer; FileTools::data_file_open_buffer(path, &buffer, &size); int load_result = luaL_loadbuffer(l, buffer, size, path.c_str()); if (load_result != 0) { // Syntax error in the lua file. Debug::die(std::string("Failed to load ") + path + " : " + lua_tostring(l, -1)); } else { // Register the callback and send string parameters to the lua script. register_callback(l); lua_pushstring(l, Video::get_rendering_driver_name().c_str()); lua_pushstring(l, shading_language_version.c_str()); lua_pushstring(l, sampler_type.c_str()); if (lua_pcall(l, 3, 0, 0) != 0) { // Runtime error. Debug::die(std::string("Failed to parse ") + path + " : " + lua_tostring(l, -1)); lua_pop(l, 1); } } FileTools::data_file_close_buffer(buffer); lua_close(l); }
void xen_enable_nmi(void) { #ifdef CONFIG_X86_64 if (register_callback(CALLBACKTYPE_nmi, nmi)) BUG(); #endif }
int plugin_init (struct plugin_name_args *plugin_info, struct plugin_gcc_version *version) { struct register_pass_info pass_info; const char *plugin_name = plugin_info->base_name; int argc = plugin_info->argc; struct plugin_argument *argv = plugin_info->argv; if (!plugin_default_version_check (version, &gcc_version)) return 1; /* For now, tell the dc to expect ranges and thus to colorize the source lines, not just the carets/underlines. This will be redundant once the C frontend generates ranges. */ global_dc->colorize_source_p = true; for (int i = 0; i < argc; i++) { if (0 == strcmp (argv[i].key, "color")) force_show_locus_color = true; } pass_info.pass = make_pass_test_show_locus (g); pass_info.reference_pass_name = "ssa"; pass_info.ref_pass_instance_number = 1; pass_info.pos_op = PASS_POS_INSERT_AFTER; register_callback (plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &pass_info); return 0; }
void ctsSocket::complete_state(DWORD _dwerror) throw() { LONG current_io_count = ::InterlockedCompareExchange(&this->io_count, 0, 0); ctFatalCondition( current_io_count != 0, L"ctsSocket::complete_state is called with outstanding IO (%d)", current_io_count); // // *NOT* taking a ctsSocket lock before calling through io_pattern // - as IOPattern can also initiate calls through ctsSocket, which can then deadlock // DWORD recorded_error = _dwerror; auto ref_io_pattern(this->io_pattern); if (ref_io_pattern) { if ((ctsIOPatternStatusIORunning == this->get_last_error()) && (NO_ERROR == _dwerror)) { recorded_error = ref_io_pattern->verify_io(); } // no longer allow any more callbacks ref_io_pattern->register_callback(nullptr); } // update last_error with those results this->set_last_error(recorded_error); auto ref_parent(this->parent.lock()); if (ref_parent) { auto gle = this->get_last_error(); ref_parent->complete_state(gle); } }
static void register_mein_pass(void) { /* from tree-pass.h */ struct opt_pass opt_pass; struct register_pass_info pass_info; opt_pass.type = GIMPLE_PASS; opt_pass.name = "xkaapi_pass"; opt_pass.gate = NULL; /* execute always */ opt_pass.execute = on_execute_pass; opt_pass.sub = NULL; opt_pass.next = NULL; opt_pass.tv_id = TV_NONE; opt_pass.properties_required = PROP_gimple_any; opt_pass.properties_provided = 0; opt_pass.properties_destroyed = 0; opt_pass.todo_flags_start = 0; opt_pass.todo_flags_finish = TODO_dump_func; /* before the first lowering pass, scope conserved... */ pass_info.pass = &opt_pass; pass_info.reference_pass_name = "early_optimizations"; /* pass_info.reference_pass_name = "ssa"; */ pass_info.ref_pass_instance_number = 1; pass_info.pos_op = PASS_POS_INSERT_BEFORE; register_callback("xkaapi", PLUGIN_PASS_MANAGER_SETUP, NULL, &pass_info); /* or: register_pass(&pass_info); */ }
void init() { WNDCLASS wc; plist_api = (PPLAYLIST_MANAGER)create_api(&g_api, &playlist_manager); pback_api = (PPLAYBACK_CONTROL)create_api(&g_api, &playback_control); ptcomp_api = (PTITLEFORMAT_COMPILER)create_api(&g_api, &titleformat_compiler); pplaycbackman = (PPLAY_CALLBACK_MANAGER)create_api(&g_api, &play_callback_manager); memset(&wc, 0x00, sizeof(wc)); wc.lpfnWndProc = WndProc; wc.hInstance = g_hIns; wc.lpszClassName = FOO_REMOTE_WND_CLASS; if(!RegisterClass(&wc)) { MessageBox(0, "Error registering window class", FOO_REMOTE_WND_CLASS, MB_OK | MB_ICONERROR | MB_TOPMOST); return; } p_hWnd=CreateWindow(FOO_REMOTE_WND_CLASS, 0, 0, 0, 0, 0, 0, 0, 0, g_hIns, 0); if(!p_hWnd) { MessageBox(0, "Error creating window", FOO_REMOTE_WND_CLASS, MB_OK | MB_ICONERROR | MB_TOPMOST); return; } register_callback(&pplaycbackman, &pplay_callback, flag_on_playback_all, FALSE); SetTimer(p_hWnd, CLEAR_CALLBACK_TIMER, 5*60*1000, ClearCallback); SendMessage(FindWindow("bbFooman", 0), WM_FOO_ACTIVATE, 0, 0); // used only for bbFooman plugin for blackbox }
int main(int argc, char *argv[]) { register_callback(my_callback, "hello world"); register_callback_pre(my_callback_pre, "hello world"); register_callback_post(my_callback_post, "hello world"); return 0; }
int plugin_init (struct plugin_name_args *plugin_info, struct plugin_gcc_version *version) { // default trace_call_type = PRINTF; if (plugin_info->argc > 0) { int i; for (i = 0; i < plugin_info->argc; i++) { if (strcmp(plugin_info->argv[i].key, "calltype") == 0) { if (strcmp(plugin_info->argv[i].value, "callback") == 0) trace_call_type = CALLBACK; } if (strcmp(plugin_info->argv[i].key, "tracefile") == 0) { read_trace_file(plugin_info->argv[i].value); } } } printf("\nAnalyzing branches..\n"); // Note: PLUGIN_PRE_GENERICIZE has more options for traversing modifying // and will call handle_pre_generic for each function register_callback (plugin_info->base_name, PLUGIN_PRE_GENERICIZE, &handle_pre_generic, NULL); return 0; }
static int __cpuinit register_callback(unsigned type, const void *func) { struct callback_register callback = { .type = type, .address = XEN_CALLBACK(__KERNEL_CS, func), .flags = CALLBACKF_mask_events, }; return HYPERVISOR_callback_op(CALLBACKOP_register, &callback); } void __cpuinit xen_enable_sysenter(void) { int ret; unsigned sysenter_feature; #ifdef CONFIG_X86_32 sysenter_feature = X86_FEATURE_SEP; #else sysenter_feature = X86_FEATURE_SYSENTER32; #endif if (!boot_cpu_has(sysenter_feature)) return; ret = register_callback(CALLBACKTYPE_sysenter, xen_sysenter_target); if(ret != 0) setup_clear_cpu_cap(sysenter_feature); }
int plugin_init (struct plugin_name_args *plugin_info, struct plugin_gcc_version *version) { struct register_pass_info pass_info; const char *plugin_name = plugin_info->base_name; int argc = plugin_info->argc; struct plugin_argument *argv = plugin_info->argv; if (!plugin_default_version_check (version, &gcc_version)) return 1; diagnostic_starter (global_dc) = test_diagnostic_starter; global_dc->start_span = test_diagnostic_start_span_fn; global_dc->begin_group_cb = test_begin_group_cb; global_dc->end_group_cb = test_end_group_cb; pass_info.pass = new pass_test_groups (g); pass_info.reference_pass_name = "*warn_function_noreturn"; pass_info.ref_pass_instance_number = 1; pass_info.pos_op = PASS_POS_INSERT_AFTER; register_callback (plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &pass_info); return 0; }
int plugin_init (struct plugin_name_args *plugin_info, struct plugin_gcc_version *version) { struct register_pass_info pass_info; const char *plugin_name = plugin_info->base_name; int argc = plugin_info->argc; struct plugin_argument *argv = plugin_info->argv; if (!plugin_default_version_check (version, &gcc_version)) return 1; for (int i = 0; i < argc; i++) { if (0 == strcmp (argv[i].key, "color")) force_show_locus_color = true; } pass_info.pass = make_pass_test_show_locus (g); pass_info.reference_pass_name = "ssa"; pass_info.ref_pass_instance_number = 1; pass_info.pos_op = PASS_POS_INSERT_AFTER; register_callback (plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &pass_info); return 0; }
int main(int argc, char *argv[]) { char p[] = "hello world"; register_callback(my_callback, p); register_callback_pre(my_callback_pre, p); register_callback_post(my_callback_post, p); return 0; }
int init_bp(){ exception_t exp; register_callback(check_breakpoint, Step_callback); add_command("break", com_break, "set breakpoint for an address.\n"); add_command("list-bp", com_list_bp, "List all the breakpoint.\n"); add_command("delete-bp", com_delete_bp, "List all the breakpoint.\n"); //register_info_command("breakpoint", com_list_bp, "List all the breakpoint.\n"); }
void init_test(ompt_function_lookup_t lookup) { if (!register_callback(ompt_event_runtime_shutdown, (ompt_callback_t) on_ompt_event_runtime_shutdown)) { CHECK(FALSE, FATAL, "failed to register ompt_event_runtime_shutdown"); } }
void ouroboros_server::handle_callback_rest(const rest_request& aRequest) { //get reference to named thing std::string resource = normalize_group(aRequest.getGroups()) + '/' + aRequest.getFields(); var_field *named = mStore.get(normalize_group(aRequest.getGroups()), aRequest.getFields()); std::string response; mg_connection *conn = aRequest.getConnection(); if (named) { switch (aRequest.getHttpRequestType()) { case POST: { std::string data(conn->content, conn->content_len); JSON json(data); std::string response_url = json.get("callback"); //create callback //Due to a limitation of C++03, use a semi-global map //to track response URLs mResponseUrls[named] = response_url; std::string callback_id = register_callback(aRequest.getGroups(), aRequest.getFields(), establish_connection); std::stringstream ss; ss << "{ \"id\" : \"" << callback_id << "\" }"; mg_send_status(conn, 201); response = ss.str(); } break; //TODO DELETE is not supported by the underlying mechanism /*case DELETE: { //Send JSON describing named item std::string data(conn->content, conn->content_len); JSON json(data); std::string id = json.get("id"); unregister_callback(id); response = detail::good_JSON(); }*/ break; default: response = detail::bad_JSON(conn); } } else { response = detail::bad_JSON(conn); } mg_send_data(conn, response.c_str(), response.length()); }