LLDB  mainline
DebugMacros.h
Go to the documentation of this file.
1 //===-- DebugMacros.h -------------------------------------------*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 #ifndef liblldb_DebugMacros_h_
10 #define liblldb_DebugMacros_h_
11 
12 #include <memory>
13 #include <vector>
14 
16 #include "lldb/lldb-private.h"
17 
18 namespace lldb_private {
19 
20 class CompileUnit;
22 typedef std::shared_ptr<DebugMacros> DebugMacrosSP;
23 
25 public:
27 
28 public:
29  static DebugMacroEntry CreateDefineEntry(uint32_t line, const char *str);
30 
31  static DebugMacroEntry CreateUndefEntry(uint32_t line, const char *str);
32 
34  uint32_t debug_line_file_idx);
35 
37 
38  static DebugMacroEntry
39  CreateIndirectEntry(const DebugMacrosSP &debug_macros_sp);
40 
41  DebugMacroEntry() : m_type(INVALID) {}
42 
43  ~DebugMacroEntry() = default;
44 
45  EntryType GetType() const { return m_type; }
46 
47  uint64_t GetLineNumber() const { return m_line; }
48 
49  ConstString GetMacroString() const { return m_str; }
50 
51  const FileSpec &GetFileSpec(CompileUnit *comp_unit) const;
52 
54  return m_debug_macros_sp.get();
55  }
56 
57 private:
58  DebugMacroEntry(EntryType type, uint32_t line, uint32_t debug_line_file_idx,
59  const char *str);
60 
61  DebugMacroEntry(EntryType type, const DebugMacrosSP &debug_macros_sp);
62 
63  EntryType m_type : 3;
64  uint32_t m_line : 29;
65  uint32_t m_debug_line_file_idx;
66  ConstString m_str;
67  DebugMacrosSP m_debug_macros_sp;
68 };
69 
70 class DebugMacros {
71 public:
72  DebugMacros() = default;
73 
74  ~DebugMacros() = default;
75 
76  void AddMacroEntry(const DebugMacroEntry &entry) {
77  m_macro_entries.push_back(entry);
78  }
79 
80  size_t GetNumMacroEntries() const { return m_macro_entries.size(); }
81 
82  DebugMacroEntry GetMacroEntryAtIndex(const size_t index) const {
83  if (index < m_macro_entries.size())
84  return m_macro_entries[index];
85  else
86  return DebugMacroEntry();
87  }
88 
89 private:
90  DISALLOW_COPY_AND_ASSIGN(DebugMacros);
91 
92  std::vector<DebugMacroEntry> m_macro_entries;
93 };
94 
95 } // namespace lldb_private
96 
97 #endif // liblldb_DebugMacros_h_
DebugMacros * GetIndirectDebugMacros() const
Definition: DebugMacros.h:53
Enumerations for broadcasting.
Definition: SBLaunchInfo.h:14
static DebugMacroEntry CreateUndefEntry(uint32_t line, const char *str)
Definition: DebugMacros.cpp:34
static DebugMacroEntry CreateEndFileEntry()
Definition: DebugMacros.cpp:46
static DebugMacroEntry CreateStartFileEntry(uint32_t line, uint32_t debug_line_file_idx)
Definition: DebugMacros.cpp:40
ConstString GetMacroString() const
Definition: DebugMacros.h:49
A file utility class.
Definition: FileSpec.h:55
size_t GetNumMacroEntries() const
Definition: DebugMacros.h:80
A class that describes a compilation unit.
Definition: CompileUnit.h:35
static DebugMacroEntry CreateDefineEntry(uint32_t line, const char *str)
Definition: DebugMacros.cpp:29
uint64_t GetLineNumber() const
Definition: DebugMacros.h:47
std::shared_ptr< DebugMacros > DebugMacrosSP
Definition: DebugMacros.h:21
EntryType GetType() const
Definition: DebugMacros.h:45
const FileSpec & GetFileSpec(CompileUnit *comp_unit) const
Definition: DebugMacros.cpp:25
A uniqued constant string class.
Definition: ConstString.h:38
static DebugMacroEntry CreateIndirectEntry(const DebugMacrosSP &debug_macros_sp)
Definition: DebugMacros.cpp:51
void AddMacroEntry(const DebugMacroEntry &entry)
Definition: DebugMacros.h:76
DebugMacroEntry GetMacroEntryAtIndex(const size_t index) const
Definition: DebugMacros.h:82