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


C++ Symtab类代码示例

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


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

示例1: if

bool
SymbolContext::GetAddressRange (uint32_t scope, AddressRange &range) const
{
    if ((scope & eSymbolContextLineEntry) && line_entry.IsValid())
    {
        range = line_entry.range;
        return true;
    }
    else if ((scope & eSymbolContextFunction) && function != NULL)
    {
        range = function->GetAddressRange();
        return true;
    }
    else if ((scope & eSymbolContextSymbol) && symbol != NULL && symbol->GetAddressRangePtr())
    {
        range = *symbol->GetAddressRangePtr();

        if (range.GetByteSize() == 0)
        {
            if (module_sp)
            {
                ObjectFile *objfile = module_sp->GetObjectFile();
                if (objfile)
                {
                    Symtab *symtab = objfile->GetSymtab();
                    if (symtab)
                        range.SetByteSize(symtab->CalculateSymbolSize (symbol));
                }
            }
        }
        return true;
    }
    range.Clear();
    return false;
}
开发者ID:ice799,项目名称:lldb,代码行数:35,代码来源:SymbolContext.cpp

示例2: getFileLineByAddr

DysectAPI::DysectErrorCode SymbolTable::getFileLineByAddr(string& fileName, int& line, Dyninst::Address addr, Dyninst::Stackwalker::Walker* proc) {
  bool ret;
  LibAddrPair lib;
  vector<LineNoTuple *> lines;

  if(SymbolTable::getLibraryByAddr(lib, addr, proc) != OK) {
    fileName = "?";
    line = 0;
    return OK;
  }

  Symtab* symtab = 0;
  string libName = lib.first;
  if(SymbolTable::getSymbolTable(libName, symtab) != OK) {
    return Err::warn(Error, "Could not load symbol table for library '%s'", libName.c_str());
  }

  symtab->setTruncateLinePaths(false);
  Address loadAddr = lib.second;
  ret = symtab->getSourceLines(lines, addr - loadAddr);
  if (!ret)
  {
    fileName = "?"; 
    line = 0;
    return OK;
  }

  fileName = string(lines[0]->getFile());
  line = lines[0]->getLine();

  return OK;
}
开发者ID:wujieqian,项目名称:STAT,代码行数:32,代码来源:symbol.cpp

示例3: module_sp

lldb::SBSymbolContextList
SBModule::FindSymbols (const char *name, lldb::SymbolType symbol_type)
{
    SBSymbolContextList sb_sc_list;
    if (name && name[0])
    {
        ModuleSP module_sp (GetSP ());
        Symtab *symtab = GetUnifiedSymbolTable (module_sp);
        if (symtab)
        {
            std::vector<uint32_t> matching_symbol_indexes;
            const size_t num_matches = symtab->FindAllSymbolsWithNameAndType(ConstString(name), symbol_type, matching_symbol_indexes);
            if (num_matches)
            {
                SymbolContext sc;
                sc.module_sp = module_sp;
                SymbolContextList &sc_list = *sb_sc_list;
                for (size_t i=0; i<num_matches; ++i)
                {
                    sc.symbol = symtab->SymbolAtIndex (matching_symbol_indexes[i]);
                    if (sc.symbol)
                        sc_list.Append(sc);
                }
            }
        }
    }
    return sb_sc_list;
    
}
开发者ID:wiltonlazary,项目名称:swift-lldb,代码行数:29,代码来源:SBModule.cpp

示例4: check

  virtual bool check(SpPoint* pt) {
    PatchFunction* f = sp::Callee(pt);
    if (!f) return false;

    sp_print("StackArrayChecker");
    // getAllVariables
    PatchObject* obj = pt->obj();
    using namespace Dyninst::ParseAPI;
    using namespace Dyninst::SymtabAPI;
    SymtabCodeSource* cs = static_cast<SymtabCodeSource*>(obj->co()->cs());
    Symtab* sym = cs->getSymtabObject();
    std::vector<Symbol*> symbols;

    std::vector<SymtabAPI::Function*> funcs;
    sym->getAllFunctions(funcs);

    for (unsigned i = 0; i < funcs.size(); i ++) {
      if (funcs[i]->getOffset() == f->addr()) {

        std::vector<localVar*> vars;
        funcs[i]->getLocalVariables(vars);

        for (unsigned j = 0; j < vars.size(); j ++) {
          typeArray* t = vars[j]->getType()->getArrayType();
          if (!t) continue;
          sp_print("%s: [%lx, %lx]", vars[j]->getName().c_str(), t->getLow(), t->getHigh());
        }
      }
    }
		return true;
  }
开发者ID:dyninst,项目名称:spi,代码行数:31,代码来源:MyAgent.C

示例5: scoped_timer

size_t
Module::FindSymbolsWithNameAndType (const ConstString &name, SymbolType symbol_type, SymbolContextList &sc_list)
{
    // No need to protect this call using m_mutex all other method calls are
    // already thread safe.


    Timer scoped_timer(__PRETTY_FUNCTION__,
                       "Module::FindSymbolsWithNameAndType (name = %s, type = %i)",
                       name.AsCString(),
                       symbol_type);
    const size_t initial_size = sc_list.GetSize();
    ObjectFile *objfile = GetObjectFile ();
    if (objfile)
    {
        Symtab *symtab = objfile->GetSymtab();
        if (symtab)
        {
            std::vector<uint32_t> symbol_indexes;
            symtab->FindAllSymbolsWithNameAndType (name, symbol_type, symbol_indexes);
            SymbolIndicesToSymbolContextList (symtab, symbol_indexes, sc_list);
        }
    }
    return sc_list.GetSize() - initial_size;
}
开发者ID:eightcien,项目名称:lldb,代码行数:25,代码来源:Module.cpp

示例6: createMemoryBackingStore

bool BinaryEdit::createMemoryBackingStore(mapped_object *obj) {
    // We want to create a buffer for every section in the
    // binary so that we can store updates.

    Symtab *symObj = obj->parse_img()->getObject();
    vector<Region*> regs;
    symObj->getAllRegions(regs);

   for (unsigned i = 0; i < regs.size(); i++) {
      memoryTracker *newTracker = NULL;
      if (regs[i]->getRegionType() == Region::RT_BSS || (regs[i]->getMemSize() == 0))
      {
         continue;
      }
      else {
         newTracker = new memoryTracker(regs[i]->getMemOffset(),
                                        regs[i]->getMemSize(),
                                        regs[i]->getPtrToRawData());
         
      }
      newTracker->alloced = false;
      if (!memoryTracker_)
         memoryTracker_ = new codeRangeTree();
      memoryTracker_->insert(newTracker);
   }

    
   return true;
}
开发者ID:sirmc,项目名称:XnRmor,代码行数:29,代码来源:binaryEdit.C

示例7: getAllDependencies

bool BinaryEdit::getAllDependencies(std::map<std::string, BinaryEdit*>& deps)
{
   Symtab *symtab = mobj->parse_img()->getObject();
   std::deque<std::string> depends;
   depends.insert(depends.end(), symtab->getDependencies().begin(), symtab->getDependencies().end());
   while(!depends.empty())
   {
     std::string lib = depends.front();
     if(deps.find(lib) == deps.end()) {
        std::map<std::string, BinaryEdit*> res;
        if(!openResolvedLibraryName(lib, res)) return false;
         std::map<std::string, BinaryEdit*>::iterator bedit_it;
         for(bedit_it = res.begin(); bedit_it != res.end(); ++bedit_it) {
           if (bedit_it->second) {
             deps.insert(*bedit_it);
             if(!bedit_it->second->getAllDependencies(deps))
             {
               return false;
             }
           } else {
             return false;
           }
         }
     }
     depends.pop_front();
   }
   return true;
}
开发者ID:sirmc,项目名称:XnRmor,代码行数:28,代码来源:binaryEdit.C

示例8: module_sp

SBSymbol SBModule::GetSymbolAtIndex(size_t idx) {
  SBSymbol sb_symbol;
  ModuleSP module_sp(GetSP());
  Symtab *symtab = GetUnifiedSymbolTable(module_sp);
  if (symtab)
    sb_symbol.SetSymbol(symtab->SymbolAtIndex(idx));
  return sb_symbol;
}
开发者ID:krytarowski,项目名称:lldb,代码行数:8,代码来源:SBModule.cpp

示例9: set_start_addr

void DICFG::parse_all(void)
{
	BPatch_addressSpace *handle = cfg_handle;
	SymtabCodeSource *sts = cfg_sts;
	CodeObject *co = cfg_co;

	// Parse the binary 
	co->parse(); 

	/* Parse the functions found by the BPatch API */
	BPatch_image *image = handle->getImage();
	std::vector<BPatch_module *> *mods = image->getModules();
	std::vector<BPatch_module *>::iterator mods_iter; 
	for (mods_iter = mods->begin(); mods_iter != mods->end(); mods_iter++) {
		address_t mod_start = (address_t)(*mods_iter)->getBaseAddr();
		address_t mod_end   = (address_t)(*mods_iter)->getBaseAddr() + (*mods_iter)->getSize();
		if((get_start_addr() == 0) || (mod_start < get_start_addr())) {
			set_start_addr(mod_start);
		}
		if((get_end_addr() == 0) || (mod_end > get_end_addr())) {
			set_end_addr(mod_end);
		}

		std::vector<BPatch_function *> *funcs = (*mods_iter)->getProcedures(false); 
		std::vector<BPatch_function *>::iterator funcs_iter = funcs->begin();
		for(; funcs_iter != funcs->end(); funcs_iter++) {
			co->parse((Address)(*funcs_iter)->getBaseAddr(), true);
		} 
	}

	/* Parse PLT entries */
	Symtab *symtab	= Symtab::findOpenSymtab(string((char *) this->get_module_name().c_str()));
	vector<SymtabAPI::relocationEntry> fbt;
	vector<SymtabAPI::relocationEntry>::iterator fbt_iter;
	symtab->getFuncBindingTable(fbt);

	for (fbt_iter = fbt.begin(); fbt_iter != fbt.end(); fbt_iter++) {
		co->parse((Address)((*fbt_iter).target_addr()), true);
	}

	const CodeObject::funclist& funcs = co->funcs();
	
	insert_functions_and_bbs(funcs);		
	for (fbt_iter = fbt.begin(); fbt_iter != fbt.end(); fbt_iter++) {
		address_t plt_fun_addr = (address_t)(*fbt_iter).target_addr();

		if((get_start_addr() == 0) || (plt_fun_addr < get_start_addr())) {
			set_start_addr(plt_fun_addr);
		}
		if((get_end_addr() == 0) || (plt_fun_addr > get_end_addr())) {
			set_end_addr(plt_fun_addr);
		}

		mark_function_as_plt(plt_fun_addr);
	}
}
开发者ID:aiaxun,项目名称:patharmor,代码行数:56,代码来源:arms_dyninst_cfg.c

示例10:

void
SymtabAPISymbols::getDepenentLibs(const std::string& objname,
	   std::vector<std::string>& dependencies)
{
    Symtab *symtab;
    bool err = Symtab::openFile(symtab, objname);
    if (symtab) {
	dependencies = symtab->getDependencies();
    }
}
开发者ID:OpenSpeedShop,项目名称:cbtf-krell,代码行数:10,代码来源:SymtabAPISymbols.cpp

示例11: locker

uint32_t
Module::ResolveSymbolContextForAddress (const Address& so_addr, uint32_t resolve_scope, SymbolContext& sc)
{
    Mutex::Locker locker (m_mutex);
    uint32_t resolved_flags = 0;

    // Clear the result symbol context in case we don't find anything
    sc.Clear();

    // Get the section from the section/offset address.
    const Section *section = so_addr.GetSection();

    // Make sure the section matches this module before we try and match anything
    if (section && section->GetModule() == this)
    {
        // If the section offset based address resolved itself, then this
        // is the right module.
        sc.module_sp = GetSP();
        resolved_flags |= eSymbolContextModule;

        // Resolve the compile unit, function, block, line table or line
        // entry if requested.
        if (resolve_scope & eSymbolContextCompUnit    ||
            resolve_scope & eSymbolContextFunction    ||
            resolve_scope & eSymbolContextBlock       ||
            resolve_scope & eSymbolContextLineEntry   )
        {
            SymbolVendor *symbols = GetSymbolVendor ();
            if (symbols)
                resolved_flags |= symbols->ResolveSymbolContext (so_addr, resolve_scope, sc);
        }

        // Resolve the symbol if requested, but don't re-look it up if we've already found it.
        if (resolve_scope & eSymbolContextSymbol && !(resolved_flags & eSymbolContextSymbol))
        {
            ObjectFile* ofile = GetObjectFile();
            if (ofile)
            {
                Symtab *symtab = ofile->GetSymtab();
                if (symtab)
                {
                    if (so_addr.IsSectionOffset())
                    {
                        sc.symbol = symtab->FindSymbolContainingFileAddress(so_addr.GetFileAddress());
                        if (sc.symbol)
                            resolved_flags |= eSymbolContextSymbol;
                    }
                }
            }
        }
    }
    return resolved_flags;
}
开发者ID:eightcien,项目名称:lldb,代码行数:53,代码来源:Module.cpp

示例12: writeModuleVariable

DysectErrorCode Backend::writeModuleVariable(Dyninst::ProcControlAPI::Process::ptr process, std::string variableName, std::string libraryPath, void *value, int size) {
  bool result, found = false;
  string libraryName;
  Symtab *symtab = NULL;
  Offset varOffset;
  Address loadAddress;
  vector<SymtabAPI::Variable *> variables;
  LibraryPool::iterator libsIter;

  if (symtabs.find(libraryPath) == symtabs.end()) {
    result = Symtab::openFile(symtab, libraryPath.c_str());
    if (result == false) {
      DYSECTWARN(false, "Failed to find file %s for symtab", libraryPath.c_str());
      return Error;
    }
  }
  else {
    symtab = symtabs[libraryPath];
  }

  result = symtab->findVariablesByName(variables, variableName);
  if (result == false || variables.size() < 1) {
    DYSECTWARN(false, "Failed to find %s variable", variableName.c_str());
    return Error;
  }
  varOffset = variables[0]->getOffset();
  DYSECTLOG(true, "found %s at offset 0x%lx", variableName.c_str(), varOffset);

  libraryName = basename(libraryPath.c_str());
  LibraryPool &libs = process->libraries();
  for (libsIter = libs.begin(); libsIter != libs.end(); libsIter++)
  {
      Library::ptr libraryPtr = *libsIter;
      if (libraryPtr->getName().find(libraryName) == string::npos)
          continue;

      loadAddress = (*libsIter)->getLoadAddress();
      found = true;
      DYSECTLOG(true, "found library %s at 0x%lx", libraryName.c_str(), loadAddress);
      break;
  }
  if (found == false) {
    DYSECTWARN(false, "Failed to find library %s", libraryName.c_str());
    return Error;
  }

  process->writeMemory(loadAddress + varOffset, value, size);

  return OK;
}
开发者ID:SteveXiSong,项目名称:STAT,代码行数:50,代码来源:backend.cpp

示例13: visit

void ByteCodeBackend::visit(IR_ProgNode* node)
{
    Symtab* top = node->symtab()->top();
    for (auto it = top->begin(); it != top->end(); ++it)
    {
        if (it->which() == Symbol::Const)
        {
            if (!m_blob.addConstant(it->data().classid(), it->data().serialize()))
                M_error(node, "internal error: unable to add constant entry to blob");
        }
    }

    // Generate bytecode for the whole program
    node->siblings()[0]->accept(this);
}
开发者ID:monti-tls,项目名称:Axolotl,代码行数:15,代码来源:bytecode_backend.cpp

示例14: getMappedObject

bool BinaryEdit::needsPIC()
{
   Symtab *symtab = getMappedObject()->parse_img()->getObject();
   assert(symtab);
   if(getMappedObject()->fileName().find("lib") == 0)
   {
       if(getMappedObject()->fileName().find(".so") != std::string::npos)
       {
           return true;
       }
   }
   //If there is a fixed load address, then we can calculate 
   // absolute addresses.
   return (symtab->getLoadAddress() == 0);  
}
开发者ID:sirmc,项目名称:XnRmor,代码行数:15,代码来源:binaryEdit.C

示例15: module_sp

void SymbolVendor::SectionFileAddressesChanged() {
  ModuleSP module_sp(GetModule());
  if (module_sp) {
    ObjectFile *module_objfile = module_sp->GetObjectFile();
    if (m_sym_file_ap.get()) {
      ObjectFile *symfile_objfile = m_sym_file_ap->GetObjectFile();
      if (symfile_objfile != module_objfile)
        symfile_objfile->SectionFileAddressesChanged();
    }
    Symtab *symtab = GetSymtab();
    if (symtab) {
      symtab->SectionFileAddressesChanged();
    }
  }
}
开发者ID:linux-on-ibm-z,项目名称:swift-lldb,代码行数:15,代码来源:SymbolVendor.cpp


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