LLDB  mainline
SBSymbolContext.cpp
Go to the documentation of this file.
1 //===-- SBSymbolContext.cpp -------------------------------------*- 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 
10 #include "SBReproducerPrivate.h"
11 #include "Utils.h"
12 #include "lldb/API/SBStream.h"
13 #include "lldb/Core/Module.h"
14 #include "lldb/Symbol/Function.h"
15 #include "lldb/Symbol/Symbol.h"
17 
18 using namespace lldb;
19 using namespace lldb_private;
20 
23 }
24 
25 SBSymbolContext::SBSymbolContext(const SymbolContext *sc_ptr) : m_opaque_up() {
27  (const lldb_private::SymbolContext *), sc_ptr);
28 
29  if (sc_ptr)
30  m_opaque_up = llvm::make_unique<SymbolContext>(*sc_ptr);
31 }
32 
35  rhs);
36 
37  m_opaque_up = clone(rhs.m_opaque_up);
38 }
39 
41 
44  SBSymbolContext, operator=,(const lldb::SBSymbolContext &),
45  rhs);
46 
47  if (this != &rhs)
48  m_opaque_up = clone(rhs.m_opaque_up);
49  return LLDB_RECORD_RESULT(*this);
50 }
51 
53  if (sc_ptr)
54  m_opaque_up = llvm::make_unique<SymbolContext>(*sc_ptr);
55  else
56  m_opaque_up->Clear(true);
57 }
58 
61  return this->operator bool();
62 }
63 SBSymbolContext::operator bool() const {
65 
66  return m_opaque_up != NULL;
67 }
68 
71 
72  SBModule sb_module;
73  ModuleSP module_sp;
74  if (m_opaque_up) {
75  module_sp = m_opaque_up->module_sp;
76  sb_module.SetSP(module_sp);
77  }
78 
79  return LLDB_RECORD_RESULT(sb_module);
80 }
81 
85 
86  return LLDB_RECORD_RESULT(
87  SBCompileUnit(m_opaque_up ? m_opaque_up->comp_unit : NULL));
88 }
89 
92 
93  Function *function = NULL;
94 
95  if (m_opaque_up)
96  function = m_opaque_up->function;
97 
98  SBFunction sb_function(function);
99 
100  return LLDB_RECORD_RESULT(sb_function);
101 }
102 
105 
106  return LLDB_RECORD_RESULT(SBBlock(m_opaque_up ? m_opaque_up->block : NULL));
107 }
108 
111 
112  SBLineEntry sb_line_entry;
113  if (m_opaque_up)
114  sb_line_entry.SetLineEntry(m_opaque_up->line_entry);
115 
116  return LLDB_RECORD_RESULT(sb_line_entry);
117 }
118 
121 
122  Symbol *symbol = NULL;
123 
124  if (m_opaque_up)
125  symbol = m_opaque_up->symbol;
126 
127  SBSymbol sb_symbol(symbol);
128 
129  return LLDB_RECORD_RESULT(sb_symbol);
130 }
131 
134  module);
135 
136  ref().module_sp = module.GetSP();
137 }
138 
141  (lldb::SBCompileUnit), compile_unit);
142 
143  ref().comp_unit = compile_unit.get();
144 }
145 
148  function);
149 
150  ref().function = function.get();
151 }
152 
155 
156  ref().block = block.GetPtr();
157 }
158 
161  line_entry);
162 
163  if (line_entry.IsValid())
164  ref().line_entry = line_entry.ref();
165  else
166  ref().line_entry.Clear();
167 }
168 
171  symbol);
172 
173  ref().symbol = symbol.get();
174 }
175 
177  return m_opaque_up.get();
178 }
179 
181  assert(m_opaque_up.get());
182  return *m_opaque_up;
183 }
184 
186  if (m_opaque_up == NULL)
187  m_opaque_up.reset(new SymbolContext);
188  return *m_opaque_up;
189 }
190 
192  if (m_opaque_up == NULL)
193  m_opaque_up.reset(new SymbolContext);
194  return *m_opaque_up;
195 }
196 
198  return m_opaque_up.get();
199 }
200 
203  description);
204 
205  Stream &strm = description.ref();
206 
207  if (m_opaque_up) {
208  m_opaque_up->GetDescription(&strm, lldb::eDescriptionLevelFull, NULL);
209  } else
210  strm.PutCString("No value");
211 
212  return true;
213 }
214 
217  SBAddress &parent_frame_addr) const {
220  (const lldb::SBAddress &, lldb::SBAddress &),
221  curr_frame_pc, parent_frame_addr);
222 
223  SBSymbolContext sb_sc;
224  if (m_opaque_up.get() && curr_frame_pc.IsValid()) {
225  if (m_opaque_up->GetParentOfInlinedScope(curr_frame_pc.ref(), sb_sc.ref(),
226  parent_frame_addr.ref()))
227  return LLDB_RECORD_RESULT(sb_sc);
228  }
230 }
231 
232 namespace lldb_private {
233 namespace repro {
234 
235 template <>
239  (const lldb_private::SymbolContext *));
242  const lldb::SBSymbolContext &,
243  SBSymbolContext, operator=,(const lldb::SBSymbolContext &));
245  LLDB_REGISTER_METHOD_CONST(bool, SBSymbolContext, operator bool, ());
248  ());
257  (lldb::SBFunction));
263  (lldb::SBStream &));
266  (const lldb::SBAddress &, lldb::SBAddress &));
267 }
268 
269 }
270 }
lldb::SBFunction GetFunction()
size_t PutCString(llvm::StringRef cstr)
Output a C string to the stream.
Definition: Stream.cpp:61
The registry contains a unique mapping between functions and their ID.
Enumerations for broadcasting.
Definition: SBLaunchInfo.h:14
lldb_private::SymbolContext * get() const
#define LLDB_RECORD_CONSTRUCTOR_NO_ARGS(Class)
A stream class that can stream formatted output to a file.
Definition: Stream.h:28
lldb::SBModule GetModule()
Defines a symbol context baton that can be handed other debug core functions.
Definition: SymbolContext.h:33
void RegisterMethods< SBSymbolContext >(Registry &R)
void Clear()
Clear the object&#39;s state.
Definition: LineEntry.cpp:34
SBSymbolContext GetParentOfInlinedScope(const SBAddress &curr_frame_pc, SBAddress &parent_frame_addr) const
lldb_private::Symbol * get()
Definition: SBSymbol.cpp:152
void SetModule(lldb::SBModule module)
A class that describes a function.
Definition: Function.h:323
CompileUnit * comp_unit
The CompileUnit for a given query.
lldb::SBLineEntry GetLineEntry()
lldb::SBCompileUnit GetCompileUnit()
Symbol * symbol
The Symbol for a given query.
void SetFunction(lldb::SBFunction function)
Function * function
The Function for a given query.
bool IsValid() const
Definition: SBLineEntry.cpp:75
class LLDB_API SBCompileUnit
Definition: SBDefines.h:35
#define LLDB_REGISTER_CONSTRUCTOR(Class, Signature)
#define LLDB_RECORD_METHOD_NO_ARGS(Result, Class, Method)
void SetCompileUnit(lldb::SBCompileUnit compile_unit)
void SetSymbolContext(const lldb_private::SymbolContext *sc_ptr)
std::unique_ptr< T > clone(const std::unique_ptr< T > &src)
Definition: Utils.h:17
lldb_private::Address & ref()
Definition: SBAddress.cpp:188
lldb_private::SymbolContext * operator->() const
#define LLDB_RECORD_CONSTRUCTOR(Class, Signature,...)
class LLDB_API SBBlock
Definition: SBDefines.h:23
void SetLineEntry(lldb::SBLineEntry line_entry)
#define LLDB_RECORD_METHOD(Result, Class, Method, Signature,...)
lldb_private::SymbolContext & operator*()
lldb_private::SymbolContext & ref()
void SetSymbol(lldb::SBSymbol symbol)
lldb_private::Stream & ref()
Definition: SBStream.cpp:162
#define LLDB_RECORD_METHOD_CONST(Result, Class, Method, Signature,...)
lldb::SBSymbol GetSymbol()
const lldb::SBSymbolContext & operator=(const lldb::SBSymbolContext &rhs)
void SetBlock(lldb::SBBlock block)
lldb::ModuleSP module_sp
The Module for a given query.
LineEntry line_entry
The LineEntry for a given query.
Definition: SBAddress.h:15
lldb::SBBlock GetBlock()
#define LLDB_REGISTER_METHOD(Result, Class, Method, Signature)
bool GetDescription(lldb::SBStream &description)
#define LLDB_RECORD_METHOD_CONST_NO_ARGS(Result, Class, Method)
Block * block
The Block for a given query.
#define LLDB_RECORD_RESULT(Result)
bool IsValid() const
Definition: SBAddress.cpp:79
#define LLDB_REGISTER_METHOD_CONST(Result, Class, Method, Signature)