void MVM_spesh_log_add_logging(MVMThreadContext *tc, MVMSpeshGraph *g, MVMint32 osr) { MVMSpeshBB *bb; /* We've no log slots so far. */ g->num_log_slots = 0; /* Work through the code, adding logging instructions where needed. */ bb = g->entry; while (bb) { MVMSpeshIns *ins = bb->first_ins; while (ins) { switch (ins->info->opcode) { case MVM_OP_getlex: if (g->sf->body.local_types[ins->operands[0].reg.orig] == MVM_reg_obj) insert_log(tc, g, bb, ins, 0); break; case MVM_OP_getlex_no: case MVM_OP_getattr_o: case MVM_OP_getattrs_o: case MVM_OP_getlexstatic_o: case MVM_OP_getlexperinvtype_o: insert_log(tc, g, bb, ins, 0); break; case MVM_OP_invoke_o: insert_log(tc, g, bb, ins, 1); break; case MVM_OP_osrpoint: if (osr) ins->info = MVM_op_get_op(MVM_OP_sp_osrfinalize); else MVM_spesh_manipulate_delete_ins(tc, g, bb, ins); break; } ins = ins->next; } bb = bb->linear_next; } /* Allocate space for logging storage. */ g->log_slots = g->num_log_slots ? MVM_calloc(g->num_log_slots * MVM_SPESH_LOG_RUNS, sizeof(MVMCollectable *)) : NULL; }
/** * Log each event * * @param irc_session_t session * @param char event * @param char origin * @param char params * @param int count * * @return void */ void log_event(irc_session_t * session, const char * event, const char * origin, const char ** params, unsigned int count) { char buf[512]; int cnt; buf[0] = '\0'; for (cnt = 0; cnt < count; cnt++) { if (cnt) { strcat (buf, "|"); } strcat(buf, params[cnt]); } insert_log(event, origin ? origin : "NULL", cnt, buf); }