1 /* 2 * Copyright (C) 2014 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 #include "disassembler_arm64.h" 18 19 #include <inttypes.h> 20 21 #include <iostream> 22 23 #include "base/logging.h" 24 #include "base/stringprintf.h" 25 #include "thread.h" 26 27 namespace art { 28 namespace arm64 { 29 30 static uint32_t ReadU32(const uint8_t* ptr) { 31 return *((const uint32_t*)ptr); 32 } 33 34 size_t DisassemblerArm64::Dump(std::ostream& os, const uint8_t* begin) { 35 uint32_t instruction = ReadU32(begin); 36 decoder.Decode(reinterpret_cast<vixl::Instruction*>(&instruction)); 37 os << FormatInstructionPointer(begin) 38 << StringPrintf(": %08x\t%s\n", instruction, disasm.GetOutput()); 39 return vixl::kInstructionSize; 40 } 41 42 void DisassemblerArm64::Dump(std::ostream& os, const uint8_t* begin, const uint8_t* end) { 43 for (const uint8_t* cur = begin; cur < end; cur += vixl::kInstructionSize) { 44 Dump(os, cur); 45 } 46 } 47 48 } // namespace arm64 49 } // namespace art 50