blob: 237b577bc2b34c23762bb579a17591db3f477dbc [file] [log] [blame]
Ian Rogers3a5c1ce2012-02-29 10:06:46 -08001/*
2 * Copyright (C) 2012 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
Ian Rogers02ed4c02013-09-06 13:10:04 -070017#ifndef ART_DISASSEMBLER_DISASSEMBLER_ARM_H_
18#define ART_DISASSEMBLER_DISASSEMBLER_ARM_H_
Ian Rogers3a5c1ce2012-02-29 10:06:46 -080019
Anton Kirilov29b0cde2016-09-06 13:01:03 +010020#include <memory>
21#include <sstream>
Elliott Hughes105afd22012-04-10 15:04:25 -070022
Anton Kirilov29b0cde2016-09-06 13:01:03 +010023#include "base/macros.h"
Ian Rogers3a5c1ce2012-02-29 10:06:46 -080024#include "disassembler.h"
25
26namespace art {
27namespace arm {
28
Ian Rogers38e12032014-03-14 14:06:14 -070029class DisassemblerArm FINAL : public Disassembler {
Anton Kirilov29b0cde2016-09-06 13:01:03 +010030 class CustomDisassembler;
31
Ian Rogers3a5c1ce2012-02-29 10:06:46 -080032 public:
Anton Kirilov29b0cde2016-09-06 13:01:03 +010033 explicit DisassemblerArm(DisassemblerOptions* options);
Ian Rogers3a5c1ce2012-02-29 10:06:46 -080034
Ian Rogers38e12032014-03-14 14:06:14 -070035 size_t Dump(std::ostream& os, const uint8_t* begin) OVERRIDE;
36 void Dump(std::ostream& os, const uint8_t* begin, const uint8_t* end) OVERRIDE;
Ian Rogersb122a4b2013-11-19 18:00:50 -080037
Ian Rogers3a5c1ce2012-02-29 10:06:46 -080038 private:
Anton Kirilov29b0cde2016-09-06 13:01:03 +010039 uintptr_t GetPc(uintptr_t instr_ptr) const {
40 return GetDisassemblerOptions()->absolute_addresses_
41 ? instr_ptr
42 : instr_ptr - reinterpret_cast<uintptr_t>(GetDisassemblerOptions()->base_address_);
43 }
Ian Rogers3a5c1ce2012-02-29 10:06:46 -080044
Anton Kirilov29b0cde2016-09-06 13:01:03 +010045 std::ostringstream output_;
46 std::unique_ptr<CustomDisassembler> disasm_;
Elliott Hughes105afd22012-04-10 15:04:25 -070047
48 DISALLOW_COPY_AND_ASSIGN(DisassemblerArm);
Ian Rogers3a5c1ce2012-02-29 10:06:46 -080049};
50
51} // namespace arm
52} // namespace art
53
Ian Rogers02ed4c02013-09-06 13:10:04 -070054#endif // ART_DISASSEMBLER_DISASSEMBLER_ARM_H_