class ExceptionTest : public CommonRuntimeTest { protected: // Since various dexers may differ in bytecode layout, we play // it safe and simply set the dex pc to the start of the method, // which always points to the first source statement. static constexpr const uint32_t kDexPc = 0;
fake_header_code_and_maps_size_ = stack_maps_size + header_size + code_size + code_alignment; // Use mmap to make sure we get untagged memory here. Real code gets allocated using // mspace_memalign which is never tagged.
fake_header_code_and_maps_ = static_cast<uint8_t*>(mmap(nullptr,
fake_header_code_and_maps_size_,
PROT_READ | PROT_WRITE,
MAP_PRIVATE | MAP_ANONYMOUS,
-1, 0));
uint8_t* code_ptr =
AlignUp(&fake_header_code_and_maps_[stack_maps_size + header_size], code_alignment);
if (kRuntimeISA == InstructionSet::kArm) { // Check that the Thumb2 adjustment will be a NOP, see EntryPointToCodePointer().
CHECK_ALIGNED(code_ptr, 2);
}
// Create the stack frame for the callee save method, expected by the runtime.
fake_stack.push_back(reinterpret_cast<uintptr_t>(save_method)); for (size_t i = 0; i < frame_info.FrameSizeInBytes() - 2 * sizeof(uintptr_t);
i += sizeof(uintptr_t)) {
fake_stack.push_back(0);
}
OatQuickMethodHeader* header = OatQuickMethodHeader::FromEntryPoint(
method_g_->GetEntryPointFromQuickCompiledCode()); // Untag native pc when running with hwasan since the pcs on the stack aren't tagged and we use // this to create a fake stack. See OatQuickMethodHeader::Contains where we untag code pointers // before comparing it with the PC from the stack.
uintptr_t native_pc = header->ToNativeQuickPc(method_g_, kDexPc); if (android::base::running_with_hwasan()) { // TODO(228989263): Use HWASanUntag once we have a hwasan target for tests too. HWASanUntag // uses static checks which won't work if we don't have a dedicated target.
native_pc = (native_pc & ((1ULL << 56) - 1));
}
fake_stack.push_back(native_pc); // return pc
// Create/push fake 16byte stack frame for method g
fake_stack.push_back(reinterpret_cast<uintptr_t>(method_g_));
fake_stack.push_back(0);
fake_stack.push_back(0);
fake_stack.push_back(native_pc); // return pc.
// Create/push fake 16byte stack frame for method f
fake_stack.push_back(reinterpret_cast<uintptr_t>(method_f_));
fake_stack.push_back(0);
fake_stack.push_back(0);
fake_stack.push_back(0xEBAD6070); // return pc
// Push Method* of null to terminate the trace
fake_stack.push_back(0);
// Push null values which will become null incoming arguments.
fake_stack.push_back(0);
fake_stack.push_back(0);
fake_stack.push_back(0);
// Set up thread to appear as if we called out of method_g_ at given pc dex.
thread->SetTopOfStack(reinterpret_cast<ArtMethod**>(&fake_stack[0]));
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.