Пример #1
0
static int find_start(jvm_agent_t* J, uint64_t ptr, uint64_t *startp) {
  int err;
  int i;

  for (i = 0; i < J->Number_of_heaps; ++i) {
    *startp = 0;
    if (codeheap_contains(i, J, ptr)) {
      int32_t used;
      uint64_t segment = segment_for(i, J, ptr);
      uint64_t block = J->Heap_segmap_low[i];
      uint8_t tag;
      err = ps_pread(J->P, block + segment, &tag, sizeof(tag));
      CHECK_FAIL(err);
      if (tag == 0xff)
        return PS_OK;
      while (tag > 0) {
        err = ps_pread(J->P, block + segment, &tag, sizeof(tag));
        CHECK_FAIL(err);
        segment -= tag;
      }
      block = block_at(i, J, segment);
      err = ps_pread(J->P, block + OFFSET_HeapBlockHeader_used, &used, sizeof(used));
      CHECK_FAIL(err);
      if (used) {
        *startp = block + SIZE_HeapBlockHeader;
      }
    }
    return PS_OK;
  }

 fail:
  return -1;
}
Пример #2
0
static int find_start(jvm_agent_t* J, uint64_t ptr, uint64_t *startp) {
  int err;

  *startp = 0;
  if (J->CodeCache_low <= ptr && ptr < J->CodeCache_high) {
    int32_t used;
    uint64_t segment = segment_for(J, ptr);
    uint64_t block = J->CodeCache_segmap_low;
    uint8_t tag;
    err = ps_pread(J->P, block + segment, &tag, sizeof(tag));
    CHECK_FAIL(err);
    if (tag == 0xff)
      return PS_OK;
    while (tag > 0) {
      err = ps_pread(J->P, block + segment, &tag, sizeof(tag));
      CHECK_FAIL(err);
      segment -= tag;
    }
    block = block_at(J, segment);
    err = ps_pread(J->P, block + OFFSET_HeapBlockHeader_used, &used, sizeof(used));
    CHECK_FAIL(err);
    if (used) {
      *startp = block + SIZE_HeapBlockHeader;
    }
  }
  return PS_OK;

 fail:
  return -1;
}