summaryrefslogtreecommitdiffstats
path: root/lldb/source/Plugins/Disassembler/llvm/DisassemblerLLVM.h
blob: 73a117d4f40ae1ca72d21e00a948b65a7da4e22e (plain)
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
//===-- DisassemblerLLVM.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_DisassemblerLLVM_h_
#define liblldb_DisassemblerLLVM_h_


#include "llvm-c/EnhancedDisassembly.h"

#include "lldb/Core/Disassembler.h"
#include "lldb/Host/Mutex.h"

class InstructionLLVM : public lldb_private::Instruction
{
public:
    InstructionLLVM (const lldb_private::Address &addr,
                     lldb_private::AddressClass addr_class,
                     EDDisassemblerRef disassembler,
                     llvm::Triple::ArchType arch_type);
    
    virtual
    ~InstructionLLVM();
    
    virtual void
    Dump (lldb_private::Stream *s,
          uint32_t max_opcode_byte_size,
          bool show_address,
          bool show_bytes,
          const lldb_private::ExecutionContext* exe_ctx,
          bool raw);
    
    virtual bool
    DoesBranch () const;
    
    virtual size_t
    Decode (const lldb_private::Disassembler &disassembler,
            const lldb_private::DataExtractor &data,
            uint32_t data_offset);
    
    virtual void
    CalculateMnemonic (lldb_private::ExecutionContextScope *exe_scope);
    
    virtual void
    CalculateOperands (lldb_private::ExecutionContextScope *exe_scope);
    
    virtual void
    CalculateComment (lldb_private::ExecutionContextScope *exe_scope);

protected:
    EDDisassemblerRef m_disassembler;
    EDInstRef m_inst;
    llvm::Triple::ArchType m_arch_type;
};


class DisassemblerLLVM : public lldb_private::Disassembler
{
public:
    //------------------------------------------------------------------
    // Static Functions
    //------------------------------------------------------------------
    static void
    Initialize();

    static void
    Terminate();

    static const char *
    GetPluginNameStatic();

    static const char *
    GetPluginDescriptionStatic();

    static lldb_private::Disassembler *
    CreateInstance(const lldb_private::ArchSpec &arch);


    DisassemblerLLVM(const lldb_private::ArchSpec &arch);

    virtual
    ~DisassemblerLLVM();

    size_t
    DecodeInstructions (const lldb_private::Address &base_addr,
                        const lldb_private::DataExtractor& data,
                        uint32_t data_offset,
                        uint32_t num_instructions,
                        bool append);
    
    //------------------------------------------------------------------
    // PluginInterface protocol
    //------------------------------------------------------------------
    virtual const char *
    GetPluginName();

    virtual const char *
    GetShortPluginName();

    virtual uint32_t
    GetPluginVersion();

protected:
    bool
    IsValid() const
    {
        return m_disassembler != NULL;
    }

    EDDisassemblerRef m_disassembler;
    EDDisassemblerRef m_disassembler_thumb;
};

#endif  // liblldb_DisassemblerLLVM_h_
OpenPOWER on IntegriCloud