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


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

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


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

示例1: log

ObjectFile::ObjectFile (const lldb::ModuleSP &module_sp, 
                        const ProcessSP &process_sp,
                        lldb::addr_t header_addr, 
                        DataBufferSP& header_data_sp) :
    ModuleChild (module_sp),
    m_file (),
    m_type (eTypeInvalid),
    m_strata (eStrataInvalid),
    m_offset (header_addr),
    m_length (0),
    m_data (),
    m_unwind_table (*this),
    m_process_wp (process_sp),
    m_memory_addr (header_addr)
{    
    if (header_data_sp)
        m_data.SetData (header_data_sp, 0, header_data_sp->GetByteSize());
    LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_OBJECT));
    if (log)
    {
        log->Printf ("%p ObjectFile::ObjectFile () module = %s/%s, process = %p, header_addr = 0x%llx\n",
                     this,
                     module_sp->GetFileSpec().GetDirectory().AsCString(),
                     module_sp->GetFileSpec().GetFilename().AsCString(),
                     process_sp.get(),
                     m_offset);
    }
}
开发者ID:,项目名称:,代码行数:28,代码来源:

示例2: scoped_timer

ObjectFileSP
ObjectFile::FindPlugin (const lldb::ModuleSP &module_sp, 
                        const ProcessSP &process_sp,
                        lldb::addr_t header_addr,
                        DataBufferSP &file_data_sp)
{
    ObjectFileSP object_file_sp;
    
    if (module_sp)
    {
        Timer scoped_timer (__PRETTY_FUNCTION__,
                            "ObjectFile::FindPlugin (module = %s/%s, process = %p, header_addr = 0x%llx)",
                            module_sp->GetFileSpec().GetDirectory().AsCString(),
                            module_sp->GetFileSpec().GetFilename().AsCString(),
                            process_sp.get(), header_addr);
        uint32_t idx;
        
        // Check if this is a normal object file by iterating through
        // all object file plugin instances.
        ObjectFileCreateMemoryInstance create_callback;
        for (idx = 0; (create_callback = PluginManager::GetObjectFileCreateMemoryCallbackAtIndex(idx)) != NULL; ++idx)
        {
            object_file_sp.reset (create_callback(module_sp, file_data_sp, process_sp, header_addr));
            if (object_file_sp.get())
                return object_file_sp;
        }
        
    }
    // We didn't find it, so clear our shared pointer in case it
    // contains anything and return an empty shared pointer
    object_file_sp.reset();
    return object_file_sp;
}
开发者ID:,项目名称:,代码行数:33,代码来源:

示例3: FindPlugin

ObjectFileSP ObjectFile::FindPlugin(const lldb::ModuleSP &module_sp,
                                    const ProcessSP &process_sp,
                                    lldb::addr_t header_addr,
                                    DataBufferSP &data_sp) {
  ObjectFileSP object_file_sp;

  if (module_sp) {
    Timer scoped_timer(LLVM_PRETTY_FUNCTION, "ObjectFile::FindPlugin (module = "
                                             "%s, process = %p, header_addr = "
                                             "0x%" PRIx64 ")",
                       module_sp->GetFileSpec().GetPath().c_str(),
                       static_cast<void *>(process_sp.get()), header_addr);
    uint32_t idx;

    // Check if this is a normal object file by iterating through
    // all object file plugin instances.
    ObjectFileCreateMemoryInstance create_callback;
    for (idx = 0;
         (create_callback =
              PluginManager::GetObjectFileCreateMemoryCallbackAtIndex(idx)) !=
         nullptr;
         ++idx) {
      object_file_sp.reset(
          create_callback(module_sp, data_sp, process_sp, header_addr));
      if (object_file_sp.get())
        return object_file_sp;
    }
  }

  // We didn't find it, so clear our shared pointer in case it
  // contains anything and return an empty shared pointer
  object_file_sp.reset();
  return object_file_sp;
}
开发者ID:krytarowski,项目名称:lldb,代码行数:34,代码来源:ObjectFile.cpp

示例4: Error

Error
PlatformAndroid::DownloadSymbolFile (const lldb::ModuleSP& module_sp,
                                     const FileSpec& dst_file_spec)
{
    // For oat file we can try to fetch additional debug info from the device
    if (module_sp->GetFileSpec().GetFileNameExtension() != ConstString("oat"))
        return Error("Symbol file downloading only supported for oat files");

    // If we have no information about the platform file we can't execute oatdump
    if (!module_sp->GetPlatformFileSpec())
        return Error("No platform file specified");

    // Symbolizer isn't available before SDK version 23
    if (GetSdkVersion() < 23)
        return Error("Symbol file generation only supported on SDK 23+");

    // If we already have symtab then we don't have to try and generate one
    if (module_sp->GetSectionList()->FindSectionByName(ConstString(".symtab")) != nullptr)
        return Error("Symtab already available in the module");

    int status = 0;
    std::string tmpdir;
    StreamString command;
    command.Printf("mktemp --directory --tmpdir %s", GetWorkingDirectory().GetCString());
    Error error = RunShellCommand(command.GetData(),
                                  GetWorkingDirectory(),
                                  &status,
                                  nullptr,
                                  &tmpdir,
                                  5 /* timeout (s) */);

    if (error.Fail() || status != 0 || tmpdir.empty())
        return Error("Failed to generate temporary directory on the device (%s)", error.AsCString());
    tmpdir.erase(tmpdir.size() - 1); // Remove trailing new line

    // Create file remover for the temporary directory created on the device
    std::unique_ptr<std::string, std::function<void(std::string*)>> tmpdir_remover(
        &tmpdir,
        [this](std::string* s) {
            StreamString command;
            command.Printf("rm -rf %s", s->c_str());
            Error error = this->RunShellCommand(command.GetData(),
                                                GetWorkingDirectory(),
                                                nullptr,
                                                nullptr,
                                                nullptr,
                                                5 /* timeout (s) */);

            Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_PLATFORM));
            if (error.Fail())
                log->Printf("Failed to remove temp directory: %s", error.AsCString());
        }
    );

    FileSpec symfile_platform_filespec(tmpdir.c_str(), false);
    symfile_platform_filespec.AppendPathComponent("symbolized.oat");

    // Execute oatdump on the remote device to generate a file with symtab
    command.Clear();
    command.Printf("oatdump --symbolize=%s --output=%s",
                   module_sp->GetPlatformFileSpec().GetCString(false),
                   symfile_platform_filespec.GetCString(false));
    error = RunShellCommand(command.GetData(),
                            GetWorkingDirectory(),
                            &status,
                            nullptr,
                            nullptr,
                            60 /* timeout (s) */);
    if (error.Fail() || status != 0)
        return Error("Oatdump failed: %s", error.AsCString());

    // Download the symbolfile from the remote device
    return GetFile(symfile_platform_filespec, dst_file_spec);
}
开发者ID:JuliaLang,项目名称:lldb,代码行数:74,代码来源:PlatformAndroid.cpp

示例5: GetAndPut

Error ModuleCache::GetAndPut(const FileSpec &root_dir_spec,
                             const char *hostname,
                             const ModuleSpec &module_spec,
                             const ModuleDownloader &module_downloader,
                             const SymfileDownloader &symfile_downloader,
                             lldb::ModuleSP &cached_module_sp,
                             bool *did_create_ptr) {
  const auto module_spec_dir =
      GetModuleDirectory(root_dir_spec, module_spec.GetUUID());
  auto error = MakeDirectory(module_spec_dir);
  if (error.Fail())
    return error;

  ModuleLock lock(root_dir_spec, module_spec.GetUUID(), error);
  if (error.Fail())
    return Error("Failed to lock module %s: %s",
                 module_spec.GetUUID().GetAsString().c_str(),
                 error.AsCString());

  const auto escaped_hostname(GetEscapedHostname(hostname));
  // Check local cache for a module.
  error = Get(root_dir_spec, escaped_hostname.c_str(), module_spec,
              cached_module_sp, did_create_ptr);
  if (error.Success())
    return error;

  const auto tmp_download_file_spec = JoinPath(module_spec_dir, kTempFileName);
  error = module_downloader(module_spec, tmp_download_file_spec);
  llvm::FileRemover tmp_file_remover(tmp_download_file_spec.GetPath().c_str());
  if (error.Fail())
    return Error("Failed to download module: %s", error.AsCString());

  // Put downloaded file into local module cache.
  error = Put(root_dir_spec, escaped_hostname.c_str(), module_spec,
              tmp_download_file_spec, module_spec.GetFileSpec());
  if (error.Fail())
    return Error("Failed to put module into cache: %s", error.AsCString());

  tmp_file_remover.releaseFile();
  error = Get(root_dir_spec, escaped_hostname.c_str(), module_spec,
              cached_module_sp, did_create_ptr);
  if (error.Fail())
    return error;

  // Fetching a symbol file for the module
  const auto tmp_download_sym_file_spec =
      JoinPath(module_spec_dir, kTempSymFileName);
  error = symfile_downloader(cached_module_sp, tmp_download_sym_file_spec);
  llvm::FileRemover tmp_symfile_remover(
      tmp_download_sym_file_spec.GetPath().c_str());
  if (error.Fail())
    // Failed to download a symfile but fetching the module was successful. The
    // module might
    // contain the necessary symbols and the debugging is also possible without
    // a symfile.
    return Error();

  error = Put(root_dir_spec, escaped_hostname.c_str(), module_spec,
              tmp_download_sym_file_spec,
              GetSymbolFileSpec(module_spec.GetFileSpec()));
  if (error.Fail())
    return Error("Failed to put symbol file into cache: %s", error.AsCString());

  tmp_symfile_remover.releaseFile();

  FileSpec symfile_spec = GetSymbolFileSpec(cached_module_sp->GetFileSpec());
  cached_module_sp->SetSymbolFileFileSpec(symfile_spec);
  return Error();
}
开发者ID:karwa,项目名称:swift-lldb,代码行数:69,代码来源:ModuleCache.cpp

示例6: lock_file

Error
ModuleCache::GetAndPut (const FileSpec &root_dir_spec,
                        const char *hostname,
                        const ModuleSpec &module_spec,
                        const ModuleDownloader &module_downloader,
                        const SymfileDownloader &symfile_downloader,
                        lldb::ModuleSP &cached_module_sp,
                        bool *did_create_ptr)
{
    const auto module_spec_dir = GetModuleDirectory (root_dir_spec, module_spec.GetUUID ());
    auto error = MakeDirectory (module_spec_dir);
    if (error.Fail ())
        return error;

    // Open lock file.
    const auto lock_file_spec = JoinPath (module_spec_dir, kLockFileName);
    File lock_file (lock_file_spec, File::eOpenOptionWrite | File::eOpenOptionCanCreate | File::eOpenOptionCloseOnExec);
    if (!lock_file)
    {
        error.SetErrorToErrno ();
        return Error("Failed to open lock file %s: %s", lock_file_spec.GetPath ().c_str (), error.AsCString ());
    }
    LockFile lock (lock_file.GetDescriptor ());
    error = lock.WriteLock (0, 1);
    if (error.Fail ())
        return Error("Failed to lock file %s:%s", lock_file_spec.GetPath ().c_str (), error.AsCString ());

    // Check local cache for a module.
    error = Get (root_dir_spec, hostname, module_spec, cached_module_sp, did_create_ptr);
    if (error.Success ())
        return error;

    const auto tmp_download_file_spec = JoinPath (module_spec_dir, kTempFileName);
    error = module_downloader (module_spec, tmp_download_file_spec);
    llvm::FileRemover tmp_file_remover (tmp_download_file_spec.GetPath ().c_str ());
    if (error.Fail ())
        return Error("Failed to download module: %s", error.AsCString ());

    // Put downloaded file into local module cache.
    error = Put (root_dir_spec, hostname, module_spec, tmp_download_file_spec, module_spec.GetFileSpec ());
    if (error.Fail ())
        return Error ("Failed to put module into cache: %s", error.AsCString ());

    tmp_file_remover.releaseFile ();
    error = Get (root_dir_spec, hostname, module_spec, cached_module_sp, did_create_ptr);
    if (error.Fail ())
        return error;

    // Fetching a symbol file for the module
    const auto tmp_download_sym_file_spec = JoinPath (module_spec_dir, kTempSymFileName);
    error = symfile_downloader (cached_module_sp, tmp_download_sym_file_spec);
    llvm::FileRemover tmp_symfile_remover (tmp_download_sym_file_spec.GetPath ().c_str ());
    if (error.Fail ())
        // Failed to download a symfile but fetching the module was successful. The module might
        // contain the neccessary symbols and the debugging is also possible without a symfile.
        return Error ();

    FileSpec symfile_spec = GetSymbolFileSpec (cached_module_sp->GetFileSpec ());
    error = Put (root_dir_spec, hostname, module_spec, tmp_download_sym_file_spec, symfile_spec);
    if (error.Fail ())
        return Error ("Failed to put symbol file into cache: %s", error.AsCString ());
    
    tmp_symfile_remover.releaseFile();

    cached_module_sp->SetSymbolFileFileSpec (symfile_spec);
    return Error ();
}
开发者ID:JuliaLang,项目名称:lldb,代码行数:67,代码来源:ModuleCache.cpp


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