blob: 73a117d4f40ae1ca72d21e00a948b65a7da4e22e [file] [log] [blame]
Chris Lattner30fdc8d2010-06-08 16:52:24 +00001//===-- DisassemblerLLVM.h --------------------------------------*- C++ -*-===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9
10#ifndef liblldb_DisassemblerLLVM_h_
11#define liblldb_DisassemblerLLVM_h_
12
Greg Claytond1daf002010-07-21 16:57:26 +000013
14#include "llvm-c/EnhancedDisassembly.h"
15
Chris Lattner30fdc8d2010-06-08 16:52:24 +000016#include "lldb/Core/Disassembler.h"
17#include "lldb/Host/Mutex.h"
18
Caroline Tice7c9dd3c2011-04-05 23:22:54 +000019class InstructionLLVM : public lldb_private::Instruction
20{
21public:
22 InstructionLLVM (const lldb_private::Address &addr,
23 lldb_private::AddressClass addr_class,
Greg Clayton7260f622011-04-18 08:33:37 +000024 EDDisassemblerRef disassembler,
Johnny Chen4b95aa42011-05-12 22:25:53 +000025 llvm::Triple::ArchType arch_type);
Caroline Tice7c9dd3c2011-04-05 23:22:54 +000026
27 virtual
28 ~InstructionLLVM();
29
30 virtual void
31 Dump (lldb_private::Stream *s,
32 uint32_t max_opcode_byte_size,
33 bool show_address,
34 bool show_bytes,
35 const lldb_private::ExecutionContext* exe_ctx,
36 bool raw);
37
38 virtual bool
39 DoesBranch () const;
40
41 virtual size_t
42 Decode (const lldb_private::Disassembler &disassembler,
43 const lldb_private::DataExtractor &data,
44 uint32_t data_offset);
45
Greg Clayton8f7180b2011-09-26 07:11:27 +000046 virtual void
Greg Claytonfb0655e2011-09-27 00:58:45 +000047 CalculateMnemonic (lldb_private::ExecutionContextScope *exe_scope);
Greg Clayton8f7180b2011-09-26 07:11:27 +000048
49 virtual void
Greg Claytonfb0655e2011-09-27 00:58:45 +000050 CalculateOperands (lldb_private::ExecutionContextScope *exe_scope);
Greg Clayton8f7180b2011-09-26 07:11:27 +000051
52 virtual void
53 CalculateComment (lldb_private::ExecutionContextScope *exe_scope);
54
Caroline Tice7c9dd3c2011-04-05 23:22:54 +000055protected:
56 EDDisassemblerRef m_disassembler;
57 EDInstRef m_inst;
Johnny Chen4b95aa42011-05-12 22:25:53 +000058 llvm::Triple::ArchType m_arch_type;
Caroline Tice7c9dd3c2011-04-05 23:22:54 +000059};
60
61
Chris Lattner30fdc8d2010-06-08 16:52:24 +000062class DisassemblerLLVM : public lldb_private::Disassembler
63{
64public:
Chris Lattner30fdc8d2010-06-08 16:52:24 +000065 //------------------------------------------------------------------
66 // Static Functions
67 //------------------------------------------------------------------
68 static void
69 Initialize();
70
71 static void
72 Terminate();
73
74 static const char *
75 GetPluginNameStatic();
76
77 static const char *
78 GetPluginDescriptionStatic();
79
80 static lldb_private::Disassembler *
81 CreateInstance(const lldb_private::ArchSpec &arch);
82
83
84 DisassemblerLLVM(const lldb_private::ArchSpec &arch);
85
86 virtual
87 ~DisassemblerLLVM();
88
89 size_t
Greg Clayton1d273162010-10-06 03:09:58 +000090 DecodeInstructions (const lldb_private::Address &base_addr,
91 const lldb_private::DataExtractor& data,
Greg Claytondda4f7b2010-06-30 23:03:03 +000092 uint32_t data_offset,
Jim Ingham37023b02011-03-22 01:48:42 +000093 uint32_t num_instructions,
94 bool append);
Greg Claytondda4f7b2010-06-30 23:03:03 +000095
Chris Lattner30fdc8d2010-06-08 16:52:24 +000096 //------------------------------------------------------------------
97 // PluginInterface protocol
98 //------------------------------------------------------------------
99 virtual const char *
100 GetPluginName();
101
102 virtual const char *
103 GetShortPluginName();
104
105 virtual uint32_t
106 GetPluginVersion();
107
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000108protected:
Greg Claytonbdda5832011-02-16 00:00:43 +0000109 bool
110 IsValid() const
111 {
112 return m_disassembler != NULL;
113 }
114
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000115 EDDisassemblerRef m_disassembler;
Greg Claytonded470d2011-03-19 01:12:21 +0000116 EDDisassemblerRef m_disassembler_thumb;
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000117};
118
119#endif // liblldb_DisassemblerLLVM_h_