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


C++ Proc::type方法代码示例

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


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

示例1: if

void
BinUtil::TextSeg::ctor_initProcs()
{
  Dbg::LM* dbgInfo = m_lm->getDebugInfo();

  // Any procedure with a parent has a <Proc*, parentVMA> entry
  std::map<Proc*, VMA> parentMap;
  
  // ------------------------------------------------------------
  // Each text section finds and creates its own routines.
  // Traverse the symbol table (which is sorted by VMA) searching
  // for function symbols in our section.  Create a Proc for
  // each one found.
  //
  // Note that symbols can appear multiple times (e.g. a weak symbol
  // 'sbrk' along with a gloabl symbol '__sbrk'), but we should not
  // have multiple procedures.
  // ------------------------------------------------------------

  bfd* abfd = m_lm->abfd();
  asymbol** symtab = m_lm->bfdSymTab(); // sorted
  uint symtabSz = m_lm->bfdSymTabSz();

  // FIXME:PERF: exploit sortedness of 'symtab' to start iteration
  for (uint i = 0; i < symtabSz; i++) {
    asymbol* sym = symtab[i];
    if (isIn(bfd_asymbol_value(sym)) && Proc::isProcBFDSym(sym)) {
      // NOTE: initially we have [begVMA, endVMA) where endVMA is the
      // *end* of the last insn.  This is changed after decoding below.
      VMA begVMA = bfd_asymbol_value(sym);
      VMA endVMA = 0; 
      
      Proc::Type procType;
      if (sym->flags & BSF_LOCAL) {
        procType = Proc::Local;
      }
      else if (sym->flags & BSF_WEAK) {
        procType = Proc::Weak;
      }
      else if (sym->flags & BSF_GLOBAL) {
        procType = Proc::Global;
      }
      else {
        procType = Proc::Unknown;
      }
      
      Proc* proc = m_lm->findProc(begVMA);
      if (proc) {
	DIAG_Assert(proc->begVMA() == begVMA, "TextSeg::ctor_initProcs: Procedure beginning at 0x" << hex << begVMA << " overlaps with:\n" << proc->toString());
	if (procType == Proc::Global) {
	  // 'global' types take precedence
	  proc->type(procType);
	}
	continue;
      }
      
      // Create a procedure based on best information we have.  We
      // always prefer explicit debug information over that inferred
      // from the symbol table.
      string procNm;
      string symNm = bfd_asymbol_name(sym);

      Dbg::LM::iterator it = dbgInfo->find(begVMA);
      Dbg::Proc* dbg = (it != dbgInfo->end()) ? it->second : NULL;

      if (!dbg) {
	procNm = findProcName(abfd, sym);
	string pnm = BinUtil::canonicalizeProcName(procNm);
	
	Dbg::LM::iterator1 it1 = dbgInfo->find1(pnm);
	dbg = (it1 != dbgInfo->end1()) ? it1->second : NULL;
      }
      if (!dbg) {
	Dbg::LM::iterator1 it1 = dbgInfo->find1(symNm);
	dbg = (it1 != dbgInfo->end1()) ? it1->second : NULL;
      }
      
      // Finding the end VMA (end of last insn).  The computation is
      // as follows because sometimes the debug information is
      // *wrong*. (Intel 9 has generated significant over-estimates).
      //
      // N.B. exploits the fact that the symbol table is sorted by vma
      VMA endVMA_approx = findProcEnd(i);

      if (dbg) {
	if (!dbg->name.empty()) {
	  procNm = dbg->name;
	}
	else if (!symNm.empty()) {
          // sometimes a procedure name is in the symbol table even
          // though it is not in the dwarf section. this case occurs
          // when gcc outlines routines from OpenMP parallel sections.
          procNm = symNm;
  	}

#if 1
	// Remove capability below... the DWARF sizes can be wrong!!
	endVMA = endVMA_approx;
#else
	endVMA = std::min(dbg->endVMA, endVMA_approx);
//.........这里部分代码省略.........
开发者ID:wjcsharp,项目名称:hpctoolkit,代码行数:101,代码来源:Seg.cpp


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