1 //===-- DebugMacros.h -------------------------------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #ifndef liblldb_DebugMacros_h_
11 #define liblldb_DebugMacros_h_
16 #include "lldb/Utility/ConstString.h"
17 #include "lldb/lldb-private.h"
19 namespace lldb_private {
23 typedef std::shared_ptr<DebugMacros> DebugMacrosSP;
25 class DebugMacroEntry {
27 enum EntryType { INVALID, DEFINE, UNDEF, START_FILE, END_FILE, INDIRECT };
30 static DebugMacroEntry CreateDefineEntry(uint32_t line, const char *str);
32 static DebugMacroEntry CreateUndefEntry(uint32_t line, const char *str);
34 static DebugMacroEntry CreateStartFileEntry(uint32_t line,
35 uint32_t debug_line_file_idx);
37 static DebugMacroEntry CreateEndFileEntry();
39 static DebugMacroEntry
40 CreateIndirectEntry(const DebugMacrosSP &debug_macros_sp);
42 DebugMacroEntry() : m_type(INVALID) {}
44 ~DebugMacroEntry() = default;
46 EntryType GetType() const { return m_type; }
48 uint64_t GetLineNumber() const { return m_line; }
50 ConstString GetMacroString() const { return m_str; }
52 const FileSpec &GetFileSpec(CompileUnit *comp_unit) const;
54 DebugMacros *GetIndirectDebugMacros() const {
55 return m_debug_macros_sp.get();
59 DebugMacroEntry(EntryType type, uint32_t line, uint32_t debug_line_file_idx,
62 DebugMacroEntry(EntryType type, const DebugMacrosSP &debug_macros_sp);
66 uint32_t m_debug_line_file_idx;
68 DebugMacrosSP m_debug_macros_sp;
73 DebugMacros() = default;
75 ~DebugMacros() = default;
77 void AddMacroEntry(const DebugMacroEntry &entry) {
78 m_macro_entries.push_back(entry);
81 size_t GetNumMacroEntries() const { return m_macro_entries.size(); }
83 DebugMacroEntry GetMacroEntryAtIndex(const size_t index) const {
84 if (index < m_macro_entries.size())
85 return m_macro_entries[index];
87 return DebugMacroEntry();
91 DISALLOW_COPY_AND_ASSIGN(DebugMacros);
93 std::vector<DebugMacroEntry> m_macro_entries;
96 } // namespace lldb_private
98 #endif // liblldb_DebugMacros_h_