CComPtr<IRegistrationInfo> new_filter_obj::get_reginfo() { if (reginfo) return reginfo; if (!SUCCEEDED(get_def()->get_RegistrationInfo(®info))) throw nscp_exception("Failed to get IRegistrationInfo: " + error::com::get()); return reginfo; }
CComPtr<ITaskSettings> new_filter_obj::get_settings() { if (settings) return settings; if (!SUCCEEDED(get_def()->get_Settings(&settings))) throw nscp_exception("Failed to get ITaskSettings: " + error::com::get()); return settings; }
// //START PRDF // void PRDF::dump() { if (g_tfile == NULL) { return; } fprintf(g_tfile, "\n==---- DUMP PRDF : liveness of PR ----==\n"); List<IRBB*> * bbl = m_ru->get_bb_list(); g_indent = 2; for (IRBB * bb = bbl->get_head(); bb != NULL; bb = bbl->get_next()) { fprintf(g_tfile, "\n\n\n-- BB%d --", BB_id(bb)); DefSBitSetCore * live_in = get_livein(BB_id(bb)); DefSBitSetCore * live_out = get_liveout(BB_id(bb)); DefSBitSetCore * def = get_def(BB_id(bb)); DefSBitSetCore * use = get_use(BB_id(bb)); fprintf(g_tfile, "\nLIVE-IN: "); live_in->dump(g_tfile); fprintf(g_tfile, "\nLIVE-OUT: "); live_out->dump(g_tfile); fprintf(g_tfile, "\nDEF: "); def->dump(g_tfile); fprintf(g_tfile, "\nUSE: "); use->dump(g_tfile); } fflush(g_tfile); }
static int aoi_name(definition *def, char *name, int errs) { /* * This will find the node named 'name' and will return a reference * to it. This is not necessarily the best code, but it works fine. */ int i; int min_scope = curr_scope; for (i = outaoi.defs.defs_len - 1; i >= 0; i--) { /* Look in all scopes from this point, and above... */ if (outaoi.defs.defs_val[i].scope <= min_scope) { min_scope = outaoi.defs.defs_val[i].scope; if (!strcmp(outaoi.defs.defs_val[i].name, name)) { if (errs == MUST_CREATE) return -1; else return i; } } } /* Not already defined. */ if (errs == NO_CREATE) return -1; i = get_def(); outaoi.defs.defs_val[i].name = name; outaoi.defs.defs_val[i].binding = 0; outaoi.defs.defs_val[i].scope = curr_scope; outaoi.defs.defs_val[i].idl_file = def->idl_file; return i; }
/* * PSEUDO CODE: * * EXTRACT INFO FROM XML NODE * RETRIEVE PROBE DEFINITION RECORD FROM DATABASE * RETRIEVE PRECEDING RAW RECORD FROM DATABASE * STORE RAW RESULTS * IF THIS IS THE FIRST RESULT EVER FOR THIS PROBE * CREATE PR_STATUS RECORD * ELSE * IF WE HAVEN'T PROCESSED THIS RECORD BEFORE * IF COLOR DIFFERS FROM PRECEDING RAW RECORD * CREATE PR_HIST * RETRIEVE FOLLOWING RAW RECORD * IF FOUND AND COLOR OF FOLLOWING IS THE SAME AS CURRENT * DELETE POSSIBLE HISTORY RECORDS FOR FOLLOWING RECORD * ENDIF * IF THIS RAW RECORD IS THE MOST RECENT EVER RECEIVED * WRITE NEW RECENT TIME INTO PROBE DEFINITION RECORD * UPDATE PR_STATUS * UPDATE SERVER COLOR * ENDIF * ELSE * IF THIS RAW RECORD IS THE MOST RECENT EVER RECEIVED * WRITE NEW RECENT TIME INTO PROBE DEFINITION RECORD * ENDIF * ENDIF * IF CURRENT RAW RECORD IS THE MOST RECENT * FOR EACH PERIOD * IF WE ENTERED A NEW SLOT * SUMMARIZE PREVIOUS SLOT * ENDIF * ENDFOR * ELSE * FOR EACH PERIOD * IF THE LAST RECORD FOR THIS SLOT HAS BEEN SEEN * RE-SUMMARIZE CURRENT SLOT * ENDIF * ENDFOR * ENDIF * ENDIF * ENDIF * * returns: * 1 in case of success * 0 in case of database failure where trying again later might help * -1 in case of malformed input, never try again * -2 in case of a fatal error, just skip this batch */ int process(trx *t) { int must_update_def=0; struct probe_result *prv=NULL; int err = 1; /* default ok */ if (!realm_exists(t->res->realm)) { return -1; } if (t->res->realm && t->res->realm[0]) { t->probe->db = open_realm(t->res->realm); } else { if (t->probe->find_realm) { t->probe->find_realm(t); } else { t->probe->db = open_realm(NULL); } } if (!t->probe->db) return -2; if (t->probe->resultcount % 400 == 0) { update_last_seen(t->probe); } if (debug > 3) fprintf(stderr, "accept_result\n"); if (t->probe->accept_result) { t->probe->accept_result(t); // do some final calculations on the result } if (debug > 3) fprintf(stderr, "get_def\n"); if (t->probe->get_def) { if (debug > 3) fprintf(stderr, "RETRIEVE PROBE DEFINITION RECORD FROM DATABASE\n"); t->def = t->probe->get_def(t, trust(t->res->name)); // RETRIEVE PROBE DEFINITION RECORD FROM DATABASE } else { t->def = get_def(t, trust(t->res->name)); } if (!t->def) { // Oops, def record not found. Skip this probe if (debug > 3) fprintf(stderr, "def NOT found\n"); err = -1; /* malformed input FIXME should make distinction between db errors and def not found */ goto exit_with_res; } if (t->probe->adjust_result) { t->probe->adjust_result(t); } if (debug > 3) fprintf(stderr, "STORE RAW RESULTS\n"); if (t->probe->store_results) { int ret = t->probe->store_results(t); // STORE RAW RESULTS if (!ret) { /* error return? */ if (debug > 3) fprintf(stderr, "error in store_results\n"); err = -2; /* database fatal error - try again later */ goto exit_with_res; } } else { t->seen_before = FALSE; } if (t->res->stattime > t->def->newest) { // IF CURRENT RAW RECORD IS THE MOST RECENT if (debug > 3) fprintf(stderr, "CURRENT RAW RECORD IS THE MOST RECENT\n"); prv = g_malloc0(sizeof(struct probe_result)); prv->color = t->def->color; // USE PREVIOUS COLOR FROM DEF RECORD prv->stattime = t->def->newest; } else { if (debug > 3) fprintf(stderr, "RETRIEVE PRECEDING RAW RECORD FROM DATABASE\n"); prv = get_previous_record(t); // RETRIEVE PRECEDING RAW RECORD FROM DATABASE } set_result_prev_color(t, prv); // indicate previous color in result set if (t->def->email[0]) { // and if email address given, add simple notification record xmlNodePtr notify; notify = xmlNewChild(t->cur, NULL, "notify", NULL); xmlSetProp(notify, "proto", "smtp"); xmlSetProp(notify, "target", t->def->email); } if (t->def->newest == 0) { // IF THIS IS THE FIRST RESULT EVER FOR THIS PROBE if (debug > 3) fprintf(stderr, "THIS IS THE FIRST RESULT EVER FOR THIS PROBE\n"); insert_pr_status(t); must_update_def = TRUE; goto finish; } if (t->seen_before) { goto finish; } // Extra debugging, be sure what colors are processed here if ( debug > 3 ) fprintf(stderr, "PREVIOUS COLOR %d - NEW COLOR %d\n", prv->color, t->res->color); // IF COLOR DIFFERS FROM PRECEDING RAW RECORD if (t->res->color != prv->color) { struct probe_result *nxt; if (t->probe->fuse) { if (t->res->color > prv->color || prv->color == STAT_PURPLE) { if (debug > 3) fprintf(stderr, "FUSE WITH HIGHER COLOR - CREATE PR_HIST\n"); create_pr_hist(t, prv); // CREATE PR_HIST } } else { if (debug > 3) fprintf(stderr, "COLOR DIFFERS FROM PRECEDING RAW RECORD - CREATE PR_HIST\n"); create_pr_hist(t, prv); // CREATE PR_HIST } if (t->res->stattime > t->def->newest) { // IF THIS RAW RECORD IS THE MOST RECENT EVER RECEIVED dbi_result result; if (debug > 3) fprintf(stderr, "THIS RAW RECORD IS THE MOST RECENT EVER RECEIVED - UPDATE PR_STATUS\n"); result = update_pr_status(t, prv); // UPDATE PR_STATUS if (dbi_result_get_numrows_affected(result) == 0) { // nothing was actually updated, need to insert new insert_pr_status(t); } dbi_result_free(result); if (debug > 3) fprintf(stderr, "UPDATE SERVER COLOR\n"); update_server_color(t, prv); // UPDATE SERVER COLOR must_update_def = TRUE; } else { if (debug > 3) fprintf(stderr, "RETRIEVE FOLLOWING RAW RECORD\n"); nxt = get_following_record(t); // RETRIEVE FOLLOWING RAW RECORD if (nxt && nxt->color) { // IF FOUND if (debug > 3) fprintf(stderr, "FOLLOWING RECORD IS FOUND\n"); if (nxt->color == t->res->color) { // IF COLOR OF FOLLOWING IS THE SAME AS CURRENT if (debug > 3) fprintf(stderr, "SAME COLOR: DELETE POSSIBLE HISTORY RECORDS\n"); delete_history(t, nxt); // DELETE POSSIBLE HISTORY RECORDS FOR FOLLOWING RECORD } g_free(nxt); } } } else { if (debug > 3) fprintf(stderr, "COLOR SAME AS PRECEDING RAW RECORD\n"); if (t->res->stattime > t->def->newest) { // IF THIS RAW RECORD IS THE MOST RECENT EVER RECEIVED dbi_result result; if (debug > 3) fprintf(stderr, "THIS RAW RECORD IS THE MOST RECENT EVER RECEIVED - UPDATE PR_STATUS\n"); result = update_pr_status(t, prv); // UPDATE PR_STATUS (not for the color, but for the expiry time) if (dbi_result_get_numrows_affected(result) == 0) { // nothing was actually updated, need to insert new insert_pr_status(t); } dbi_result_free(result); must_update_def = TRUE; } } if (t->def->email[0] || t->def->sms[0]) { // if we have an address // RETRIEVE LAST HIST ENTRY FOR THIS PROBE get_previous_pr_hist(t); // notify if needed if (strcmp(t->res->notified, "yes")) { // not already notified if (notify(t)) { set_pr_hist_notified(t); } } } if (t->probe->summarize && t->res->color != STAT_PURPLE) { if (t->res->stattime > t->def->newest) { // IF CURRENT RAW RECORD IS THE MOST RECENT guint cur_slot, prev_slot; gulong slotlow, slothigh; gulong dummy_low, dummy_high; gint i; if (debug > 3) fprintf(stderr, "SUMMARIZING. CURRENT RAW RECORD IS THE MOST RECENT\n"); for (i=0; summ_info[i].period != -1; i++) { // FOR EACH PERIOD prev_slot = uw_slot(summ_info[i].period, prv->stattime, &slotlow, &slothigh); cur_slot = uw_slot(summ_info[i].period, t->res->stattime, &dummy_low, &dummy_high); if (cur_slot != prev_slot) { // IF WE ENTERED A NEW SLOT, SUMMARIZE PREVIOUS SLOT if (debug > 3) fprintf(stderr, "cur(%u for %u) != prv(%u for %u), summarizing %s from %lu to %lu", cur_slot, t->res->stattime, prev_slot, prv->stattime, summ_info[i].from, slotlow, slothigh); t->probe->summarize(t, summ_info[i].from, summ_info[i].to, cur_slot, slotlow, slothigh, 0); } } } else { guint cur_slot; gulong slotlow, slothigh; gulong not_later_then = UINT_MAX; gint i; if (debug > 3) { fprintf(stderr, "SUMMARIZING. CURRENT RAW RECORD IS AN OLD ONE\n"); LOG(LOG_DEBUG, "stattime = %u, newest = %u for %s %u", t->res->stattime, t->def->newest, t->res->name, t->def->probeid); } for (i=0; summ_info[i].period != -1; i++) { // FOR EACH PERIOD cur_slot = uw_slot(summ_info[i].period, t->res->stattime, &slotlow, &slothigh); if (slothigh > not_later_then) continue; // we already know there are none later then this // IF THIS SLOT IS COMPLETE if (slot_is_complete(t, i, slotlow, slothigh)) { // RE-SUMMARIZE CURRENT SLOT if (debug > 3) fprintf(stderr, "SLOT IS COMPLETE - RE-SUMMARIZE CURRENT SLOT\n"); t->probe->summarize(t, summ_info[i].from, summ_info[i].to, cur_slot, slotlow, slothigh, 0); } else { not_later_then = slothigh; } } } } finish: if (must_update_def) { t->def->newest = t->res->stattime; t->def->color = t->res->color; } g_free(prv); exit_with_res: if (t->probe->end_result) { t->probe->end_result(t); } // free the result block if (t->res) { if (t->probe->free_res) { t->probe->free_res(t->res); // the probe specific part... } free_res(t->res); // .. and the generic part } // note we don't free the *t->def here, because that structure is owned by the hashtable // except if the module does not use caching, we try to free it ourselves if (!t->probe->needs_cache) { if (t->probe->free_def) { t->probe->free_def(t->def); } else { free(t->def); } } return err; }
void PRDF::computeLocal(IRBB * bb, List<IR const*> & lst) { DefSBitSetCore * gen = get_def(BB_id(bb)); DefSBitSetCore * use = get_use(BB_id(bb)); gen->clean(m_sbs_mgr); use->clean(m_sbs_mgr); for (IR * x = BB_last_ir(bb); x != NULL; x = BB_prev_ir(bb)) { ASSERT0(x->is_stmt()); switch (IR_code(x)) { case IR_ST: lst.clean(); processOpnd(ST_rhs(x), lst, use, gen); break; case IR_STPR: gen->bunion(STPR_no(x), m_sbs_mgr); use->diff(STPR_no(x), m_sbs_mgr); processMay(x, gen, use, true); lst.clean(); processOpnd(STPR_rhs(x), lst, use, gen); break; case IR_SETELEM: gen->bunion(SETELEM_prno(x), m_sbs_mgr); use->diff(SETELEM_prno(x), m_sbs_mgr); processMay(x, gen, use, true); lst.clean(); processOpnd(SETELEM_rhs(x), lst, use, gen); lst.clean(); processOpnd(SETELEM_ofst(x), lst, use, gen); break; case IR_GETELEM: gen->bunion(GETELEM_prno(x), m_sbs_mgr); use->diff(GETELEM_prno(x), m_sbs_mgr); processMay(x, gen, use, true); lst.clean(); processOpnd(GETELEM_base(x), lst, use, gen); lst.clean(); processOpnd(GETELEM_ofst(x), lst, use, gen); break; case IR_STARRAY: lst.clean(); processOpnd(x, lst, use, gen); break; case IR_IST: lst.clean(); processOpnd(x, lst, use, gen); break; case IR_SWITCH: lst.clean(); processOpnd(SWITCH_vexp(x), lst, use, gen); break; case IR_IGOTO: lst.clean(); processOpnd(IGOTO_vexp(x), lst, use, gen); break; case IR_GOTO: break; case IR_CALL: case IR_ICALL: if (x->hasReturnValue()) { gen->bunion(CALL_prno(x), m_sbs_mgr); use->diff(CALL_prno(x), m_sbs_mgr); processMay(x, gen, use, true); } lst.clean(); processOpnd(CALL_param_list(x), lst, use, gen); if (x->is_icall() && ICALL_callee(x)->is_pr()) { use->bunion(PR_no(ICALL_callee(x)), m_sbs_mgr); processMay(ICALL_callee(x), gen, use, false); } break; case IR_TRUEBR: case IR_FALSEBR: lst.clean(); processOpnd(BR_det(x), lst, use, gen); break; case IR_RETURN: lst.clean(); processOpnd(RET_exp(x), lst, use, gen); break; case IR_PHI: gen->bunion(PHI_prno(x), m_sbs_mgr); use->diff(PHI_prno(x), m_sbs_mgr); processMay(x, gen, use, true); lst.clean(); processOpnd(PHI_opnd_list(x), lst, use, gen); break; case IR_REGION: break; default: ASSERT0(0); } } }
static void xl_add_vers(definition *def_ptr, version_list *v, int prog_ref) { /* * This builds an interface for the version given, which inherits the * program that contains this version. */ int ref = get_def(); aoi_type bind; aoi_interface *ver; proc_list *curr_proc; int proc_ref; /* Create the interface. */ outaoi.defs.defs_val[ref].name = v->vers_name; outaoi.defs.defs_val[ref].binding = (aoi_type) mustmalloc(sizeof(aoi_type_u)); outaoi.defs.defs_val[ref].scope = curr_scope; outaoi.defs.defs_val[ref].idl_file = def_ptr->idl_file; bind = outaoi.defs.defs_val[ref].binding; bind->kind = AOI_INTERFACE; bind->aoi_type_u_u.interface_def = xl_new_vers_interface(def_ptr, prog_ref, v->vers_num); ver = &(bind->aoi_type_u_u.interface_def); /* Add the operations. */ proc_ref = 0; for (curr_proc = v->procs; curr_proc; curr_proc = curr_proc->next) proc_ref++; ver->ops.ops_len = proc_ref; ver->ops.ops_val = (aoi_operation *) mustmalloc(sizeof(aoi_operation) * proc_ref); for (curr_proc = v->procs, proc_ref = 0; curr_proc; curr_proc = curr_proc->next, proc_ref++) { aoi_operation *curr_op = &(ver->ops.ops_val[proc_ref]); curr_op->name = curr_proc->proc_name; curr_op->request_code = aoi_new_const_int(xl_eval(def_ptr, curr_proc->proc_num)); /* * XXX --- Adding 1024 to the procedure number is a hack. * Flick currently requires that the request and reply codes be * different. */ curr_op->reply_code = aoi_new_const_int(xl_eval(def_ptr, curr_proc->proc_num) + 1024); curr_op->flags = AOI_OP_FLAG_NONE; curr_op->return_type = xl_td_buildtype(def_ptr, curr_proc->res_type); curr_op->params.params_len = 1; curr_op->params.params_val = (aoi_parameter *) mustmalloc(sizeof(aoi_parameter)); /* * curr_op->params.params_val[0].name = (char *) 0; * ENE: A parameter with no name is bad news when we check the * CAST. We might as well give the parameter a name now. */ curr_op->params.params_val[0].name = "arg"; curr_op->params.params_val[0].direction = AOI_DIR_IN; curr_op->params.params_val[0].type = xl_td_buildtype(def_ptr, curr_proc->arg_type); } }