当前位置: 首页>>代码示例>>C++>>正文


C++ codeGen::point方法代码示例

本文整理汇总了C++中codeGen::point方法的典型用法代码示例。如果您正苦于以下问题:C++ codeGen::point方法的具体用法?C++ codeGen::point怎么用?C++ codeGen::point使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在codeGen的用法示例。


在下文中一共展示了codeGen::point方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: generateInterFunctionBranch

void insnCodeGen::generateInterFunctionBranch(codeGen &gen,
                                              Address from,
                                              Address to,
                                              bool link) {
    long disp = to - from;

    if (ABS(disp) <= MAX_BRANCH) {
        // We got lucky...
        return generateBranch(gen, from, to);
    }
    instPoint *point = gen.point();
    if (!point) {
        return generateBranchViaTrap(gen, from, to, false);
    }
    assert(point);
    bitArray liveRegs = point->liveRegisters();
    if (liveRegs[registerSpace::ctr] == true) 
    {
	fprintf(stderr, " COUNT REGISTER NOT AVAILABLE. We cannot insterument this point. skipping ...\n");
	return;
    }

    insnCodeGen::loadImmIntoReg(gen, 0, to);
    insnCodeGen::generateMoveToCR(gen, 0);
    // And branch to CTR
    instruction btctr(link ? BCTRLraw : BCTRraw);
    insnCodeGen::generate(gen,btctr);
}
开发者ID:chubbymaggie,项目名称:dyninst,代码行数:28,代码来源:codegen-power.C

示例2: PCtoReturnAddr

bool PCWidget::PCtoReturnAddr(const codeGen &templ, const RelocBlock *t, CodeBuffer &buffer) {
  if(templ.addrSpace()->proc()) {
    std::vector<unsigned char> newInsn;
#if defined(arch_x86_64)
    codeGen gen(16);
    Address RIP = addr_ + insn_.size();
    insnCodeGen::generatePush64(gen, RIP);
    buffer.addPIC(gen, tracker(t));
#elif defined(arch_x86)
    newInsn.push_back(0x68); // push
    Address EIP = addr_ + insn_.size();
    unsigned char *tmp = (unsigned char *) &EIP;
    newInsn.insert(newInsn.end(),
		   tmp,
		   tmp+sizeof(unsigned int));
    buffer.addPIC(newInsn, tracker(t));
#else
    // We want to get a value into LR, which is the return address.
    // Fun for the whole family... we need a spare register. Argh!

    codeGen gen(16);
    gen.applyTemplate(templ);
    // Must be in LR
    instPoint *point = templ.point();
    // If we do not have a point then we have to invent one
    if (!point || 
	(point->type() != instPoint::PreInsn &&
	 point->insnAddr() != addr())) {
      point = instPoint::preInsn(t->func(), t->block(), addr(), insn_, true);
    }
    assert(point);
    
    registerSpace *rs = registerSpace::actualRegSpace(point);
    gen.setRegisterSpace(rs);
    int stackSize = 0;
    pdvector<Register> freeReg;
    pdvector<Register> excludeReg;
    
    Address origRet = addr() + insn_.size();
    Register scratch = gen.rs()->getScratchRegister(gen, true);
    if (scratch == REG_NULL) {
      stackSize = insnCodeGen::createStackFrame(gen, 1, freeReg, excludeReg);
      assert(stackSize == 1);
      scratch = freeReg[0];
    }
    insnCodeGen::loadImmIntoReg(gen, scratch, origRet);
    insnCodeGen::generateMoveToLR(gen, scratch);
    buffer.addPIC(gen, tracker(t));
#endif
  }
  else {
    IPPatch *newPatch = new IPPatch(IPPatch::Push, addr_, insn_, t->block(), t->func());
    buffer.addPatch(newPatch, tracker(t));
  }	
   
  return true;
}
开发者ID:dyninst,项目名称:dyninst,代码行数:57,代码来源:PCWidget.C

示例3: apply

bool RelDataPatch::apply(codeGen &gen, CodeBuffer *) {
  instruction ugly_insn(orig_insn.ptr(), (gen.width() == 8));
  instPoint *point = gen.point();
  if (!point || (point->type() != instPoint::PreInsn && point->insnAddr() != orig)) {
      point = instPoint::preInsn(func, block, orig, orig_insn, true);
  }
  registerSpace *rs = registerSpace::actualRegSpace(point);
  gen.setRegisterSpace(rs);

  if (!insnCodeGen::modifyData(target_addr, ugly_insn, gen)) {
      relocation_cerr << "RelDataPatch returned false from modifyData (original address: " << std::hex<< orig << ")" <<endl;
      return false;
  }
  return true;
}
开发者ID:dyninst,项目名称:dyninst,代码行数:15,代码来源:RelDataWidget.C

示例4: generateLongBranch

void insnCodeGen::generateLongBranch(codeGen &gen, 
                                     Address from, 
                                     Address to, 
                                     bool isCall) {
    // First, see if we can cheap out
    long disp = (to - from);
    if (ABS(disp) <= MAX_BRANCH) {
        return generateBranch(gen, disp, isCall);
    }

    // We can use a register branch via the LR or CTR, if either of them
    // is free.
    
    // Let's see if we can grab a free GPregister...
    instPoint *point = gen.point();
    if (!point) {
        // fprintf(stderr, " %s[%d] No point generateBranchViaTrap \n", FILE__, __LINE__);
        return generateBranchViaTrap(gen, from, to, isCall);
    }

    assert(point);
    
    // Could see if the codeGen has it, but right now we have assert
    // code there and we don't want to hit that.
    registerSpace *rs = registerSpace::actualRegSpace(point);
    gen.setRegisterSpace(rs);
    
    Register scratch = rs->getScratchRegister(gen, true);

    bool mustRestore = false;
    
    if (scratch == REG_NULL) { 
        // On Linux we save under the stack and hope it doesn't
        // cause problems.
        fprintf(stderr, " %s[%d] No registers generateBranchViaTrap \n", FILE__, __LINE__);
        return generateBranchViaTrap(gen, from, to, isCall);
    }
    
    // Load the destination into our scratch register
    insnCodeGen::loadImmIntoReg(gen, scratch, to);
    
    // Find out whether the LR or CTR is "dead"...
    bitArray liveRegs = point->liveRegisters();
    unsigned branchRegister = 0;
    if (liveRegs[registerSpace::lr] == false) {
        branchRegister = registerSpace::lr;
    }
    else if (liveRegs[registerSpace::ctr] == false) {
        branchRegister = registerSpace::ctr;
    }

    if (!branchRegister) {
        fprintf(stderr, " %s[%d] No branch register generateBranchViaTrap \n", FILE__, __LINE__);
        return generateBranchViaTrap(gen, from, to, isCall); 
    }
    
    assert(branchRegister);
    
    instruction moveToBr;
    moveToBr.clear();
    XFXFORM_OP_SET(moveToBr, MTSPRop);
    XFXFORM_RT_SET(moveToBr, scratch);
    if (branchRegister == registerSpace::lr) {
        XFORM_RA_SET(moveToBr, SPR_LR & 0x1f);
        XFORM_RB_SET(moveToBr, (SPR_LR >> 5) & 0x1f);
        // The two halves (top 5 bits/bottom 5 bits) are _reversed_ in this encoding. 
    }
开发者ID:chubbymaggie,项目名称:dyninst,代码行数:67,代码来源:codegen-power.C

示例5: apply

bool IPPatch::apply(codeGen &gen, CodeBuffer *) {
  relocation_cerr << "\t\t IPPatch::apply" << endl;

  // We want to generate addr (as modified) into the appropriate location.
  // TODO get rid of the #ifdef here...

#if defined(arch_x86) || defined(arch_x86_64) 
    GET_PTR(newInsn, gen); 
    
    *newInsn = 0xE8;
    newInsn++;
    unsigned int *temp = (uint32_t *) newInsn;
    *temp = 0;
    newInsn += sizeof(uint32_t);
    SET_PTR(newInsn, gen);
    Address offset = addr - gen.currAddr() + insn->size();
    REGET_PTR(newInsn, gen);
    *newInsn = 0x81;
    newInsn++;
    *newInsn = 0x04;
    newInsn++;
    *newInsn = 0x24;
    newInsn++;
    temp =  (uint32_t *) newInsn;
    *temp = offset;
    newInsn += sizeof(uint32_t);	  

    if (type == Reg) {
      assert(reg != (Register) -1);
      // pop...
      *newInsn++ = static_cast<unsigned char>(0x58 + reg); // POP family
    }
    SET_PTR(newInsn, gen);
#else
    // For dynamic we can do this in-line
    assert(gen.addrSpace()->edit());

    // Must be in LR
    if (reg == -1) reg = registerSpace::lr;
    assert(reg == registerSpace::lr);

    instPoint *point = gen.point();
    // If we do not have a point then we have to invent one
    if (!point || 
	(point->type() != instPoint::PreInsn &&
	 point->insnAddr() != addr)) {
      point = instPoint::preInsn(func, block, addr, insn, true);
    }
    assert(point);
    
    registerSpace *rs = registerSpace::actualRegSpace(point);
    gen.setRegisterSpace(rs);
    
    int stackSize = 0;
    pdvector<Register> freeReg;
    pdvector<Register> excludeReg;
    
    Register scratchPCReg = gen.rs()->getScratchRegister(gen, true);
    excludeReg.push_back(scratchPCReg);
    Register scratchReg = gen.rs()->getScratchRegister(gen, excludeReg, true);
    
    if ((scratchPCReg == REG_NULL) && (scratchReg == REG_NULL)) {
      excludeReg.clear();
      stackSize = insnCodeGen::createStackFrame(gen, 2, freeReg, excludeReg);
      assert(stackSize == 2);
      scratchPCReg = freeReg[0];
      scratchReg = freeReg[1];
      
    } else if (scratchReg == REG_NULL && scratchPCReg != REG_NULL) {
      stackSize = insnCodeGen::createStackFrame(gen, 1, freeReg, excludeReg);
      assert(stackSize == 1);
      scratchReg = freeReg[0];
    } 
    
    //scratchPCReg == NULL && scratchReg != NULL - not a valid case 
    //since getScratchRegister works in order
    
    // relocaAddr may have moved if we added instructions to setup a new stack frame
    Address newRelocAddr = gen.currAddr();
    
    insnCodeGen::generateBranch(gen, gen.currAddr(),  gen.currAddr()+4, true); // blrl
    insnCodeGen::generateMoveFromLR(gen, scratchPCReg); // mflr
    
    Address varOffset = addr - newRelocAddr;
    gen.emitter()->emitCallRelative(scratchReg, varOffset, scratchPCReg, gen);
    insnCodeGen::generateMoveToLR(gen, scratchReg);

    if( stackSize > 0) {
      insnCodeGen::removeStackFrame(gen); 
    }
#endif
    return true;
}
开发者ID:Zirkon,项目名称:dyninst,代码行数:93,代码来源:PCWidget.C


注:本文中的codeGen::point方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。