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


C++ Trace::consume_header方法代码示例

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


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

示例1: assembly


//.........这里部分代码省略.........
              bblock->bap_ir = new vector<Stmt *>();
              bblock->inst = tf->id;
              //generate_bap_ir_block(prog, bblock);
              Label * label = new Label("ReadSyscall");
              if (atts)
                  label->attributes.cv = tf->getOperands() ;
              bblock->bap_ir->push_back(label);
              bblock->vex_ir = NULL;
              result->push_back(bblock);
          
              //cerr << sf->callno << " " << sf->args[0] << " " << sf->args[4] << endl;
              //for (int i = 0 ; i < bblock->bap_ir->size() ; i ++)
              //    cout << bblock->bap_ir->at(i)->tostring() << endl ;
              break;
	  
          }
          
      case pintrace::FRM_EXCEPT:   // TODO: Fill this in
          {
              break;
          }

      default:
          break;

      }

      /* After all this, delete the frame */
      delete f;
      /* Clean up prog, prog->abfd, and vex memory */
      asmir_close(prog);
    }
    
  }
  else {
    ifstream trace ;
    trace.open(filename.c_str());
    
    if (!trace.is_open()) {
      cerr << "Couldn't open " << filename << endl;
      exit(1);
    }
    
    Trace * trc ;
    EntryHeader eh;
    TraceHeader hdr;
    
    try {
      trace.read(BLOCK(hdr), TRACE_HEADER_FIXED_SIZE);
      
      assert(hdr.magicnumber == MAGIC_NUMBER) ;
      switch (hdr.version)
	{
	case 40: trc = new Trace_v40(&trace); break;
	case 41: trc = new Trace_v41(&trace); break;
	case 50: trc = new Trace_v50(&trace); break;
	default: throw "unsupported trace version";
	}
      trc->consume_header(&hdr) ;
      
      /* Since the traces do not contain any architecture information *
       * we only support x86 for now - ethan                          */
      VexArch arch = VexArchX86;
      /* XXX Suspected memory leak! (Is prog freed?) */
      asm_program_t * prog = asmir_new_asmp_for_arch(bfd_arch_i386);
      
      // Initializations
      translate_init();
      while(!trace.eof()) {
	// Reading each entry header
	trc->read_entry_header(&eh);
	
	counter ++ ;
	if (counter > offset) {

	  bap_block_t *bblock = new bap_block_t;
	  bblock->bap_ir = new vector<Stmt *>();
	  bblock->inst = eh.address;
	  // lift the instruction to VEX IL
	  bblock->vex_ir = translate_insn(arch, eh.rawbytes, eh.address);
	  // and then to BAP IL
	  generate_bap_ir_block(prog, bblock);
	  if (atts)
	    bblock->bap_ir->front()->attributes.cv = trc->operand_status(&eh) ;
	  // append to result
	  result->push_back(bblock);
	  int i;
	  if (print)
	    for ( i = 0 ; i < bblock->bap_ir->size() ; i ++)
	      cout << bblock->bap_ir->at(i)->tostring() << endl ;
	}
      }
    }
    catch (const char * s)
      {
	cout << s << endl ;
      }
  }
  return result;
}
开发者ID:GREYFOXRGR,项目名称:moflow,代码行数:101,代码来源:readtrace.cpp


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