blob: bd25062c38efbeb9d523806e9081387198dfbe1b [file] [log] [blame]
Chris Lattner30fdc8d2010-06-08 16:52:24 +00001//===-- ObjectFileMachO.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_ObjectFileMachO_h_
11#define liblldb_ObjectFileMachO_h_
12
Greg Claytone1a916a2010-07-21 22:12:05 +000013#include "llvm/Support/MachO.h"
14
Jim Ingham672e6f52011-03-07 23:44:08 +000015#include "lldb/Core/Address.h"
Greg Clayton53239f02011-02-08 05:05:52 +000016#include "lldb/Host/FileSpec.h"
Chris Lattner30fdc8d2010-06-08 16:52:24 +000017#include "lldb/Host/Mutex.h"
18#include "lldb/Symbol/ObjectFile.h"
19
20//----------------------------------------------------------------------
21// This class needs to be hidden as eventually belongs in a plugin that
22// will export the ObjectFile protocol
23//----------------------------------------------------------------------
24class ObjectFileMachO :
25 public lldb_private::ObjectFile
26{
27public:
28 //------------------------------------------------------------------
29 // Static Functions
30 //------------------------------------------------------------------
31 static void
32 Initialize();
33
34 static void
35 Terminate();
36
37 static const char *
38 GetPluginNameStatic();
39
40 static const char *
41 GetPluginDescriptionStatic();
42
43 static ObjectFile *
44 CreateInstance (lldb_private::Module* module,
45 lldb::DataBufferSP& dataSP,
46 const lldb_private::FileSpec* file,
47 lldb::addr_t offset,
48 lldb::addr_t length);
49
50 static bool
51 MagicBytesMatch (lldb::DataBufferSP& dataSP);
52
53 //------------------------------------------------------------------
54 // Member Functions
55 //------------------------------------------------------------------
56 ObjectFileMachO (lldb_private::Module* module,
57 lldb::DataBufferSP& dataSP,
58 const lldb_private::FileSpec* file,
59 lldb::addr_t offset,
60 lldb::addr_t length);
61
62 virtual
63 ~ObjectFileMachO();
64
65 virtual bool
66 ParseHeader ();
67
68 virtual lldb::ByteOrder
69 GetByteOrder () const;
Jim Ingham5aee1622010-08-09 23:31:02 +000070
71 virtual bool
72 IsExecutable () const;
Chris Lattner30fdc8d2010-06-08 16:52:24 +000073
74 virtual size_t
75 GetAddressByteSize () const;
76
Greg Claytonded470d2011-03-19 01:12:21 +000077 virtual lldb::AddressClass
78 GetAddressClass (lldb::addr_t file_addr);
79
Chris Lattner30fdc8d2010-06-08 16:52:24 +000080 virtual lldb_private::Symtab *
81 GetSymtab();
82
83 virtual lldb_private::SectionList *
84 GetSectionList();
85
86 virtual void
87 Dump (lldb_private::Stream *s);
88
89 virtual bool
Greg Clayton514487e2011-02-15 21:59:32 +000090 GetArchitecture (lldb_private::ArchSpec &arch);
Chris Lattner30fdc8d2010-06-08 16:52:24 +000091
92 virtual bool
93 GetUUID (lldb_private::UUID* uuid);
94
95 virtual uint32_t
96 GetDependentModules (lldb_private::FileSpecList& files);
97
98 //------------------------------------------------------------------
99 // PluginInterface protocol
100 //------------------------------------------------------------------
101 virtual const char *
102 GetPluginName();
103
104 virtual const char *
105 GetShortPluginName();
106
107 virtual uint32_t
108 GetPluginVersion();
109
Jim Ingham672e6f52011-03-07 23:44:08 +0000110 virtual lldb_private::Address
111 GetEntryPointAddress ();
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000112
113protected:
114 mutable lldb_private::Mutex m_mutex;
Greg Claytone1a916a2010-07-21 22:12:05 +0000115 llvm::MachO::mach_header m_header;
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000116 mutable std::auto_ptr<lldb_private::SectionList> m_sections_ap;
117 mutable std::auto_ptr<lldb_private::Symtab> m_symtab_ap;
118
Greg Claytone1a916a2010-07-21 22:12:05 +0000119 llvm::MachO::dysymtab_command m_dysymtab;
120 std::vector<llvm::MachO::segment_command_64> m_mach_segments;
121 std::vector<llvm::MachO::section_64> m_mach_sections;
Jim Ingham672e6f52011-03-07 23:44:08 +0000122 lldb_private::Address m_entry_point_address;
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000123
124 size_t
125 ParseSections ();
126
127 size_t
128 ParseSymtab (bool minimize);
129
130};
131
132#endif // liblldb_ObjectFileMachO_h_