本文整理汇总了C++中ModuleList类的典型用法代码示例。如果您正苦于以下问题:C++ ModuleList类的具体用法?C++ ModuleList怎么用?C++ ModuleList使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ModuleList类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: fprintf
void C2Builder::generateOptionalIR() {
if (options.checkOnly) return;
if (!options.generateIR && !recipe.generateIR) return;
bool single_module = false;
for (unsigned i=0; i<recipe.genConfigs.size(); i++) {
const std::string& conf = recipe.genConfigs[i];
// TODO just pass struct with bools?
if (conf == "single-module") single_module = true;
else {
fprintf(stderr, ANSI_RED"invalid code generation argument '%s'" ANSI_NORMAL"\n", conf.c_str());
}
}
std::string outdir = OUTPUT_DIR + recipe.name + BUILD_DIR;
// TODO move all this to some generic Codegen class
// Q: use single context or one-per-module?
llvm::LLVMContext context;
const ModuleList& mods = mainComponent->getModules();
if (single_module) {
uint64_t t1 = Utils::getCurrentTime();
std::string filename = recipe.name;
if (options.verbose) log(COL_VERBOSE, "generating IR for single module %s", filename.c_str());
CodeGenModule cgm(filename, true, mods, context);
cgm.generate();
uint64_t t2 = Utils::getCurrentTime();
if (options.printTiming) log(COL_TIME, "IR generation took %" PRIu64" usec", t2 - t1);
if (options.printIR) cgm.dump();
bool ok = cgm.verify();
if (ok) cgm.write(outdir, filename);
} else {
for (unsigned m=0; m<mods.size(); m++) {
Module* M = mods[m];
uint64_t t1 = Utils::getCurrentTime();
if (M->isPlainC()) continue;
if (M->getName() == "c2") continue;
if (options.verbose) log(COL_VERBOSE, "generating IR for module %s", M->getName().c_str());
ModuleList single;
single.push_back(M);
CodeGenModule cgm(M->getName(), false, single, context);
cgm.generate();
uint64_t t2 = Utils::getCurrentTime();
if (options.printTiming) log(COL_TIME, "IR generation took %" PRIu64" usec", t2 - t1);
if (options.printIR) cgm.dump();
bool ok = cgm.verify();
if (ok) cgm.write(outdir, M->getName());
}
}
}
示例2: baseclass_guard
// Assume that dyld is in memory at ADDR and try to parse it's load commands
bool DynamicLoaderMacOSXDYLD::ReadDYLDInfoFromMemoryAndSetNotificationCallback(
lldb::addr_t addr) {
std::lock_guard<std::recursive_mutex> baseclass_guard(GetMutex());
DataExtractor data; // Load command data
static ConstString g_dyld_all_image_infos("dyld_all_image_infos");
if (ReadMachHeader(addr, &m_dyld.header, &data)) {
if (m_dyld.header.filetype == llvm::MachO::MH_DYLINKER) {
m_dyld.address = addr;
ModuleSP dyld_module_sp;
if (ParseLoadCommands(data, m_dyld, &m_dyld.file_spec)) {
if (m_dyld.file_spec) {
UpdateDYLDImageInfoFromNewImageInfo(m_dyld);
}
}
dyld_module_sp = GetDYLDModule();
Target &target = m_process->GetTarget();
if (m_dyld_all_image_infos_addr == LLDB_INVALID_ADDRESS &&
dyld_module_sp.get()) {
const Symbol *symbol = dyld_module_sp->FindFirstSymbolWithNameAndType(
g_dyld_all_image_infos, eSymbolTypeData);
if (symbol)
m_dyld_all_image_infos_addr = symbol->GetLoadAddress(&target);
}
// Update all image infos
InitializeFromAllImageInfos();
// If we didn't have an executable before, but now we do, then the dyld
// module shared pointer might be unique and we may need to add it again
// (since Target::SetExecutableModule() will clear the images). So append
// the dyld module back to the list if it is
/// unique!
if (dyld_module_sp) {
target.GetImages().AppendIfNeeded(dyld_module_sp);
// At this point we should have read in dyld's module, and so we should
// set breakpoints in it:
ModuleList modules;
modules.Append(dyld_module_sp);
target.ModulesDidLoad(modules);
SetDYLDModule(dyld_module_sp);
}
return true;
}
}
return false;
}
示例3: locker
size_t
ModuleList::FindModules (const ModuleSpec &module_spec, ModuleList& matching_module_list) const
{
size_t existing_matches = matching_module_list.GetSize();
Mutex::Locker locker(m_modules_mutex);
collection::const_iterator pos, end = m_modules.end();
for (pos = m_modules.begin(); pos != end; ++pos)
{
ModuleSP module_sp(*pos);
if (module_sp->MatchesModuleSpec (module_spec))
matching_module_list.Append(module_sp);
}
return matching_module_list.GetSize() - existing_matches;
}
示例4: findDefaultModulesFolder
File EnabledModuleList::findDefaultModulesFolder (Project& project)
{
ModuleList available;
available.scanAllKnownFolders (project);
for (int i = available.modules.size(); --i >= 0;)
{
File f (available.modules.getUnchecked(i)->getFolder());
if (f.isDirectory())
return f.getParentDirectory();
}
return File::getCurrentWorkingDirectory();
}
示例5: GetEigenvalue
bool CSecurityCache::GetEigenvalue(ModuleList& mlist)
{
mlist.clear();
for(int i = 0; i < SECURE_BUCKET_SIZE; i++)
{
for(list<SecCachStruct*>::iterator ite = m_secuBucket[i].begin(); ite != m_secuBucket[i].end(); ite ++)
{
if(((*ite)->tag == 1) || (*ite)->tag == 3 || (*ite)->tag == 4)//有效数据
{
ModuleItem item;
memcpy(item.md,(void*)(*ite)->chkdata,SECURE_SIZE);
mlist.push_back(item);
}
}
}
return true;
}
示例6: makeGen
void CGenerator::generate() {
std::string outdir = options.outputDir + targetName + options.buildDir;
MakefileGenerator makeGen(outdir, targetName, targetType);
if (options.single_module) {
makeGen.add(targetName);
CCodeGenerator gen(targetName, CCodeGenerator::SINGLE_FILE, moduleMap, mods, includeNamer);
gen.generate(options.printC, outdir);
} else {
for (unsigned m=0; m<mods.size(); m++) {
Module* M = mods[m];
makeGen.add(M->getName());
ModuleList single;
single.push_back(M);
CCodeGenerator gen(M->getName(), CCodeGenerator::MULTI_FILE, moduleMap, single, includeNamer);
gen.generate(options.printC, outdir);
}
}
for (StringListConstIter iter=libs.begin(); iter!=libs.end(); ++iter) {
makeGen.addLinkerLib(*iter);
}
makeGen.write();
// generate exports.version
if (targetType == GenUtils::SHARED_LIB) {
StringBuilder expmap;
expmap << "LIB_1.0 {\n";
expmap << "\tglobal:\n";
for (unsigned m=0; m<mods.size(); m++) {
const Module* M = mods[m];
const Module::Symbols& syms = M->getSymbols();
for (Module::SymbolsConstIter iter = syms.begin(); iter != syms.end(); ++iter) {
const Decl* D = iter->second;
if (!D->isExported()) continue;
if (!isa<FunctionDecl>(D) && !isa<VarDecl>(D)) continue;
expmap << "\t\t";
GenUtils::addName(M->getName(), iter->first, expmap);
expmap << ";\n";
}
}
expmap << "\tlocal:\n\t\t*;\n";
expmap << "};\n";
std::string outfile = outdir + "exports.version";
FileUtils::writeFile(outdir.c_str(), outfile.c_str(), expmap);
}
}
示例7: warnAboutOldProjucerVersion
void Project::warnAboutOldProjucerVersion()
{
ModuleList available;
available.scanAllKnownFolders (*this);
if (isAnyModuleNewerThanProjucer (available.modules))
{
if (ProjucerApplication::getApp().isRunningCommandLine)
std::cout << "WARNING! This version of the Projucer is out-of-date!" << std::endl;
else
AlertWindow::showMessageBoxAsync (AlertWindow::WarningIcon,
"Projucer",
"This version of the Projucer is out-of-date!"
"\n\n"
"Always make sure that you're running the very latest version, "
"preferably compiled directly from the JUCE repository that you're working with!");
}
}
示例8: locker
void
AppleObjCRuntime::ReadObjCLibraryIfNeeded (const ModuleList &module_list)
{
if (!HasReadObjCLibrary ())
{
Mutex::Locker locker (module_list.GetMutex ());
size_t num_modules = module_list.GetSize();
for (size_t i = 0; i < num_modules; i++)
{
auto mod = module_list.GetModuleAtIndex (i);
if (IsModuleObjCLibrary (mod))
{
ReadObjCLibrary (mod);
break;
}
}
}
}
示例9: findGlobalModulesFolder
File EnabledModuleList::findDefaultModulesFolder (Project& project)
{
auto globalPath = findGlobalModulesFolder();
if (globalPath != File())
return globalPath;
ModuleList available;
available.scanProjectExporterModulePaths (project);
for (int i = available.modules.size(); --i >= 0;)
{
File f (available.modules.getUnchecked(i)->getFolder());
if (f.isDirectory())
return f.getParentDirectory();
}
return File::getCurrentWorkingDirectory();
}
示例10: lock
void Host::ScanInvalidModuleFiles()
{
ScopedLock lock(&moduleMutex);
this->autoScan = false; // Do not recursively scan
ModuleList modulesLoaded; // Track loaded modules
std::vector<std::string>::iterator iter;
iter = this->invalid_module_files.begin();
while (iter != this->invalid_module_files.end())
{
std::string path = *iter;
ModuleProvider *provider = FindModuleProvider(path);
if (provider != NULL)
{
SharedPtr<Module> m = this->LoadModule(path, provider);
// Module was loaded successfully
if (!m.isNull())
modulesLoaded.push_back(m);
// Erase path, even on failure
iter = invalid_module_files.erase(iter);
}
else
{
iter++;
}
}
if (modulesLoaded.size() > 0)
{
this->StartModules(modulesLoaded);
/* If any of the invalid module files added
* a ModuleProvider, let them load their modules */
this->ScanInvalidModuleFiles();
}
this->autoScan = true;
}
示例11: SearchInModuleList
void SearchFilter::SearchInModuleList(Searcher &searcher, ModuleList &modules) {
SymbolContext empty_sc;
if (!m_target_sp)
return;
empty_sc.target_sp = m_target_sp;
if (searcher.GetDepth() == lldb::eSearchDepthTarget)
searcher.SearchCallback(*this, empty_sc, nullptr, false);
else {
std::lock_guard<std::recursive_mutex> guard(modules.GetMutex());
const size_t numModules = modules.GetSize();
for (size_t i = 0; i < numModules; i++) {
ModuleSP module_sp(modules.GetModuleAtIndexUnlocked(i));
if (ModulePasses(module_sp)) {
if (DoModuleIteration(module_sp, searcher) ==
Searcher::eCallbackReturnStop)
return;
}
}
}
}
示例12: GetSymbolAddress
addr_t JITLoaderGDB::GetSymbolAddress(ModuleList &module_list,
const ConstString &name,
SymbolType symbol_type) const {
SymbolContextList target_symbols;
Target &target = m_process->GetTarget();
if (!module_list.FindSymbolsWithNameAndType(name, symbol_type,
target_symbols))
return LLDB_INVALID_ADDRESS;
SymbolContext sym_ctx;
target_symbols.GetContextAtIndex(0, sym_ctx);
const Address jit_descriptor_addr = sym_ctx.symbol->GetAddress();
if (!jit_descriptor_addr.IsValid())
return LLDB_INVALID_ADDRESS;
const addr_t jit_addr = jit_descriptor_addr.GetLoadAddress(&target);
return jit_addr;
}
示例13: addModuleInteractive
void EnabledModuleList::addModuleInteractive (const String& moduleID)
{
ModuleList list;
list.scanGlobalJuceModulePath();
if (auto* info = list.getModuleWithID (moduleID))
{
addModule (info->moduleFolder, areMostModulesCopiedLocally(), areMostModulesUsingGlobalPath());
return;
}
list.scanGlobalUserModulePath();
if (auto* info = list.getModuleWithID (moduleID))
{
addModule (info->moduleFolder, areMostModulesCopiedLocally(), areMostModulesUsingGlobalPath());
return;
}
list.scanProjectExporterModulePaths (project);
if (auto* info = list.getModuleWithID (moduleID))
addModule (info->moduleFolder, areMostModulesCopiedLocally(), false);
else
addModuleFromUserSelectedFile();
}
示例14: fillModuleListPSAPI
//*************************************************************************
// Method: fillModuleListPSAPI
// Description: support function
//
//*************************************************************************
bool StackWalker::fillModuleListPSAPI( ModuleList& modules, DWORD pid, HANDLE hProcess )
{
// EnumProcessModules()
typedef BOOL (__stdcall *tEPM)( HANDLE hProcess, HMODULE *lphModule, DWORD cb, LPDWORD lpcbNeeded );
// GetModuleFileNameEx()
typedef DWORD (__stdcall *tGMFNE)( HANDLE hProcess, HMODULE hModule, LPSTR lpFilename, DWORD nSize );
// GetModuleBaseName() -- redundant, as GMFNE() has the same prototype, but who cares?
typedef DWORD (__stdcall *tGMBN)( HANDLE hProcess, HMODULE hModule, LPSTR lpFilename, DWORD nSize );
// GetModuleInformation()
typedef BOOL (__stdcall *tGMI)( HANDLE hProcess, HMODULE hModule, LPMODULEINFO pmi, DWORD nSize );
HINSTANCE hPsapi;
tEPM pEPM;
tGMFNE pGMFNE;
tGMBN pGMBN;
tGMI pGMI;
int i;
ModuleEntry e;
DWORD cbNeeded;
MODULEINFO mi;
HMODULE *hMods = 0;
char *tt = 0;
hPsapi = LoadLibrary( "psapi.dll" );
if ( hPsapi == 0 )
return false;
modules.clear();
pEPM = (tEPM) GetProcAddress( hPsapi, "EnumProcessModules" );
pGMFNE = (tGMFNE) GetProcAddress( hPsapi, "GetModuleFileNameExA" );
pGMBN = (tGMFNE) GetProcAddress( hPsapi, "GetModuleBaseNameA" );
pGMI = (tGMI) GetProcAddress( hPsapi, "GetModuleInformation" );
if ( pEPM == 0 || pGMFNE == 0 || pGMBN == 0 || pGMI == 0 )
{
// yuck. Some API is missing.
FreeLibrary( hPsapi );
return false;
}
hMods = new HMODULE[TTBUFLEN / sizeof HMODULE];
tt = new char[TTBUFLEN];
// not that this is a sample. Which means I can get away with
// not checking for errors, but you cannot. :)
if ( ! pEPM( hProcess, hMods, TTBUFLEN, &cbNeeded ) )
{
//printf( "EPM failed, GetLastError() = %lu\n", GetLastError() );
goto cleanup;
}
if ( cbNeeded > TTBUFLEN )
{
//printf( "More than %lu module handles. Huh?\n", lenof( hMods ) );
goto cleanup;
}
for ( i = 0; i < cbNeeded / sizeof hMods[0]; ++ i )
{
// for each module, get:
// base address, size
pGMI( hProcess, hMods[i], &mi, sizeof mi );
e.baseAddress = (DWORD) mi.lpBaseOfDll;
e.size = mi.SizeOfImage;
// image file name
tt[0] = '\0';
pGMFNE( hProcess, hMods[i], tt, TTBUFLEN );
e.imageName = tt;
// module name
tt[0] = '\0';
pGMBN( hProcess, hMods[i], tt, TTBUFLEN );
e.moduleName = tt;
/*printf( "%08lXh %6lu %-15.15s %s\n", e.baseAddress,
e.size, e.moduleName.c_str(), e.imageName.c_str() );*/
modules.push_back( e );
}
cleanup:
if ( hPsapi )
FreeLibrary( hPsapi );
delete [] tt;
delete [] hMods;
return modules.size() != 0;
}
示例15: module_sp
void
Breakpoint::ModulesChanged (ModuleList &module_list, bool load)
{
if (load)
{
// The logic for handling new modules is:
// 1) If the filter rejects this module, then skip it.
// 2) Run through the current location list and if there are any locations
// for that module, we mark the module as "seen" and we don't try to re-resolve
// breakpoint locations for that module.
// However, we do add breakpoint sites to these locations if needed.
// 3) If we don't see this module in our breakpoint location list, call ResolveInModules.
ModuleList new_modules; // We'll stuff the "unseen" modules in this list, and then resolve
// them after the locations pass. Have to do it this way because
// resolving breakpoints will add new locations potentially.
const size_t num_locs = m_locations.GetSize();
for (size_t i = 0; i < module_list.GetSize(); i++)
{
bool seen = false;
ModuleSP module_sp (module_list.GetModuleAtIndex (i));
if (!m_filter_sp->ModulePasses (module_sp))
continue;
for (size_t loc_idx = 0; loc_idx < num_locs; loc_idx++)
{
BreakpointLocationSP break_loc = m_locations.GetByIndex(loc_idx);
if (!break_loc->IsEnabled())
continue;
const Section *section = break_loc->GetAddress().GetSection();
if (section == NULL || section->GetModule() == module_sp.get())
{
if (!seen)
seen = true;
if (!break_loc->ResolveBreakpointSite())
{
LogSP log (lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_BREAKPOINTS));
if (log)
log->Printf ("Warning: could not set breakpoint site for breakpoint location %d of breakpoint %d.\n",
break_loc->GetID(), GetID());
}
}
}
if (!seen)
new_modules.AppendIfNeeded (module_sp);
}
if (new_modules.GetSize() > 0)
{
ResolveBreakpointInModules(new_modules);
}
}
else
{
// Go through the currently set locations and if any have breakpoints in
// the module list, then remove their breakpoint sites.
// FIXME: Think about this... Maybe it's better to delete the locations?
// Are we sure that on load-unload-reload the module pointer will remain
// the same? Or do we need to do an equality on modules that is an
// "equivalence"???
for (size_t i = 0; i < module_list.GetSize(); i++)
{
ModuleSP module_sp (module_list.GetModuleAtIndex (i));
if (m_filter_sp->ModulePasses (module_sp))
{
const size_t num_locs = m_locations.GetSize();
for (size_t loc_idx = 0; loc_idx < num_locs; ++loc_idx)
{
BreakpointLocationSP break_loc = m_locations.GetByIndex(loc_idx);
const Section *section = break_loc->GetAddress().GetSection();
if (section && section->GetModule() == module_sp.get())
{
// Remove this breakpoint since the shared library is
// unloaded, but keep the breakpoint location around
// so we always get complete hit count and breakpoint
// lifetime info
break_loc->ClearBreakpointSite();
}
}
}
}
}
}