blob: d00ae0d73c0cc779c6a4a25a5df9e02199eeed0b [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
Chris Lattner30fdc8d2010-06-08 16:52:24 +000015#include "lldb/Core/FileSpec.h"
16#include "lldb/Host/Mutex.h"
17#include "lldb/Symbol/ObjectFile.h"
18
19//----------------------------------------------------------------------
20// This class needs to be hidden as eventually belongs in a plugin that
21// will export the ObjectFile protocol
22//----------------------------------------------------------------------
23class ObjectFileMachO :
24 public lldb_private::ObjectFile
25{
26public:
27 //------------------------------------------------------------------
28 // Static Functions
29 //------------------------------------------------------------------
30 static void
31 Initialize();
32
33 static void
34 Terminate();
35
36 static const char *
37 GetPluginNameStatic();
38
39 static const char *
40 GetPluginDescriptionStatic();
41
42 static ObjectFile *
43 CreateInstance (lldb_private::Module* module,
44 lldb::DataBufferSP& dataSP,
45 const lldb_private::FileSpec* file,
46 lldb::addr_t offset,
47 lldb::addr_t length);
48
49 static bool
50 MagicBytesMatch (lldb::DataBufferSP& dataSP);
51
52 //------------------------------------------------------------------
53 // Member Functions
54 //------------------------------------------------------------------
55 ObjectFileMachO (lldb_private::Module* module,
56 lldb::DataBufferSP& dataSP,
57 const lldb_private::FileSpec* file,
58 lldb::addr_t offset,
59 lldb::addr_t length);
60
61 virtual
62 ~ObjectFileMachO();
63
64 virtual bool
65 ParseHeader ();
66
67 virtual lldb::ByteOrder
68 GetByteOrder () const;
69
70 virtual size_t
71 GetAddressByteSize () const;
72
73 virtual lldb_private::Symtab *
74 GetSymtab();
75
76 virtual lldb_private::SectionList *
77 GetSectionList();
78
79 virtual void
80 Dump (lldb_private::Stream *s);
81
82 virtual bool
83 GetTargetTriple (lldb_private::ConstString &target_triple);
84
85 virtual bool
86 GetUUID (lldb_private::UUID* uuid);
87
88 virtual uint32_t
89 GetDependentModules (lldb_private::FileSpecList& files);
90
91 //------------------------------------------------------------------
92 // PluginInterface protocol
93 //------------------------------------------------------------------
94 virtual const char *
95 GetPluginName();
96
97 virtual const char *
98 GetShortPluginName();
99
100 virtual uint32_t
101 GetPluginVersion();
102
103 virtual void
104 GetPluginCommandHelp (const char *command, lldb_private::Stream *strm);
105
106 virtual lldb_private::Error
107 ExecutePluginCommand (lldb_private::Args &command, lldb_private::Stream *strm);
108
109 virtual lldb_private::Log *
110 EnablePluginLogging (lldb_private::Stream *strm, lldb_private::Args &command);
111
112
113
114protected:
115 mutable lldb_private::Mutex m_mutex;
Greg Claytone1a916a2010-07-21 22:12:05 +0000116 llvm::MachO::mach_header m_header;
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000117 mutable std::auto_ptr<lldb_private::SectionList> m_sections_ap;
118 mutable std::auto_ptr<lldb_private::Symtab> m_symtab_ap;
119
Greg Claytone1a916a2010-07-21 22:12:05 +0000120 llvm::MachO::dysymtab_command m_dysymtab;
121 std::vector<llvm::MachO::segment_command_64> m_mach_segments;
122 std::vector<llvm::MachO::section_64> m_mach_sections;
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_