// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void SimpleDeadCodeElimination::InstructionRemoved(Instruction* instr) { #if 1 auto block = instr->ParentBlock(); auto function = instr->ParentFunction(); string blockName = block && block->HasName() ? *block->Name() : "UNTITLED"; string functionName = function && function->HasName() ? *function->Name() : "UNTITLED"; string text = IRPrinter(instr).ToString(); Log::Warning("Dead instr removed in " + functionName + ":" + blockName + ": " + text); #endif }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void AggregateCopyPropagation::CopyPropagated(Instruction* instr) { #if 1 auto block = instr->ParentBlock(); auto function = instr->ParentFunction(); string blockName = block && block->HasName() ? *block->Name() : "UNTITLED"; string functionName = function && function->HasName() ? *function->Name() : "UNTITLED"; string text = IRPrinter(instr).ToString(); Log::Warning("Aggregate copy propagated in " + functionName + ":" + blockName + ": " + text); #endif }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void Peephole::InstructionSimplified(Instruction* before, Operand* after) { #if 1 auto block = before->ParentBlock(); auto function = before->ParentFunction(); string blockName = block && block->HasName() ? *block->Name() : "UNTITLED"; string functionName = function && function->HasName() ? *function->Name() : "UNTITLED"; string beforeText = IRPrinter(before).ToString(); string afterText = after->HasDefiningInstruction() ? IRPrinter(after->DefiningInstruction()).ToString() : IRPrinter(after).ToString(); Log::Warning("Peephole in " + functionName + ":" + blockName + ": " + beforeText + " => " + afterText); #endif }
QString WeatherGlobal::getConfigFile(const QString &serverName) const { SERVERS::const_iterator server = std::find_if(servers_.begin(), servers_.end(), HasName(serverName)); if (server != servers_.end()) return server->configFile_; else QString(); }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void RecursionElimination::CallEliminated(Block* block) { #if 1 auto function = block->ParentFunction(); string blockName = block && block->HasName() ? *block->Name() : "UNTITLED"; string functionName = function && function->HasName() ? *function->Name() : "UNTITLED"; Log::Warning("Tail call eliminated in " + functionName + ":" + blockName); #endif }
bool ForEachName(T && fn) { if (!HasName()) return false; ParseCommon(); m_params.name.ForEach(std::forward<T>(fn)); return true; }
void WeatherGlobal::setServerUsing(const QString serverName, bool use) { SERVERS::iterator server = std::find_if(servers_.begin(), servers_.end(), HasName(serverName)); if (server != servers_.end()) server->use_ = use; }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void VariableAnalysis::Dump() { ObjectDumper("", "SSA Variable Analysis").Dump(); auto function = funct_; string text = ""; // Address taken info. for(int i = 0; i < funct_->VariableCount(); i++) { auto variable = funct_->Variables()[i]; if(variable->IsAddressTaken()) { if(variable->HasName()) { text = text + *variable->Name() + ", "; } } } for(int i = 0; i < funct_->ParameterCount(); i++) { auto variable = funct_->Parameters()[i]; if(variable->IsAddressTaken()) { if(variable->HasName()) { text = text + *variable->Name() + ", "; } } } ObjectDumper(text, "Address taken: ").Dump(); // Definition and live blocks info. string defText = ""; string liveText = ""; for(int i = 0; i < funct_->VariableCount(); i++) { auto variable = funct_->Variables()[i]; if(defBlocks_.ContainsKey(variable->Id())) { auto& blockSet = defBlocks_[variable->Id()]; defText = defText + "\n" + (variable->HasName() ? *variable->Name() : "UNTITLED") + ": "; blockSet.ForEachSetBit([&defText, function](int index) -> bool { auto block = function->GetBlock(index); if(block->HasName()) { defText = defText + *block->Name() + ", "; } return true; }); } if(liveBlocks_.ContainsKey(variable->Id())) { auto& liveSet = liveBlocks_[variable->Id()]; liveText = liveText + "\n" + (variable->HasName() ? *variable->Name() : "UNTITLED") + ": "; liveSet.ForEachSetBit([&liveText, function](int index) -> bool { auto block = function->GetBlock(index); if(block->HasName()) { liveText = liveText + *block->Name() + ", "; } return true; }); } } ObjectDumper(defText, "Definition blocks: ").Dump(); ObjectDumper(liveText, "Live blocks: ").Dump(); }
bool LauncherLink::Process() { if (!tcpc->Connected()) return false; if(m_bootTimer.Check(false)) { //force a boot on any zone which isnt running. std::map<std::string, ZoneState>::iterator cur, end; cur = m_states.begin(); end = m_states.end(); for(; cur != end; ++cur) { if(!cur->second.up) { StartZone(cur->first.c_str()); } } m_bootTimer.Disable(); } ServerPacket *pack = 0; while((pack = tcpc->PopPacket())) { _hex(WORLD__ZONE_TRACE,pack->pBuffer,pack->size); if (!authenticated) { if (WorldConfig::get()->SharedKey.length() > 0) { if (pack->opcode == ServerOP_ZAAuth && pack->size == 16) { uint8 tmppass[16]; MD5::Generate((const uchar*) WorldConfig::get()->SharedKey.c_str(), WorldConfig::get()->SharedKey.length(), tmppass); if (memcmp(pack->pBuffer, tmppass, 16) == 0) authenticated = true; else { struct in_addr in; in.s_addr = GetIP(); _log(WORLD__LAUNCH_ERR, "Launcher authorization failed."); ServerPacket* pack = new ServerPacket(ServerOP_ZAAuthFailed); SendPacket(pack); delete pack; Disconnect(); return false; } } else { struct in_addr in; in.s_addr = GetIP(); _log(WORLD__LAUNCH_ERR, "Launcher authorization failed."); ServerPacket* pack = new ServerPacket(ServerOP_ZAAuthFailed); SendPacket(pack); delete pack; Disconnect(); return false; } } else { _log(WORLD__LAUNCH,"**WARNING** You have not configured a world shared key in your config file. You should add a <key>STRING</key> element to your <world> element to prevent unauthroized zone access."); authenticated = true; } delete pack; continue; } switch(pack->opcode) { case 0: break; case ServerOP_KeepAlive: { // ignore this break; } case ServerOP_ZAAuth: { _log(WORLD__LAUNCH, "Got authentication from %s when they are already authenticated.", m_name.c_str()); break; } case ServerOP_LauncherConnectInfo: { const LauncherConnectInfo *it = (const LauncherConnectInfo *) pack->pBuffer; if(HasName()) { _log(WORLD__LAUNCH_ERR, "Launcher '%s' received an additional connect packet with name '%s'. Ignoring.", m_name.c_str(), it->name); break; } m_name = it->name; EQLConfig *config = launcher_list.GetConfig(m_name.c_str()); if(config == nullptr) { _log(WORLD__LAUNCH, "Unknown launcher '%s' connected. Disconnecting.", it->name); Disconnect(); break; } _log(WORLD__LAUNCH, "Launcher Identified itself as '%s'. Loading zone list.", it->name); std::vector<LauncherZone> result; //database.GetLauncherZones(it->name, result); config->GetZones(result); std::vector<LauncherZone>::iterator cur, end; cur = result.begin(); end = result.end(); ZoneState zs; for(; cur != end; cur++) { zs.port = cur->port; zs.up = false; zs.starts = 0; _log(WORLD__LAUNCH_TRACE, "%s: Loaded zone '%s' on port %d", m_name.c_str(), cur->name.c_str(), zs.port); m_states[cur->name] = zs; } //now we add all the dynamics. BootDynamics(config->GetDynamicCount()); m_bootTimer.Start(); break; } case ServerOP_LauncherZoneStatus: { const LauncherZoneStatus *it = (const LauncherZoneStatus *) pack->pBuffer; std::map<std::string, ZoneState>::iterator res; res = m_states.find(it->short_name); if(res == m_states.end()) { _log(WORLD__LAUNCH_ERR, "%s: reported state for zone %s which it does not have.", m_name.c_str(), it->short_name); break; } _log(WORLD__LAUNCH, "%s: %s reported state %s (%d starts)", m_name.c_str(), it->short_name, it->running?"STARTED":"STOPPED", it->start_count); res->second.up = it->running; res->second.starts = it->start_count; break; } default: { _log(WORLD__LAUNCH_ERR, "Unknown ServerOPcode from launcher 0x%04x, size %d",pack->opcode,pack->size); DumpPacket(pack->pBuffer, pack->size); break; } } delete pack; } return(true); }