Serban Constantinescu | e6622be | 2014-02-27 15:36:47 +0000 | [diff] [blame] | 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 << StringPrintf("%p: %08x\t%s\n", begin, instruction, disasm.GetOutput()); |
| 38 | return vixl::kInstructionSize; |
| 39 | } |
| 40 | |
| 41 | void DisassemblerArm64::Dump(std::ostream& os, const uint8_t* begin, const uint8_t* end) { |
| 42 | for (const uint8_t* cur = begin; cur < end; cur += vixl::kInstructionSize) { |
| 43 | Dump(os, cur); |
| 44 | } |
| 45 | } |
| 46 | |
| 47 | } // namespace arm64 |
| 48 | } // namespace art |