// // Method: runOnModule() // // Description: // Entry point for this LLVM pass. // // Return value: // true - The module was modified. // false - The module was not modified. // bool RewriteOOB::runOnModule (Module & M) { // // Insert calls so that comparison instructions convert Out of Bound pointers // back into their original values. This should be done *before* rewriting // the program so that pointers are replaced with the return values of bounds // checks; this is because the return values of bounds checks have no DSNode // in the DSA results, and hence, no associated Pool Handle. // bool modified = addGetActualValues (M); // // Transform the code for each type of checking function. Mark whether // we've changed anything. // for (unsigned index = 0; index < numChecks; ++index) { // // If this is not a pointer arithmetic check, skip it. // if (RuntimeChecks[index].checkType == gepcheck) { // // Transform the function so that the pointer it checks is replaced with // its return value. The return value is the rewritten OOB pointer. // modified |= processFunction (M, RuntimeChecks[index]); } } return modified; }
void TypeInferenceVisitor::visitBlockNode(BlockNode* node) { _scopes.push(node->scope()); Scope::FunctionIterator fit(node->scope()); while(fit.hasNext()) { processFunction(fit.next()); } node->visitChildren(this); _scopes.pop(); }
void METH(processBuffer)(t_sword * inbuf, t_sword * outbuf, t_uint16 size) { //int error = 0; if (mStereoenhancerConfig.mNewConfigAvailable == 1) { applyEffectConfig(&mStereoenhancerConfig,&mStereoEnhancerData); //reset the value mStereoenhancerConfig.mNewConfigAvailable = 0; } processFunction(inbuf, outbuf, size); OstTraceInt0(TRACE_DEBUG,"StereowidenerNmf::ProcessFunction reached"); }
LTerm Parser::processTerm(QString line){ specialDebug("Term : ", line); QStringList splitLine = split(line); if(splitLine.size() == 1){ if(splitLine[0][0] == QChar('?')){ specialDebug(" Variable ", splitLine[0]); LTerm answer = LTerm(new Logic_Term(splitLine[0], VARIABLE)); return answer; } else{ specialDebug(" Constant : ", splitLine[0]); LTerm answer = LTerm(new Logic_Term(splitLine[0], CONSTANT)); return answer; } } else{ return processFunction(line); } }
void codeGen(Node *root, FILE *ucoFile) { Node *p; // pointer for Node int globalSize; // the size of global variables file = ucoFile; // rootTable = initSymbolTable(); // step 1: process the declaration part for (p = root->son; p; p = p->next) { if (p->token.tokenNumber == DCL) { processDeclaration(rootTable, p->son); } else if (p->token.tokenNumber == FUNC_DEF) { processFuncHeader(rootTable, p->son); } else { icg_error(3); } } globalSize = rootTable->offset - 1; // step 2: process the function part for (p = root->son; p; p = p->next) { if (p->token.tokenNumber == FUNC_DEF) { processFunction(rootTable, p); } } display(rootTable, 0); // step 3: generate codes for starting routine // bgn globalSize // ldp // call main // end emit1("bgn", globalSize); emit0("ldp"); emitJump("call", "main"); emit0("end"); }
/** @internal @brief Flush a tBuffer, and check for special processing. This function determines if the tBuffer contains something that requires special processing, calls it if it does, or just outputs it unmodified if not. @param[in,out] buf the tBuffer to process */ static void flushBuffer(tBuffer *buf) { if (buf->ptr > buf->data) { if (buf->fileComment) { processFileComment(buf); } else if (buf->function.count == 1 && buf->arglist.count == 1 && buf->body.count == 1) { processFunction(buf); } else if (!gOptions.onlyPrototypes) { dumpBlock(buf, buf->data, buf->ptr); } } clearBuffer(buf); }
Value *ValueProcessor::processConstant(TokenList::const_iterator &i, TokenList::const_iterator &end, const ValueScope &scope, bool defaultVal) const { Token token; Value *ret; const TokenList *var; TokenList variable; bool hasQuotes; std::string str; if (i == end) return NULL; token = *i; switch (token.type) { case Token::HASH: i++; // generate color from hex value return new Color(token); case Token::NUMBER: case Token::PERCENTAGE: case Token::DIMENSION: i++; return new NumberValue(token); case Token::ATKEYWORD: if ((var = scope.getVariable(token)) != NULL) { variable = *var; ret = processStatement(variable, scope); if (ret != NULL) { i++; //ret->setLocation(token); return ret; } } return NULL; case Token::STRING: i++; hasQuotes = token.stringHasQuotes(); interpolate(token, scope); token.removeQuotes(); return new StringValue(token, hasQuotes); case Token::URL: i++; interpolate(token, scope); str = token.getUrlString(); return new UrlValue(token, str); case Token::IDENTIFIER: i++; if (i != end && (*i).type == Token::PAREN_OPEN) { if (token == "default") { i++; if ((*i).type != Token::PAREN_CLOSED) { throw new ParseException(*i, ")", (*i).line, (*i).column, (*i).source); } return new BooleanValue(token, defaultVal); } else if (functionExists(token.c_str())) { i++; ret = processFunction(token, i, end, scope); if (ret == NULL) { i--; i--; return NULL; } else return ret; } else { i--; return NULL; } } else if (token.compare("true") == 0) { return new BooleanValue(token, true); } else if ((ret = processUnit(token)) != NULL) { return ret; } else if ((ret = Color::fromName(token)) != NULL) { return ret; } else { return new StringValue(token, false); } case Token::PAREN_OPEN: return processSubstatement(i, end, scope, defaultVal); default: break; } if ((var = processDeepVariable(i, end, scope)) != NULL) { variable = *var; ret = processStatement(variable, scope); if (ret != NULL) { //ret->setLocation(token); } return ret; } if (token == "%") { i++; if (i != end && (*i).type == Token::PAREN_OPEN) { i++; if ((ret = processFunction(token, i, end, scope)) != NULL) return ret; i--; } i--; } if ((ret = processEscape(i, end, scope)) != NULL) { return ret; } else if ((ret = processNegative(i, end, scope)) != NULL) { return ret; } return NULL; }
static void findTag (tokenInfo *const token) { if (currentContext->kind != K_UNDEFINED) { /* Drop context, but only if an end token is found */ dropContext (token); } if (token->kind == K_CONSTANT && vStringItem (token->name, 0) == '`') { /* Bug #961001: Verilog compiler directives are line-based. */ int c = skipWhite (vGetc ()); readIdentifier (token, c); createTag (token); /* Skip the rest of the line. */ do { c = vGetc(); } while (c != EOF && c != '\n'); vUngetc (c); } else if (token->kind == K_BLOCK) { /* Process begin..end blocks */ processBlock (token); } else if (token->kind == K_FUNCTION || token->kind == K_TASK) { /* Functions are treated differently because they may also include the * type of the return value. * Tasks are treated in the same way, although not having a return * value.*/ processFunction (token); } else if (token->kind == K_ASSERTION) { if (vStringLength (currentContext->blockName) > 0) { vStringCopy (token->name, currentContext->blockName); createTag (token); skipToSemiColon (); } } else if (token->kind == K_TYPEDEF) { processTypedef (token); } else if (token->kind == K_CLASS) { processClass (token); } else if (token->kind == K_IGNORE && isSingleStatement (token)) { currentContext->singleStat = TRUE; } else if (isVariable (token)) { int c = skipWhite (vGetc ()); tagNameList (token, c); } else if (token->kind != K_UNDEFINED && token->kind != K_IGNORE) { int c = skipWhite (vGetc ()); if (isIdentifierCharacter (c)) { readIdentifier (token, c); while (getKind (token) == K_IGNORE) { c = skipWhite (vGetc ()); readIdentifier (token, c); } createTag (token); /* Get port list if required */ c = skipWhite (vGetc ()); if (c == '(' && hasSimplePortList (token)) { processPortList (c); } else { vUngetc (c); } } } }
// Plug-in process void CORE_Process(int iArg) { try { char version[16]; sprintf(version, "%u.%u", HIBYTE(MY_VERSION), LOBYTE(MY_VERSION)); msg("\n>> WhatAPIs: v: %s, built: %s, By Sirmabus\n", version, __DATE__); if (!autoIsOk()) { msg("** Must wait for IDA to finish processing before starting plug-in! **\n*** Aborted ***\n\n"); return; } // Show UI refreshUI(); int uiResult = AskUsingForm_c(mainDialog, version, doHyperlink); if (!uiResult) { msg(" - Canceled -\n"); return; } WaitBox::show(); TIMESTAMP startTime = getTimeStamp(); // Build import segment bounds table { msg("Import segments:\n"); refreshUI(); SEGLIST segList; for (int i = 0; i < get_segm_qty(); i++) { if (segment_t *s = getnseg(i)) { if (s->type == SEG_XTRN) { char buffer[64] = { "unknown" }; buffer[SIZESTR(buffer)] = 0; get_true_segm_name(s, buffer, SIZESTR(buffer)); msg(" [%d] \"%s\" "EAFORMAT" - "EAFORMAT"\n", segmentCount, buffer, s->startEA, s->endEA); BOUNDS b = { s->startEA, s->endEA }; segList.push_back(b); segmentCount++; } } } refreshUI(); // Flatten list into an array for speed if (segmentCount) { UINT size = (segmentCount * sizeof(BOUNDS)); if (segmentPtr = (BOUNDS *)_aligned_malloc(size, 16)) { BOUNDS *b = segmentPtr; for (SEGLIST::iterator i = segList.begin(); i != segList.end(); i++, b++) { b->startEA = i->startEA; b->endEA = i->endEA; } } else { msg("\n*** Allocation failure of %u bytes! ***\n", size); refreshUI(); } } } if (segmentCount) { // Make a list of all import names if (int moduleCount = get_import_module_qty()) { for (int i = 0; i < moduleCount; i++) enum_import_names(i, importNameCallback); char buffer[32]; msg("Parsed %s module imports.\n", prettyNumberString(moduleCount, buffer)); refreshUI(); } // Iterate through all functions.. BOOL aborted = FALSE; UINT functionCount = get_func_qty(); char buffer[32]; msg("Processing %s functions.\n", prettyNumberString(functionCount, buffer)); refreshUI(); for (UINT n = 0; n < functionCount; n++) { processFunction(getn_func(n)); if (WaitBox::isUpdateTime()) { if (WaitBox::updateAndCancelCheck((int)(((float)n / (float)functionCount) * 100.0f))) { msg("* Aborted *\n"); break; } } } refresh_idaview_anyway(); WaitBox::hide(); msg("\n"); msg("Done. %s comments add/appended in %s.\n", prettyNumberString(commentCount, buffer), timeString(getTimeStamp() - startTime)); msg("-------------------------------------------------------------\n"); } else msg("\n*** No import segments! ***\n"); if (segmentPtr) { _aligned_free(segmentPtr); segmentPtr = NULL; } apiMap.clear(); } CATCH() }
bool ControlBodyTranslator::preorder(const IR::MethodCallExpression* expression) { builder->append("/* "); visit(expression->method); builder->append("("); bool first = true; for (auto a : *expression->arguments) { if (!first) builder->append(", "); first = false; visit(a); } builder->append(")"); builder->append("*/"); builder->newline(); auto mi = P4::MethodInstance::resolve(expression, control->program->refMap, control->program->typeMap); auto apply = mi->to<P4::ApplyMethod>(); if (apply != nullptr) { processApply(apply); return false; } auto ef = mi->to<P4::ExternFunction>(); if (ef != nullptr) { processFunction(ef); return false; } auto ext = mi->to<P4::ExternMethod>(); if (ext != nullptr) { processMethod(ext); return false; } auto bim = mi->to<P4::BuiltInMethod>(); if (bim != nullptr) { builder->emitIndent(); if (bim->name == IR::Type_Header::isValid) { visit(bim->appliedTo); builder->append(".ebpf_valid"); return false; } else if (bim->name == IR::Type_Header::setValid) { visit(bim->appliedTo); builder->append(".ebpf_valid = true"); return false; } else if (bim->name == IR::Type_Header::setInvalid) { visit(bim->appliedTo); builder->append(".ebpf_valid = false"); return false; } } auto ac = mi->to<P4::ActionCall>(); if (ac != nullptr) { // Action arguments have been eliminated by the mid-end. BUG_CHECK(expression->arguments->size() == 0, "%1%: unexpected arguments for action call", expression); visit(ac->action->body); return false; } ::error("Unsupported method invocation %1%", expression); return false; }
int SwPluginCore2::treatFrame(char * framebuffer, int framesize) { char *header = strstr(framebuffer, SWFRAME_HEADER); if(!header) { fprintf(stderr, "!!!!!!! SwPluginCore: Invalid header in treatFrame()\n"); fflush(stderr); swPurgePipe(stdin); return 0; } char *command = header + strlen(SWFRAME_HEADER) + 1; char *arg = nextTab( command ); // category ?? if(strncmp(command, SWFRAME_ASKCATEGORY, strlen(SWFRAME_ASKCATEGORY)) == 0) { sendCategory(); return 1; } // Function list ?? if(strncmp(command, SWFRAME_ASKFUNCLIST, strlen(SWFRAME_ASKFUNCLIST)) == 0) { sendFunctions(); return 1; } // quit command if(strncmp(command, SWFRAME_QUIT, strlen(SWFRAME_QUIT)) == 0) { fprintf(stderr, "Quitting...\n"); fflush(stderr); quit = true; return 1; } // Function descriptor ?? if(strncmp(command, SWFRAME_ASKFUNCTIONDESC, strlen(SWFRAME_ASKFUNCTIONDESC)) == 0) { int nb = atoi(arg); if(nb > NbFunctions) return 0; sendFunctionDescriptor( nb); return 1; } // Function call if(strncmp(command, SWFRAME_SETFUNCTIONDESC, strlen(SWFRAME_SETFUNCTIONDESC)) == 0) { setFunctionParameters(arg, framesize - (arg - framebuffer) ); return 1; } // Function call if(strncmp(command, SWFRAME_PROCESSRESULT, strlen(SWFRAME_PROCESSRESULT)) == 0) { processFunction(arg, framesize - (arg - framebuffer) ); return 1; } return 0; }