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


C++ ModuleSP::GetObjectName方法代码示例

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


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

示例1: scoped_timer

ObjectFileSP
ObjectFile::FindPlugin (const lldb::ModuleSP &module_sp,
                        const FileSpec* file,
                        lldb::offset_t file_offset,
                        lldb::offset_t file_size,
                        DataBufferSP &data_sp,
                        lldb::offset_t &data_offset)
{
    ObjectFileSP object_file_sp;

    if (module_sp)
    {
        Timer scoped_timer (__PRETTY_FUNCTION__,
                            "ObjectFile::FindPlugin (module = %s, file = %p, file_offset = 0x%8.8" PRIx64 ", file_size = 0x%8.8" PRIx64 ")",
                            module_sp->GetFileSpec().GetPath().c_str(),
                            file, (uint64_t) file_offset, (uint64_t) file_size);
        if (file)
        {
            FileSpec archive_file;
            ObjectContainerCreateInstance create_object_container_callback;

            const bool file_exists = file->Exists();
            if (!data_sp)
            {
                // We have an object name which most likely means we have
                // a .o file in a static archive (.a file). Try and see if
                // we have a cached archive first without reading any data
                // first
                if (file_exists && module_sp->GetObjectName())
                {
                    for (uint32_t idx = 0; (create_object_container_callback = PluginManager::GetObjectContainerCreateCallbackAtIndex(idx)) != NULL; ++idx)
                    {
                        std::unique_ptr<ObjectContainer> object_container_ap(create_object_container_callback(module_sp, data_sp, data_offset, file, file_offset, file_size));
                        
                        if (object_container_ap.get())
                            object_file_sp = object_container_ap->GetObjectFile(file);
                        
                        if (object_file_sp.get())
                            return object_file_sp;
                    }
                }
                // Ok, we didn't find any containers that have a named object, now
                // lets read the first 512 bytes from the file so the object file
                // and object container plug-ins can use these bytes to see if they
                // can parse this file.
                if (file_size > 0)
                {
                    data_sp = file->ReadFileContents(file_offset, std::min<size_t>(512, file_size));
                    data_offset = 0;
                }
            }

            if (!data_sp || data_sp->GetByteSize() == 0)
            {
                // Check for archive file with format "/path/to/archive.a(object.o)"
                char path_with_object[PATH_MAX*2];
                module_sp->GetFileSpec().GetPath(path_with_object, sizeof(path_with_object));

                ConstString archive_object;
                const bool must_exist = true;
                if (ObjectFile::SplitArchivePathWithObject (path_with_object, archive_file, archive_object, must_exist))
                {
                    file_size = archive_file.GetByteSize();
                    if (file_size > 0)
                    {
                        file = &archive_file;
                        module_sp->SetFileSpecAndObjectName (archive_file, archive_object);
                        // Check if this is a object container by iterating through all object
                        // container plugin instances and then trying to get an object file
                        // from the container plugins since we had a name. Also, don't read
                        // ANY data in case there is data cached in the container plug-ins
                        // (like BSD archives caching the contained objects within an file).
                        for (uint32_t idx = 0; (create_object_container_callback = PluginManager::GetObjectContainerCreateCallbackAtIndex(idx)) != NULL; ++idx)
                        {
                            std::unique_ptr<ObjectContainer> object_container_ap(create_object_container_callback(module_sp, data_sp, data_offset, file, file_offset, file_size));
                            
                            if (object_container_ap.get())
                                object_file_sp = object_container_ap->GetObjectFile(file);
                            
                            if (object_file_sp.get())
                                return object_file_sp;
                        }
                        // We failed to find any cached object files in the container
                        // plug-ins, so lets read the first 512 bytes and try again below...
                        data_sp = archive_file.ReadFileContents(file_offset, 512);
                    }
                }
            }

            if (data_sp && data_sp->GetByteSize() > 0)
            {
                // Check if this is a normal object file by iterating through
                // all object file plugin instances.
                ObjectFileCreateInstance create_object_file_callback;
                for (uint32_t idx = 0; (create_object_file_callback = PluginManager::GetObjectFileCreateCallbackAtIndex(idx)) != NULL; ++idx)
                {
                    object_file_sp.reset (create_object_file_callback(module_sp, data_sp, data_offset, file, file_offset, file_size));
                    if (object_file_sp.get())
                        return object_file_sp;
                }
//.........这里部分代码省略.........
开发者ID:,项目名称:,代码行数:101,代码来源:


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