int idaapi logmsg(const char *format, ...) { if (!isLoggingEnabled()) return -1; va_list va; va_start(va, format); int nbytes = vmsg(format, va); va_end(va); return nbytes; }
void TR::ILValidator::updateNodeState(Location &newLocation) { TR::Node *node = newLocation.currentNode(); NodeState &state = _nodeStates[node]; if (node->getReferenceCount() == state._futureReferenceCount) { // First occurrence -- do some bookkeeping // if (node->getReferenceCount() == 0) { validityRule(newLocation, node->getOpCode().isTreeTop(), "Only nodes with isTreeTop opcodes can have refcount == 0"); } else { _liveNodes.add(node); } } if (_liveNodes.contains(node)) { validityRule(newLocation, state._futureReferenceCount >= 1, "Node already has reference count 0"); if (--state._futureReferenceCount == 0) { _liveNodes.remove(node); } } else { validityRule(newLocation, node->getOpCode().isTreeTop(), "Node has already gone dead"); } if (isLoggingEnabled()) { static const char *traceLiveNodesDuringValidation = feGetEnv("TR_traceLiveNodesDuringValidation"); if (traceLiveNodesDuringValidation && !_liveNodes.isEmpty()) { traceMsg(comp(), " -- Live nodes: {"); char *separator = ""; for (LiveNodeWindow::Iterator lnwi(_liveNodes); lnwi.currentNode(); ++lnwi) { traceMsg(comp(), "%sn%dn", separator, lnwi.currentNode()->getGlobalIndex()); separator = ", "; } traceMsg(comp(), "}\n"); } } }
void FileLock::log(const std::string& message) { if (s_logFile.empty() || !isLoggingEnabled()) { // if we were constructed without a path, or file lock logging was not explicitly enabled // (legacy option), then debug log to the in-proc logger LOG_DEBUG_MESSAGE_NAMED(kFileLockingLogSection, message); } else { // avoid logging too many errors (e.g. if the user has specified // a file that does not exist) static int counter = 0; static int max = 5; if (counter < max) { // append to logfile Error error = core::writeStringToFile( s_logFile, message, string_utils::LineEndingPosix, false); if (error) { LOG_ERROR(error); ++counter; } } else if (counter == max) { LOG_ERROR_MESSAGE("failed to write lockfile logs"); ++counter; } else { // do nothing } } }
void initLoggingFile(const char* filename) { if (isLoggingEnabled()) g_ofs = std::make_unique<std::ofstream>(filename); }