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_
18 // Other libraries and framework includes
20 #include "lldb/Core/ConstString.h"
21 #include "lldb/lldb-private.h"
23 namespace lldb_private {
27 typedef std::shared_ptr<DebugMacros> DebugMacrosSP;
29 class DebugMacroEntry {
31 enum EntryType { INVALID, DEFINE, UNDEF, START_FILE, END_FILE, INDIRECT };
34 static DebugMacroEntry CreateDefineEntry(uint32_t line, const char *str);
36 static DebugMacroEntry CreateUndefEntry(uint32_t line, const char *str);
38 static DebugMacroEntry CreateStartFileEntry(uint32_t line,
39 uint32_t debug_line_file_idx);
41 static DebugMacroEntry CreateEndFileEntry();
43 static DebugMacroEntry
44 CreateIndirectEntry(const DebugMacrosSP &debug_macros_sp);
46 DebugMacroEntry() : m_type(INVALID) {}
48 ~DebugMacroEntry() = default;
50 EntryType GetType() const { return m_type; }
52 uint64_t GetLineNumber() const { return m_line; }
54 ConstString GetMacroString() const { return m_str; }
56 const FileSpec &GetFileSpec(CompileUnit *comp_unit) const;
58 DebugMacros *GetIndirectDebugMacros() const {
59 return m_debug_macros_sp.get();
63 DebugMacroEntry(EntryType type, uint32_t line, uint32_t debug_line_file_idx,
66 DebugMacroEntry(EntryType type, const DebugMacrosSP &debug_macros_sp);
70 uint32_t m_debug_line_file_idx;
72 DebugMacrosSP m_debug_macros_sp;
77 DebugMacros() = default;
79 ~DebugMacros() = default;
81 void AddMacroEntry(const DebugMacroEntry &entry) {
82 m_macro_entries.push_back(entry);
85 size_t GetNumMacroEntries() const { return m_macro_entries.size(); }
87 DebugMacroEntry GetMacroEntryAtIndex(const size_t index) const {
88 if (index < m_macro_entries.size())
89 return m_macro_entries[index];
91 return DebugMacroEntry();
95 DISALLOW_COPY_AND_ASSIGN(DebugMacros);
97 std::vector<DebugMacroEntry> m_macro_entries;
100 } // namespace lldb_private
102 #endif // liblldb_DebugMacros_h_