/*
 * BPatch_addressSpace::isStaticExecutable
 *
 * Returns true if the underlying image represents a statically-linked executable, false otherwise.
 */
bool BPatch_addressSpace::isStaticExecutable() {
   std::vector<AddressSpace *> as;
   getAS(as);

   if( !as.size() ) return false;

   AddressSpace *aout = as[0];
   return aout->getAOut()->isStaticExec();
}
Exemple #2
0
void read_element(AddressSpace const& as,
  void* local, remote_ptr<s_xbt_dynar_t> addr, size_t i, size_t len)
{
  s_xbt_dynar_t d;
  as.read_bytes(&d, sizeof(d), addr);
  if (i >= d.used)
    xbt_die("Out of bound index %zi/%lu", i, d.used);
  if (len != d.elmsize)
    xbt_die("Bad size in simgrid::mc::read_element");
  as.read_bytes(local, len, remote(xbt_dynar_get_ptr(&d, i)));
}
Exemple #3
0
Matrox::Matrox()
{
    fCard = PCIInterface::QueryDevice(CLASS_VIDEO, 0);
    if (fCard == 0) {
        printf("Couldn't find video card.\n");
        return;
    }

    AddressSpace *space = AddressSpace::GetKernelAddressSpace();
    fControlArea = (unsigned*) space->MapPhysicalMemory("Matrox Control Aperature",
                   fCard->ReadConfig(0x10) & ~(PAGE_SIZE - 1), 0x4000, SYSTEM_WRITE | SYSTEM_READ)
                   ->GetBaseAddress();
    fFrameBuffer = (char*) space->MapPhysicalMemory("Matrox Frame Buffer",
                   fCard->ReadConfig(0x14) & ~(PAGE_SIZE - 1), 0x400000, USER_READ |
                   USER_WRITE | SYSTEM_READ | SYSTEM_WRITE)->GetBaseAddress();
}
/** @brief Take a per-page snapshot of a region
 *
 *  @param data            The start of the region (must be at the beginning of a page)
 *  @param pag_count       Number of pages of the region
 *  @return                Snapshot page numbers of this new snapshot
 */
PerPageCopy::PerPageCopy(PageStore& store, AddressSpace& as,
    remote_ptr<void> addr, std::size_t page_count)
{
  store_ = &store;
  this->pagenos_.resize(page_count);
  std::vector<char> buffer(xbt_pagesize);

  for (size_t i = 0; i != page_count; ++i) {

      remote_ptr<void> page = remote(addr.address() + (i << xbt_pagebits));
      xbt_assert(mc_page_offset((void*)page.address())==0,
        "Not at the beginning of a page");

        /* Adding another copy (and a syscall) will probably slow things a lot.
           TODO, optimize this somehow (at least by grouping the syscalls)
           if needed. Either:
            - reduce the number of syscalls;
            - let the application snapshot itself;
            - move the segments in shared memory (this will break `fork` however).
        */

        as.read_bytes(
          buffer.data(), xbt_pagesize, page,
          simgrid::mc::ProcessIndexDisabled);

      pagenos_[i] = store_->store_page(buffer.data());

  }
}
Exemple #5
0
std::size_t read_length(AddressSpace const& as, remote_ptr<s_xbt_dynar_t> addr)
{
  if (!addr)
    return 0;
  unsigned long res;
  as.read_bytes(&res, sizeof(res),
    remote(&((xbt_dynar_t)addr.address())->used));
  return res;
}