blob: dd6621d344829a451635b72b7b5d3c5f71465bef [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
Roland Levillainbbc6e7e2018-08-24 16:58:47 +010029class 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
Roland Levillainbbc6e7e2018-08-24 16:58:47 +010035 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_