blob: 5d0c2189cc31a380383e162dcd5ddf6c8555c72f [file] [log] [blame]
Serban Constantinescue6622be2014-02-27 15:36:47 +00001/*
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
27namespace art {
28namespace arm64 {
29
30static uint32_t ReadU32(const uint8_t* ptr) {
31 return *((const uint32_t*)ptr);
32}
33
34size_t DisassemblerArm64::Dump(std::ostream& os, const uint8_t* begin) {
35 uint32_t instruction = ReadU32(begin);
36 decoder.Decode(reinterpret_cast<vixl::Instruction*>(&instruction));
Brian Carlstrom2cbaccb2014-09-14 20:34:17 -070037 os << FormatInstructionPointer(begin)
38 << StringPrintf(": %08x\t%s\n", instruction, disasm.GetOutput());
Serban Constantinescue6622be2014-02-27 15:36:47 +000039 return vixl::kInstructionSize;
40}
41
42void 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