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


C++ LibraryView::SetCrazy方法代码示例

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


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

示例1: LoadLibrary


//.........这里部分代码省略.........
    LOG("%s: System library %s loaded at %p\n", __FUNCTION__, lib_name, wrap);
    LOG("  name=%s\n", wrap->GetName());
    return wrap;
  }

  ScopedPtr<SharedLibrary> lib(new SharedLibrary());

  // Find the full library path.
  String full_path;

  if (!strchr(lib_name, '/')) {
    LOG("%s: Looking through the search path list\n", __FUNCTION__);
    const char* path = search_path_list->FindFile(lib_name);
    if (!path) {
      error->Format("Can't find library file %s", lib_name);
      return NULL;
    }
    full_path = path;
  } else {
    if (lib_name[0] != '/') {
      // Need to transform this into a full path.
      full_path = GetCurrentDirectory();
      if (full_path.size() && full_path[full_path.size() - 1] != '/')
        full_path += '/';
      full_path += lib_name;
    } else {
      // Absolute path. Easy.
      full_path = lib_name;
    }
    LOG("%s: Full library path: %s\n", __FUNCTION__, full_path.c_str());
    if (!PathIsFile(full_path.c_str())) {
      error->Format("Library file doesn't exist: %s", full_path.c_str());
      return NULL;
    }
  }

  // Load the library
  if (!lib->Load(full_path.c_str(), load_address, file_offset, error))
    return NULL;

  // Load all dependendent libraries.
  LOG("%s: Loading dependencies of %s\n", __FUNCTION__, base_name);
  SharedLibrary::DependencyIterator iter(lib.Get());
  Vector<LibraryView*> dependencies;
  while (iter.GetNext()) {
    Error dep_error;
    LibraryView* dependency = LoadLibrary(iter.GetName(),
                                          dlopen_mode,
                                          0U /* load address */,
                                          0U /* file offset */,
                                          search_path_list,
                                          &dep_error);
    if (!dependency) {
      error->Format("When loading %s: %s", base_name, dep_error.c_str());
      return NULL;
    }
    dependencies.PushBack(dependency);
  }
  if (CRAZY_DEBUG) {
    LOG("%s: Dependencies loaded for %s\n", __FUNCTION__, base_name);
    for (size_t n = 0; n < dependencies.GetCount(); ++n)
      LOG("  ... %p %s\n", dependencies[n], dependencies[n]->GetName());
    LOG("    dependencies @%p\n", &dependencies);
  }

  // Relocate the library.
  LOG("%s: Relocating %s\n", __FUNCTION__, base_name);
  if (!lib->Relocate(this, &dependencies, error))
    return NULL;

  // Notify GDB of load.
  lib->link_map_.l_addr = lib->load_address();
  lib->link_map_.l_name = const_cast<char*>(lib->base_name_);
  lib->link_map_.l_ld = reinterpret_cast<uintptr_t>(lib->view_.dynamic());
  Globals::GetRDebug()->AddEntry(&lib->link_map_);

  // The library was properly loaded, add it to the list of crazy
  // libraries. IMPORTANT: Do this _before_ calling the constructors
  // because these could call dlopen().
  lib->list_next_ = head_;
  lib->list_prev_ = NULL;
  if (head_)
    head_->list_prev_ = lib.Get();
  head_ = lib.Get();

  // Then create a new LibraryView for it.
  wrap = new LibraryView();
  wrap->SetCrazy(lib.Get(), lib_name);
  known_libraries_.PushBack(wrap);

  LOG("%s: Running constructors for %s\n", __FUNCTION__, base_name);

  // Now run the constructors.
  lib->CallConstructors();

  LOG("%s: Done loading %s\n", __FUNCTION__, base_name);
  lib.Release();

  return wrap;
}
开发者ID:,项目名称:,代码行数:101,代码来源:


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