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 LLDB_SYMBOL_DEBUGMACROS_H
10 #define LLDB_SYMBOL_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:
26  enum EntryType : uint8_t {
28  };
29 
30  static DebugMacroEntry CreateDefineEntry(uint32_t line, const char *str);
31 
32  static DebugMacroEntry CreateUndefEntry(uint32_t line, const char *str);
33 
35  uint32_t debug_line_file_idx);
36 
38 
39  static DebugMacroEntry
40  CreateIndirectEntry(const DebugMacrosSP &debug_macros_sp);
41 
43 
44  ~DebugMacroEntry() = default;
45 
46  EntryType GetType() const { return static_cast<EntryType>(m_type); }
47 
48  uint64_t GetLineNumber() const { return m_line; }
49 
50  ConstString GetMacroString() const { return m_str; }
51 
52  const FileSpec &GetFileSpec(CompileUnit *comp_unit) const;
53 
55  return m_debug_macros_sp.get();
56  }
57 
58 private:
59  DebugMacroEntry(EntryType type, uint32_t line, uint32_t debug_line_file_idx,
60  const char *str);
61 
62  DebugMacroEntry(EntryType type, const DebugMacrosSP &debug_macros_sp);
63 
69 };
70 
71 class DebugMacros {
72 public:
73  DebugMacros() = default;
74 
75  ~DebugMacros() = default;
76 
77  void AddMacroEntry(const DebugMacroEntry &entry) {
78  m_macro_entries.push_back(entry);
79  }
80 
81  size_t GetNumMacroEntries() const { return m_macro_entries.size(); }
82 
83  DebugMacroEntry GetMacroEntryAtIndex(const size_t index) const {
84  if (index < m_macro_entries.size())
85  return m_macro_entries[index];
86  else
87  return DebugMacroEntry();
88  }
89 
90 private:
91  DebugMacros(const DebugMacros &) = delete;
92  const DebugMacros &operator=(const DebugMacros &) = delete;
93 
94  std::vector<DebugMacroEntry> m_macro_entries;
95 };
96 
97 } // namespace lldb_private
98 
99 #endif // LLDB_SYMBOL_DEBUGMACROS_H
lldb_private::DebugMacroEntry::~DebugMacroEntry
~DebugMacroEntry()=default
lldb_private::DebugMacros
Definition: DebugMacros.h:71
EntryType
FormatEntity::Entry::Type EntryType
Definition: FormatEntity.cpp:83
lldb_private::DebugMacros::DebugMacros
DebugMacros()=default
lldb_private::DebugMacroEntry::GetIndirectDebugMacros
DebugMacros * GetIndirectDebugMacros() const
Definition: DebugMacros.h:54
lldb_private::DebugMacroEntry::CreateEndFileEntry
static DebugMacroEntry CreateEndFileEntry()
Definition: DebugMacros.cpp:46
lldb_private::CompileUnit
Definition: CompileUnit.h:38
lldb_private::DebugMacros::GetMacroEntryAtIndex
DebugMacroEntry GetMacroEntryAtIndex(const size_t index) const
Definition: DebugMacros.h:83
lldb_private::FileSpec
Definition: FileSpec.h:56
lldb_private::DebugMacroEntry::m_type
uint32_t m_type
Definition: DebugMacros.h:64
lldb_private::DebugMacroEntry::GetType
EntryType GetType() const
Definition: DebugMacros.h:46
lldb_private::DebugMacroEntry
Definition: DebugMacros.h:24
lldb_private::DebugMacrosSP
std::shared_ptr< DebugMacros > DebugMacrosSP
Definition: DebugMacros.h:21
lldb_private::ConstString
Definition: ConstString.h:40
lldb_private::DebugMacroEntry::INDIRECT
@ INDIRECT
Definition: DebugMacros.h:27
lldb_private::DebugMacroEntry::CreateStartFileEntry
static DebugMacroEntry CreateStartFileEntry(uint32_t line, uint32_t debug_line_file_idx)
Definition: DebugMacros.cpp:40
lldb_private::DebugMacroEntry::CreateUndefEntry
static DebugMacroEntry CreateUndefEntry(uint32_t line, const char *str)
Definition: DebugMacros.cpp:34
lldb_private::DebugMacroEntry::START_FILE
@ START_FILE
Definition: DebugMacros.h:27
lldb_private::DebugMacroEntry::CreateDefineEntry
static DebugMacroEntry CreateDefineEntry(uint32_t line, const char *str)
Definition: DebugMacros.cpp:29
lldb_private::DebugMacroEntry::DEFINE
@ DEFINE
Definition: DebugMacros.h:27
lldb_private::DebugMacroEntry::CreateIndirectEntry
static DebugMacroEntry CreateIndirectEntry(const DebugMacrosSP &debug_macros_sp)
Definition: DebugMacros.cpp:51
lldb_private::DebugMacroEntry::GetLineNumber
uint64_t GetLineNumber() const
Definition: DebugMacros.h:48
lldb-private.h
lldb_private::DebugMacroEntry::END_FILE
@ END_FILE
Definition: DebugMacros.h:27
lldb_private::DebugMacros::m_macro_entries
std::vector< DebugMacroEntry > m_macro_entries
Definition: DebugMacros.h:94
lldb_private::DebugMacros::operator=
const DebugMacros & operator=(const DebugMacros &)=delete
uint32_t
lldb_private::DebugMacroEntry::m_debug_line_file_idx
uint32_t m_debug_line_file_idx
Definition: DebugMacros.h:66
lldb_private::DebugMacroEntry::EntryType
EntryType
Definition: DebugMacros.h:26
lldb_private::DebugMacros::~DebugMacros
~DebugMacros()=default
lldb_private::DebugMacroEntry::m_str
ConstString m_str
Definition: DebugMacros.h:67
lldb_private::DebugMacroEntry::m_line
uint32_t m_line
Definition: DebugMacros.h:65
lldb_private::DebugMacroEntry::m_debug_macros_sp
DebugMacrosSP m_debug_macros_sp
Definition: DebugMacros.h:68
lldb_private
A class that represents a running process on the host machine.
Definition: SBCommandInterpreterRunOptions.h:16
lldb_private::DebugMacroEntry::DebugMacroEntry
DebugMacroEntry()
Definition: DebugMacros.h:42
lldb_private::DebugMacros::GetNumMacroEntries
size_t GetNumMacroEntries() const
Definition: DebugMacros.h:81
lldb_private::DebugMacroEntry::INVALID
@ INVALID
Definition: DebugMacros.h:27
ConstString.h
lldb_private::DebugMacroEntry::UNDEF
@ UNDEF
Definition: DebugMacros.h:27
lldb_private::DebugMacroEntry::GetFileSpec
const FileSpec & GetFileSpec(CompileUnit *comp_unit) const
Definition: DebugMacros.cpp:25
lldb_private::DebugMacros::AddMacroEntry
void AddMacroEntry(const DebugMacroEntry &entry)
Definition: DebugMacros.h:77
lldb_private::DebugMacroEntry::GetMacroString
ConstString GetMacroString() const
Definition: DebugMacros.h:50