1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
|
//===-- Disassembler.h ------------------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#ifndef liblldb_Disassembler_h_
#define liblldb_Disassembler_h_
// C Includes
// C++ Includes
#include <vector>
// Other libraries and framework includes
// Project includes
#include "lldb/lldb-private.h"
#include "lldb/Core/Address.h"
#include "lldb/Core/ArchSpec.h"
#include "lldb/Core/PluginInterface.h"
namespace lldb_private {
class Instruction
{
public:
Instruction (const Address &addr);
virtual
~Instruction();
const Address &
GetAddress () const
{
return m_addr;
}
void
SetAddress (const Address &addr)
{
m_addr = addr;
}
virtual size_t
GetByteSize() const = 0;
virtual void
Dump (Stream *s,
bool show_address,
const DataExtractor *bytes,
uint32_t bytes_offset,
const ExecutionContext *exe_ctx,
bool raw) = 0;
virtual bool
DoesBranch () const = 0;
virtual size_t
Extract (const DataExtractor& data, uint32_t data_offset) = 0;
protected:
Address m_addr; // The section offset address of this instruction
};
class InstructionList
{
public:
InstructionList();
~InstructionList();
size_t
GetSize() const;
lldb::InstructionSP
GetInstructionAtIndex (uint32_t idx) const;
void
Clear();
void
Append (lldb::InstructionSP &inst_sp);
private:
typedef std::vector<lldb::InstructionSP> collection;
typedef collection::iterator iterator;
typedef collection::const_iterator const_iterator;
collection m_instructions;
};
class Disassembler :
public PluginInterface
{
public:
static Disassembler*
FindPlugin (const ArchSpec &arch);
static lldb::DisassemblerSP
DisassembleRange (const ArchSpec &arch,
const ExecutionContext &exe_ctx,
const AddressRange &disasm_range);
static bool
Disassemble (Debugger &debugger,
const ArchSpec &arch,
const ExecutionContext &exe_ctx,
const AddressRange &range,
uint32_t num_mixed_context_lines,
bool show_bytes,
Stream &strm);
static size_t
Disassemble (Debugger &debugger,
const ArchSpec &arch,
const ExecutionContext &exe_ctx,
SymbolContextList &sc_list,
uint32_t num_mixed_context_lines,
bool show_bytes,
Stream &strm);
static bool
Disassemble (Debugger &debugger,
const ArchSpec &arch,
const ExecutionContext &exe_ctx,
const ConstString &name,
Module *module,
uint32_t num_mixed_context_lines,
bool show_bytes,
Stream &strm);
static bool
Disassemble (Debugger &debugger,
const ArchSpec &arch,
const ExecutionContext &exe_ctx,
uint32_t num_mixed_context_lines,
bool show_bytes,
Stream &strm);
//------------------------------------------------------------------
// Constructors and Destructors
//------------------------------------------------------------------
Disassembler(const ArchSpec &arch);
virtual ~Disassembler();
typedef const char * (*SummaryCallback)(const Instruction& inst, ExecutionContext *exe_context, void *user_data);
size_t
ParseInstructions (const ExecutionContext *exe_ctx,
const AddressRange &range,
DataExtractor& data);
virtual size_t
DecodeInstructions (const Address &base_addr,
const DataExtractor& data,
uint32_t data_offset,
uint32_t num_instructions) = 0;
InstructionList &
GetInstructionList ();
const InstructionList &
GetInstructionList () const;
protected:
//------------------------------------------------------------------
// Classes that inherit from Disassembler can see and modify these
//------------------------------------------------------------------
const ArchSpec m_arch;
InstructionList m_instruction_list;
lldb::addr_t m_base_addr;
private:
//------------------------------------------------------------------
// For Disassembler only
//------------------------------------------------------------------
DISALLOW_COPY_AND_ASSIGN (Disassembler);
};
} // namespace lldb_private
#endif // liblldb_Disassembler_h_
|