LLDB  mainline
StackFrame.cpp
Go to the documentation of this file.
1 //===-- StackFrame.cpp ----------------------------------------------------===//
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 "lldb/Core/Debugger.h"
11 #include "lldb/Core/Disassembler.h"
12 #include "lldb/Core/FormatEntity.h"
13 #include "lldb/Core/Mangled.h"
14 #include "lldb/Core/Module.h"
15 #include "lldb/Core/Value.h"
20 #include "lldb/Symbol/Function.h"
21 #include "lldb/Symbol/Symbol.h"
23 #include "lldb/Symbol/Type.h"
25 #include "lldb/Target/ABI.h"
27 #include "lldb/Target/Process.h"
30 #include "lldb/Target/Target.h"
31 #include "lldb/Target/Thread.h"
32 #include "lldb/Utility/Log.h"
34 
35 #include "lldb/lldb-enumerations.h"
36 
37 #include <memory>
38 
39 using namespace lldb;
40 using namespace lldb_private;
41 
42 // The first bits in the flags are reserved for the SymbolContext::Scope bits
43 // so we know if we have tried to look up information in our internal symbol
44 // context (m_sc) already.
45 #define RESOLVED_FRAME_CODE_ADDR (uint32_t(eSymbolContextEverything + 1))
46 #define RESOLVED_FRAME_ID_SYMBOL_SCOPE (RESOLVED_FRAME_CODE_ADDR << 1)
47 #define GOT_FRAME_BASE (RESOLVED_FRAME_ID_SYMBOL_SCOPE << 1)
48 #define RESOLVED_VARIABLES (GOT_FRAME_BASE << 1)
49 #define RESOLVED_GLOBAL_VARIABLES (RESOLVED_VARIABLES << 1)
50 
51 StackFrame::StackFrame(const ThreadSP &thread_sp, user_id_t frame_idx,
52  user_id_t unwind_frame_index, addr_t cfa,
53  bool cfa_is_valid, addr_t pc, StackFrame::Kind kind,
54  bool behaves_like_zeroth_frame,
55  const SymbolContext *sc_ptr)
56  : m_thread_wp(thread_sp), m_frame_index(frame_idx),
57  m_concrete_frame_index(unwind_frame_index), m_reg_context_sp(),
58  m_id(pc, cfa, nullptr), m_frame_code_addr(pc), m_sc(), m_flags(),
59  m_frame_base(), m_frame_base_error(), m_cfa_is_valid(cfa_is_valid),
60  m_stack_frame_kind(kind),
61  m_behaves_like_zeroth_frame(behaves_like_zeroth_frame),
62  m_variable_list_sp(), m_variable_list_value_objects(),
63  m_recognized_frame_sp(), m_disassembly(), m_mutex() {
64  // If we don't have a CFA value, use the frame index for our StackID so that
65  // recursive functions properly aren't confused with one another on a history
66  // stack.
67  if (IsHistorical() && !m_cfa_is_valid) {
68  m_id.SetCFA(m_frame_index);
69  }
70 
71  if (sc_ptr != nullptr) {
72  m_sc = *sc_ptr;
73  m_flags.Set(m_sc.GetResolvedMask());
74  }
75 }
76 
77 StackFrame::StackFrame(const ThreadSP &thread_sp, user_id_t frame_idx,
78  user_id_t unwind_frame_index,
79  const RegisterContextSP &reg_context_sp, addr_t cfa,
80  addr_t pc, bool behaves_like_zeroth_frame,
81  const SymbolContext *sc_ptr)
82  : m_thread_wp(thread_sp), m_frame_index(frame_idx),
83  m_concrete_frame_index(unwind_frame_index),
84  m_reg_context_sp(reg_context_sp), m_id(pc, cfa, nullptr),
85  m_frame_code_addr(pc), m_sc(), m_flags(), m_frame_base(),
86  m_frame_base_error(), m_cfa_is_valid(true),
87  m_stack_frame_kind(StackFrame::Kind::Regular),
88  m_behaves_like_zeroth_frame(behaves_like_zeroth_frame),
89  m_variable_list_sp(), m_variable_list_value_objects(),
90  m_recognized_frame_sp(), m_disassembly(), m_mutex() {
91  if (sc_ptr != nullptr) {
92  m_sc = *sc_ptr;
93  m_flags.Set(m_sc.GetResolvedMask());
94  }
95 
96  if (reg_context_sp && !m_sc.target_sp) {
97  m_sc.target_sp = reg_context_sp->CalculateTarget();
98  if (m_sc.target_sp)
99  m_flags.Set(eSymbolContextTarget);
100  }
101 }
102 
103 StackFrame::StackFrame(const ThreadSP &thread_sp, user_id_t frame_idx,
104  user_id_t unwind_frame_index,
105  const RegisterContextSP &reg_context_sp, addr_t cfa,
106  const Address &pc_addr, bool behaves_like_zeroth_frame,
107  const SymbolContext *sc_ptr)
108  : m_thread_wp(thread_sp), m_frame_index(frame_idx),
109  m_concrete_frame_index(unwind_frame_index),
110  m_reg_context_sp(reg_context_sp),
111  m_id(pc_addr.GetLoadAddress(thread_sp->CalculateTarget().get()), cfa,
112  nullptr),
113  m_frame_code_addr(pc_addr), m_sc(), m_flags(), m_frame_base(),
114  m_frame_base_error(), m_cfa_is_valid(true),
115  m_stack_frame_kind(StackFrame::Kind::Regular),
116  m_behaves_like_zeroth_frame(behaves_like_zeroth_frame),
117  m_variable_list_sp(), m_variable_list_value_objects(),
118  m_recognized_frame_sp(), m_disassembly(), m_mutex() {
119  if (sc_ptr != nullptr) {
120  m_sc = *sc_ptr;
121  m_flags.Set(m_sc.GetResolvedMask());
122  }
123 
124  if (!m_sc.target_sp && reg_context_sp) {
125  m_sc.target_sp = reg_context_sp->CalculateTarget();
126  if (m_sc.target_sp)
127  m_flags.Set(eSymbolContextTarget);
128  }
129 
130  ModuleSP pc_module_sp(pc_addr.GetModule());
131  if (!m_sc.module_sp || m_sc.module_sp != pc_module_sp) {
132  if (pc_module_sp) {
133  m_sc.module_sp = pc_module_sp;
134  m_flags.Set(eSymbolContextModule);
135  } else {
136  m_sc.module_sp.reset();
137  }
138  }
139 }
140 
141 StackFrame::~StackFrame() = default;
142 
143 StackID &StackFrame::GetStackID() {
144  std::lock_guard<std::recursive_mutex> guard(m_mutex);
145  // Make sure we have resolved the StackID object's symbol context scope if we
146  // already haven't looked it up.
147 
149  if (m_id.GetSymbolContextScope()) {
150  // We already have a symbol context scope, we just don't have our flag
151  // bit set.
153  } else {
154  // Calculate the frame block and use this for the stack ID symbol context
155  // scope if we have one.
157  if (scope == nullptr) {
158  // We don't have a block, so use the symbol
159  if (m_flags.IsClear(eSymbolContextSymbol))
160  GetSymbolContext(eSymbolContextSymbol);
161 
162  // It is ok if m_sc.symbol is nullptr here
163  scope = m_sc.symbol;
164  }
165  // Set the symbol context scope (the accessor will set the
166  // RESOLVED_FRAME_ID_SYMBOL_SCOPE bit in m_flags).
167  SetSymbolContextScope(scope);
168  }
169  }
170  return m_id;
171 }
172 
174  ThreadSP thread_sp = GetThread();
175  if (thread_sp)
176  return thread_sp->GetStackFrameList()->GetVisibleStackFrameIndex(
177  m_frame_index);
178  else
179  return m_frame_index;
180 }
181 
183  std::lock_guard<std::recursive_mutex> guard(m_mutex);
185  m_id.SetSymbolContextScope(symbol_scope);
186 }
187 
189  std::lock_guard<std::recursive_mutex> guard(m_mutex);
193 
194  // Resolve the PC into a temporary address because if ResolveLoadAddress
195  // fails to resolve the address, it will clear the address object...
196  ThreadSP thread_sp(GetThread());
197  if (thread_sp) {
198  TargetSP target_sp(thread_sp->CalculateTarget());
199  if (target_sp) {
200  const bool allow_section_end = true;
202  m_frame_code_addr.GetOffset(), target_sp.get(),
203  AddressClass::eCode, allow_section_end)) {
204  ModuleSP module_sp(m_frame_code_addr.GetModule());
205  if (module_sp) {
206  m_sc.module_sp = module_sp;
207  m_flags.Set(eSymbolContextModule);
208  }
209  }
210  }
211  }
212  }
213  return m_frame_code_addr;
214 }
215 
216 // This can't be rewritten into a call to
217 // RegisterContext::GetPCForSymbolication because this
218 // StackFrame may have been constructed with a special pc,
219 // e.g. tail-call artificial frames.
221  Address lookup_addr(GetFrameCodeAddress());
222  if (!lookup_addr.IsValid())
223  return lookup_addr;
225  return lookup_addr;
226 
227  addr_t offset = lookup_addr.GetOffset();
228  if (offset > 0) {
229  lookup_addr.SetOffset(offset - 1);
230  } else {
231  // lookup_addr is the start of a section. We need do the math on the
232  // actual load address and re-compute the section. We're working with
233  // a 'noreturn' function at the end of a section.
234  TargetSP target_sp = CalculateTarget();
235  if (target_sp) {
236  addr_t addr_minus_one = lookup_addr.GetOpcodeLoadAddress(
237  target_sp.get(), AddressClass::eCode) -
238  1;
239  lookup_addr.SetOpcodeLoadAddress(addr_minus_one, target_sp.get());
240  }
241  }
242  return lookup_addr;
243 }
244 
246  std::lock_guard<std::recursive_mutex> guard(m_mutex);
247  // We can't change the pc value of a history stack frame - it is immutable.
248  if (IsHistorical())
249  return false;
251  m_sc.Clear(false);
252  m_flags.Reset(0);
253  ThreadSP thread_sp(GetThread());
254  if (thread_sp)
255  thread_sp->ClearStackFrames();
256  return true;
257 }
258 
259 const char *StackFrame::Disassemble() {
260  std::lock_guard<std::recursive_mutex> guard(m_mutex);
261  if (!m_disassembly.Empty())
262  return m_disassembly.GetData();
263 
264  ExecutionContext exe_ctx(shared_from_this());
265  if (Target *target = exe_ctx.GetTargetPtr()) {
266  Disassembler::Disassemble(target->GetDebugger(), target->GetArchitecture(),
267  *this, m_disassembly);
268  }
269 
270  return m_disassembly.Empty() ? nullptr : m_disassembly.GetData();
271 }
272 
274  if (m_sc.block == nullptr && m_flags.IsClear(eSymbolContextBlock))
275  GetSymbolContext(eSymbolContextBlock);
276 
277  if (m_sc.block) {
278  Block *inline_block = m_sc.block->GetContainingInlinedBlock();
279  if (inline_block) {
280  // Use the block with the inlined function info as the frame block we
281  // want this frame to have only the variables for the inlined function
282  // and its non-inlined block child blocks.
283  return inline_block;
284  } else {
285  // This block is not contained within any inlined function blocks with so
286  // we want to use the top most function block.
287  return &m_sc.function->GetBlock(false);
288  }
289  }
290  return nullptr;
291 }
292 
293 // Get the symbol context if we already haven't done so by resolving the
294 // PC address as much as possible. This way when we pass around a
295 // StackFrame object, everyone will have as much information as possible and no
296 // one will ever have to look things up manually.
297 const SymbolContext &
298 StackFrame::GetSymbolContext(SymbolContextItem resolve_scope) {
299  std::lock_guard<std::recursive_mutex> guard(m_mutex);
300  // Copy our internal symbol context into "sc".
301  if ((m_flags.Get() & resolve_scope) != resolve_scope) {
302  uint32_t resolved = 0;
303 
304  // If the target was requested add that:
305  if (!m_sc.target_sp) {
307  if (m_sc.target_sp)
308  resolved |= eSymbolContextTarget;
309  }
310 
311  // Resolve our PC to section offset if we haven't already done so and if we
312  // don't have a module. The resolved address section will contain the
313  // module to which it belongs
316 
317  // If this is not frame zero, then we need to subtract 1 from the PC value
318  // when doing address lookups since the PC will be on the instruction
319  // following the function call instruction...
321 
322  if (m_sc.module_sp) {
323  // We have something in our stack frame symbol context, lets check if we
324  // haven't already tried to lookup one of those things. If we haven't
325  // then we will do the query.
326 
327  SymbolContextItem actual_resolve_scope = SymbolContextItem(0);
328 
329  if (resolve_scope & eSymbolContextCompUnit) {
330  if (m_flags.IsClear(eSymbolContextCompUnit)) {
331  if (m_sc.comp_unit)
332  resolved |= eSymbolContextCompUnit;
333  else
334  actual_resolve_scope |= eSymbolContextCompUnit;
335  }
336  }
337 
338  if (resolve_scope & eSymbolContextFunction) {
339  if (m_flags.IsClear(eSymbolContextFunction)) {
340  if (m_sc.function)
341  resolved |= eSymbolContextFunction;
342  else
343  actual_resolve_scope |= eSymbolContextFunction;
344  }
345  }
346 
347  if (resolve_scope & eSymbolContextBlock) {
348  if (m_flags.IsClear(eSymbolContextBlock)) {
349  if (m_sc.block)
350  resolved |= eSymbolContextBlock;
351  else
352  actual_resolve_scope |= eSymbolContextBlock;
353  }
354  }
355 
356  if (resolve_scope & eSymbolContextSymbol) {
357  if (m_flags.IsClear(eSymbolContextSymbol)) {
358  if (m_sc.symbol)
359  resolved |= eSymbolContextSymbol;
360  else
361  actual_resolve_scope |= eSymbolContextSymbol;
362  }
363  }
364 
365  if (resolve_scope & eSymbolContextLineEntry) {
366  if (m_flags.IsClear(eSymbolContextLineEntry)) {
367  if (m_sc.line_entry.IsValid())
368  resolved |= eSymbolContextLineEntry;
369  else
370  actual_resolve_scope |= eSymbolContextLineEntry;
371  }
372  }
373 
374  if (actual_resolve_scope) {
375  // We might be resolving less information than what is already in our
376  // current symbol context so resolve into a temporary symbol context
377  // "sc" so we don't clear out data we have already found in "m_sc"
378  SymbolContext sc;
379  // Set flags that indicate what we have tried to resolve
380  resolved |= m_sc.module_sp->ResolveSymbolContextForAddress(
381  lookup_addr, actual_resolve_scope, sc);
382  // Only replace what we didn't already have as we may have information
383  // for an inlined function scope that won't match what a standard
384  // lookup by address would match
385  if ((resolved & eSymbolContextCompUnit) && m_sc.comp_unit == nullptr)
386  m_sc.comp_unit = sc.comp_unit;
387  if ((resolved & eSymbolContextFunction) && m_sc.function == nullptr)
388  m_sc.function = sc.function;
389  if ((resolved & eSymbolContextBlock) && m_sc.block == nullptr)
390  m_sc.block = sc.block;
391  if ((resolved & eSymbolContextSymbol) && m_sc.symbol == nullptr)
392  m_sc.symbol = sc.symbol;
393  if ((resolved & eSymbolContextLineEntry) &&
394  !m_sc.line_entry.IsValid()) {
397  }
398  }
399  } else {
400  // If we don't have a module, then we can't have the compile unit,
401  // function, block, line entry or symbol, so we can safely call
402  // ResolveSymbolContextForAddress with our symbol context member m_sc.
403  if (m_sc.target_sp) {
404  resolved |= m_sc.target_sp->GetImages().ResolveSymbolContextForAddress(
405  lookup_addr, resolve_scope, m_sc);
406  }
407  }
408 
409  // Update our internal flags so we remember what we have tried to locate so
410  // we don't have to keep trying when more calls to this function are made.
411  // We might have dug up more information that was requested (for example if
412  // we were asked to only get the block, we will have gotten the compile
413  // unit, and function) so set any additional bits that we resolved
414  m_flags.Set(resolve_scope | resolved);
415  }
416 
417  // Return the symbol context with everything that was possible to resolve
418  // resolved.
419  return m_sc;
420 }
421 
422 VariableList *StackFrame::GetVariableList(bool get_file_globals) {
423  std::lock_guard<std::recursive_mutex> guard(m_mutex);
426 
427  Block *frame_block = GetFrameBlock();
428 
429  if (frame_block) {
430  const bool get_child_variables = true;
431  const bool can_create = true;
432  const bool stop_if_child_block_is_inlined_function = true;
433  m_variable_list_sp = std::make_shared<VariableList>();
434  frame_block->AppendBlockVariables(can_create, get_child_variables,
435  stop_if_child_block_is_inlined_function,
436  [](Variable *v) { return true; },
437  m_variable_list_sp.get());
438  }
439  }
440 
441  if (m_flags.IsClear(RESOLVED_GLOBAL_VARIABLES) && get_file_globals) {
443 
444  if (m_flags.IsClear(eSymbolContextCompUnit))
445  GetSymbolContext(eSymbolContextCompUnit);
446 
447  if (m_sc.comp_unit) {
448  VariableListSP global_variable_list_sp(
450  if (m_variable_list_sp)
451  m_variable_list_sp->AddVariables(global_variable_list_sp.get());
452  else
453  m_variable_list_sp = global_variable_list_sp;
454  }
455  }
456 
457  return m_variable_list_sp.get();
458 }
459 
460 VariableListSP
462  bool must_have_valid_location) {
463  std::lock_guard<std::recursive_mutex> guard(m_mutex);
464  // We can't fetch variable information for a history stack frame.
465  if (IsHistorical())
466  return VariableListSP();
467 
468  VariableListSP var_list_sp(new VariableList);
469  GetSymbolContext(eSymbolContextCompUnit | eSymbolContextBlock);
470 
471  if (m_sc.block) {
472  const bool can_create = true;
473  const bool get_parent_variables = true;
474  const bool stop_if_block_is_inlined_function = true;
476  can_create, get_parent_variables, stop_if_block_is_inlined_function,
477  [this, must_have_valid_location](Variable *v) {
478  return v->IsInScope(this) && (!must_have_valid_location ||
479  v->LocationIsValidForFrame(this));
480  },
481  var_list_sp.get());
482  }
483 
484  if (m_sc.comp_unit && get_file_globals) {
485  VariableListSP global_variable_list_sp(
487  if (global_variable_list_sp)
488  var_list_sp->AddVariables(global_variable_list_sp.get());
489  }
490 
491  return var_list_sp;
492 }
493 
495  llvm::StringRef var_expr, DynamicValueType use_dynamic, uint32_t options,
496  VariableSP &var_sp, Status &error) {
497  llvm::StringRef original_var_expr = var_expr;
498  // We can't fetch variable information for a history stack frame.
499  if (IsHistorical())
500  return ValueObjectSP();
501 
502  if (var_expr.empty()) {
503  error.SetErrorStringWithFormat("invalid variable path '%s'",
504  var_expr.str().c_str());
505  return ValueObjectSP();
506  }
507 
508  const bool check_ptr_vs_member =
509  (options & eExpressionPathOptionCheckPtrVsMember) != 0;
510  const bool no_fragile_ivar =
512  const bool no_synth_child =
514  // const bool no_synth_array = (options &
515  // eExpressionPathOptionsNoSyntheticArrayRange) != 0;
516  error.Clear();
517  bool deref = false;
518  bool address_of = false;
519  ValueObjectSP valobj_sp;
520  const bool get_file_globals = true;
521  // When looking up a variable for an expression, we need only consider the
522  // variables that are in scope.
523  VariableListSP var_list_sp(GetInScopeVariableList(get_file_globals));
524  VariableList *variable_list = var_list_sp.get();
525 
526  if (!variable_list)
527  return ValueObjectSP();
528 
529  // If first character is a '*', then show pointer contents
530  std::string var_expr_storage;
531  if (var_expr[0] == '*') {
532  deref = true;
533  var_expr = var_expr.drop_front(); // Skip the '*'
534  } else if (var_expr[0] == '&') {
535  address_of = true;
536  var_expr = var_expr.drop_front(); // Skip the '&'
537  }
538 
539  size_t separator_idx = var_expr.find_first_of(".-[=+~|&^%#@!/?,<>{}");
540  StreamString var_expr_path_strm;
541 
542  ConstString name_const_string(var_expr.substr(0, separator_idx));
543 
544  var_sp = variable_list->FindVariable(name_const_string, false);
545 
546  bool synthetically_added_instance_object = false;
547 
548  if (var_sp) {
549  var_expr = var_expr.drop_front(name_const_string.GetLength());
550  }
551 
552  if (!var_sp && (options & eExpressionPathOptionsAllowDirectIVarAccess)) {
553  // Check for direct ivars access which helps us with implicit access to
554  // ivars with the "this->" or "self->"
555  GetSymbolContext(eSymbolContextFunction | eSymbolContextBlock);
556  lldb::LanguageType method_language = eLanguageTypeUnknown;
557  bool is_instance_method = false;
558  ConstString method_object_name;
559  if (m_sc.GetFunctionMethodInfo(method_language, is_instance_method,
560  method_object_name)) {
561  if (is_instance_method && method_object_name) {
562  var_sp = variable_list->FindVariable(method_object_name);
563  if (var_sp) {
564  separator_idx = 0;
565  var_expr_storage = "->";
566  var_expr_storage += var_expr;
567  var_expr = var_expr_storage;
568  synthetically_added_instance_object = true;
569  }
570  }
571  }
572  }
573 
574  if (!var_sp && (options & eExpressionPathOptionsInspectAnonymousUnions)) {
575  // Check if any anonymous unions are there which contain a variable with
576  // the name we need
577  for (const VariableSP &variable_sp : *variable_list) {
578  if (!variable_sp)
579  continue;
580  if (!variable_sp->GetName().IsEmpty())
581  continue;
582 
583  Type *var_type = variable_sp->GetType();
584  if (!var_type)
585  continue;
586 
587  if (!var_type->GetForwardCompilerType().IsAnonymousType())
588  continue;
589  valobj_sp = GetValueObjectForFrameVariable(variable_sp, use_dynamic);
590  if (!valobj_sp)
591  return valobj_sp;
592  valobj_sp = valobj_sp->GetChildMemberWithName(name_const_string, true);
593  if (valobj_sp)
594  break;
595  }
596  }
597 
598  if (var_sp && !valobj_sp) {
599  valobj_sp = GetValueObjectForFrameVariable(var_sp, use_dynamic);
600  if (!valobj_sp)
601  return valobj_sp;
602  }
603  if (!valobj_sp) {
604  error.SetErrorStringWithFormat("no variable named '%s' found in this frame",
605  name_const_string.GetCString());
606  return ValueObjectSP();
607  }
608 
609  // We are dumping at least one child
610  while (!var_expr.empty()) {
611  // Calculate the next separator index ahead of time
612  ValueObjectSP child_valobj_sp;
613  const char separator_type = var_expr[0];
614  bool expr_is_ptr = false;
615  switch (separator_type) {
616  case '-':
617  expr_is_ptr = true;
618  if (var_expr.size() >= 2 && var_expr[1] != '>')
619  return ValueObjectSP();
620 
621  if (no_fragile_ivar) {
622  // Make sure we aren't trying to deref an objective
623  // C ivar if this is not allowed
624  const uint32_t pointer_type_flags =
625  valobj_sp->GetCompilerType().GetTypeInfo(nullptr);
626  if ((pointer_type_flags & eTypeIsObjC) &&
627  (pointer_type_flags & eTypeIsPointer)) {
628  // This was an objective C object pointer and it was requested we
629  // skip any fragile ivars so return nothing here
630  return ValueObjectSP();
631  }
632  }
633 
634  // If we have a non pointer type with a sythetic value then lets check if
635  // we have an sythetic dereference specified.
636  if (!valobj_sp->IsPointerType() && valobj_sp->HasSyntheticValue()) {
637  Status deref_error;
638  if (valobj_sp->GetCompilerType().IsReferenceType()) {
639  valobj_sp = valobj_sp->GetSyntheticValue()->Dereference(deref_error);
640  if (error.Fail()) {
641  error.SetErrorStringWithFormatv(
642  "Failed to dereference reference type: %s", deref_error);
643  return ValueObjectSP();
644  }
645  }
646 
647  valobj_sp = valobj_sp->Dereference(deref_error);
648  if (error.Fail()) {
649  error.SetErrorStringWithFormatv(
650  "Failed to dereference sythetic value: {0}", deref_error);
651  return ValueObjectSP();
652  }
653  // Some synthetic plug-ins fail to set the error in Dereference
654  if (!valobj_sp) {
655  error.SetErrorString("Failed to dereference sythetic value");
656  return ValueObjectSP();
657  }
658  expr_is_ptr = false;
659  }
660 
661  var_expr = var_expr.drop_front(); // Remove the '-'
662  LLVM_FALLTHROUGH;
663  case '.': {
664  var_expr = var_expr.drop_front(); // Remove the '.' or '>'
665  separator_idx = var_expr.find_first_of(".-[");
666  ConstString child_name(var_expr.substr(0, var_expr.find_first_of(".-[")));
667 
668  if (check_ptr_vs_member) {
669  // We either have a pointer type and need to verify valobj_sp is a
670  // pointer, or we have a member of a class/union/struct being accessed
671  // with the . syntax and need to verify we don't have a pointer.
672  const bool actual_is_ptr = valobj_sp->IsPointerType();
673 
674  if (actual_is_ptr != expr_is_ptr) {
675  // Incorrect use of "." with a pointer, or "->" with a
676  // class/union/struct instance or reference.
677  valobj_sp->GetExpressionPath(var_expr_path_strm);
678  if (actual_is_ptr)
679  error.SetErrorStringWithFormat(
680  "\"%s\" is a pointer and . was used to attempt to access "
681  "\"%s\". Did you mean \"%s->%s\"?",
682  var_expr_path_strm.GetData(), child_name.GetCString(),
683  var_expr_path_strm.GetData(), var_expr.str().c_str());
684  else
685  error.SetErrorStringWithFormat(
686  "\"%s\" is not a pointer and -> was used to attempt to "
687  "access \"%s\". Did you mean \"%s.%s\"?",
688  var_expr_path_strm.GetData(), child_name.GetCString(),
689  var_expr_path_strm.GetData(), var_expr.str().c_str());
690  return ValueObjectSP();
691  }
692  }
693  child_valobj_sp = valobj_sp->GetChildMemberWithName(child_name, true);
694  if (!child_valobj_sp) {
695  if (!no_synth_child) {
696  child_valobj_sp = valobj_sp->GetSyntheticValue();
697  if (child_valobj_sp)
698  child_valobj_sp =
699  child_valobj_sp->GetChildMemberWithName(child_name, true);
700  }
701 
702  if (no_synth_child || !child_valobj_sp) {
703  // No child member with name "child_name"
704  if (synthetically_added_instance_object) {
705  // We added a "this->" or "self->" to the beginning of the
706  // expression and this is the first pointer ivar access, so just
707  // return the normal error
708  error.SetErrorStringWithFormat(
709  "no variable or instance variable named '%s' found in "
710  "this frame",
711  name_const_string.GetCString());
712  } else {
713  valobj_sp->GetExpressionPath(var_expr_path_strm);
714  if (child_name) {
715  error.SetErrorStringWithFormat(
716  "\"%s\" is not a member of \"(%s) %s\"",
717  child_name.GetCString(),
718  valobj_sp->GetTypeName().AsCString("<invalid type>"),
719  var_expr_path_strm.GetData());
720  } else {
721  error.SetErrorStringWithFormat(
722  "incomplete expression path after \"%s\" in \"%s\"",
723  var_expr_path_strm.GetData(),
724  original_var_expr.str().c_str());
725  }
726  }
727  return ValueObjectSP();
728  }
729  }
730  synthetically_added_instance_object = false;
731  // Remove the child name from the path
732  var_expr = var_expr.drop_front(child_name.GetLength());
733  if (use_dynamic != eNoDynamicValues) {
734  ValueObjectSP dynamic_value_sp(
735  child_valobj_sp->GetDynamicValue(use_dynamic));
736  if (dynamic_value_sp)
737  child_valobj_sp = dynamic_value_sp;
738  }
739  } break;
740 
741  case '[': {
742  // Array member access, or treating pointer as an array Need at least two
743  // brackets and a number
744  if (var_expr.size() <= 2) {
745  error.SetErrorStringWithFormat(
746  "invalid square bracket encountered after \"%s\" in \"%s\"",
747  var_expr_path_strm.GetData(), var_expr.str().c_str());
748  return ValueObjectSP();
749  }
750 
751  // Drop the open brace.
752  var_expr = var_expr.drop_front();
753  long child_index = 0;
754 
755  // If there's no closing brace, this is an invalid expression.
756  size_t end_pos = var_expr.find_first_of(']');
757  if (end_pos == llvm::StringRef::npos) {
758  error.SetErrorStringWithFormat(
759  "missing closing square bracket in expression \"%s\"",
760  var_expr_path_strm.GetData());
761  return ValueObjectSP();
762  }
763  llvm::StringRef index_expr = var_expr.take_front(end_pos);
764  llvm::StringRef original_index_expr = index_expr;
765  // Drop all of "[index_expr]"
766  var_expr = var_expr.drop_front(end_pos + 1);
767 
768  if (index_expr.consumeInteger(0, child_index)) {
769  // If there was no integer anywhere in the index expression, this is
770  // erroneous expression.
771  error.SetErrorStringWithFormat("invalid index expression \"%s\"",
772  index_expr.str().c_str());
773  return ValueObjectSP();
774  }
775 
776  if (index_expr.empty()) {
777  // The entire index expression was a single integer.
778 
779  if (valobj_sp->GetCompilerType().IsPointerToScalarType() && deref) {
780  // what we have is *ptr[low]. the most similar C++ syntax is to deref
781  // ptr and extract bit low out of it. reading array item low would be
782  // done by saying ptr[low], without a deref * sign
783  Status error;
784  ValueObjectSP temp(valobj_sp->Dereference(error));
785  if (error.Fail()) {
786  valobj_sp->GetExpressionPath(var_expr_path_strm);
787  error.SetErrorStringWithFormat(
788  "could not dereference \"(%s) %s\"",
789  valobj_sp->GetTypeName().AsCString("<invalid type>"),
790  var_expr_path_strm.GetData());
791  return ValueObjectSP();
792  }
793  valobj_sp = temp;
794  deref = false;
795  } else if (valobj_sp->GetCompilerType().IsArrayOfScalarType() &&
796  deref) {
797  // what we have is *arr[low]. the most similar C++ syntax is to get
798  // arr[0] (an operation that is equivalent to deref-ing arr) and
799  // extract bit low out of it. reading array item low would be done by
800  // saying arr[low], without a deref * sign
801  Status error;
802  ValueObjectSP temp(valobj_sp->GetChildAtIndex(0, true));
803  if (error.Fail()) {
804  valobj_sp->GetExpressionPath(var_expr_path_strm);
805  error.SetErrorStringWithFormat(
806  "could not get item 0 for \"(%s) %s\"",
807  valobj_sp->GetTypeName().AsCString("<invalid type>"),
808  var_expr_path_strm.GetData());
809  return ValueObjectSP();
810  }
811  valobj_sp = temp;
812  deref = false;
813  }
814 
815  bool is_incomplete_array = false;
816  if (valobj_sp->IsPointerType()) {
817  bool is_objc_pointer = true;
818 
819  if (valobj_sp->GetCompilerType().GetMinimumLanguage() !=
821  is_objc_pointer = false;
822  else if (!valobj_sp->GetCompilerType().IsPointerType())
823  is_objc_pointer = false;
824 
825  if (no_synth_child && is_objc_pointer) {
826  error.SetErrorStringWithFormat(
827  "\"(%s) %s\" is an Objective-C pointer, and cannot be "
828  "subscripted",
829  valobj_sp->GetTypeName().AsCString("<invalid type>"),
830  var_expr_path_strm.GetData());
831 
832  return ValueObjectSP();
833  } else if (is_objc_pointer) {
834  // dereferencing ObjC variables is not valid.. so let's try and
835  // recur to synthetic children
836  ValueObjectSP synthetic = valobj_sp->GetSyntheticValue();
837  if (!synthetic /* no synthetic */
838  || synthetic == valobj_sp) /* synthetic is the same as
839  the original object */
840  {
841  valobj_sp->GetExpressionPath(var_expr_path_strm);
842  error.SetErrorStringWithFormat(
843  "\"(%s) %s\" is not an array type",
844  valobj_sp->GetTypeName().AsCString("<invalid type>"),
845  var_expr_path_strm.GetData());
846  } else if (
847  static_cast<uint32_t>(child_index) >=
848  synthetic
849  ->GetNumChildren() /* synthetic does not have that many values */) {
850  valobj_sp->GetExpressionPath(var_expr_path_strm);
851  error.SetErrorStringWithFormat(
852  "array index %ld is not valid for \"(%s) %s\"", child_index,
853  valobj_sp->GetTypeName().AsCString("<invalid type>"),
854  var_expr_path_strm.GetData());
855  } else {
856  child_valobj_sp = synthetic->GetChildAtIndex(child_index, true);
857  if (!child_valobj_sp) {
858  valobj_sp->GetExpressionPath(var_expr_path_strm);
859  error.SetErrorStringWithFormat(
860  "array index %ld is not valid for \"(%s) %s\"", child_index,
861  valobj_sp->GetTypeName().AsCString("<invalid type>"),
862  var_expr_path_strm.GetData());
863  }
864  }
865  } else {
866  child_valobj_sp =
867  valobj_sp->GetSyntheticArrayMember(child_index, true);
868  if (!child_valobj_sp) {
869  valobj_sp->GetExpressionPath(var_expr_path_strm);
870  error.SetErrorStringWithFormat(
871  "failed to use pointer as array for index %ld for "
872  "\"(%s) %s\"",
873  child_index,
874  valobj_sp->GetTypeName().AsCString("<invalid type>"),
875  var_expr_path_strm.GetData());
876  }
877  }
878  } else if (valobj_sp->GetCompilerType().IsArrayType(
879  nullptr, nullptr, &is_incomplete_array)) {
880  // Pass false to dynamic_value here so we can tell the difference
881  // between no dynamic value and no member of this type...
882  child_valobj_sp = valobj_sp->GetChildAtIndex(child_index, true);
883  if (!child_valobj_sp && (is_incomplete_array || !no_synth_child))
884  child_valobj_sp =
885  valobj_sp->GetSyntheticArrayMember(child_index, true);
886 
887  if (!child_valobj_sp) {
888  valobj_sp->GetExpressionPath(var_expr_path_strm);
889  error.SetErrorStringWithFormat(
890  "array index %ld is not valid for \"(%s) %s\"", child_index,
891  valobj_sp->GetTypeName().AsCString("<invalid type>"),
892  var_expr_path_strm.GetData());
893  }
894  } else if (valobj_sp->GetCompilerType().IsScalarType()) {
895  // this is a bitfield asking to display just one bit
896  child_valobj_sp = valobj_sp->GetSyntheticBitFieldChild(
897  child_index, child_index, true);
898  if (!child_valobj_sp) {
899  valobj_sp->GetExpressionPath(var_expr_path_strm);
900  error.SetErrorStringWithFormat(
901  "bitfield range %ld-%ld is not valid for \"(%s) %s\"",
902  child_index, child_index,
903  valobj_sp->GetTypeName().AsCString("<invalid type>"),
904  var_expr_path_strm.GetData());
905  }
906  } else {
907  ValueObjectSP synthetic = valobj_sp->GetSyntheticValue();
908  if (no_synth_child /* synthetic is forbidden */ ||
909  !synthetic /* no synthetic */
910  || synthetic == valobj_sp) /* synthetic is the same as the
911  original object */
912  {
913  valobj_sp->GetExpressionPath(var_expr_path_strm);
914  error.SetErrorStringWithFormat(
915  "\"(%s) %s\" is not an array type",
916  valobj_sp->GetTypeName().AsCString("<invalid type>"),
917  var_expr_path_strm.GetData());
918  } else if (
919  static_cast<uint32_t>(child_index) >=
920  synthetic
921  ->GetNumChildren() /* synthetic does not have that many values */) {
922  valobj_sp->GetExpressionPath(var_expr_path_strm);
923  error.SetErrorStringWithFormat(
924  "array index %ld is not valid for \"(%s) %s\"", child_index,
925  valobj_sp->GetTypeName().AsCString("<invalid type>"),
926  var_expr_path_strm.GetData());
927  } else {
928  child_valobj_sp = synthetic->GetChildAtIndex(child_index, true);
929  if (!child_valobj_sp) {
930  valobj_sp->GetExpressionPath(var_expr_path_strm);
931  error.SetErrorStringWithFormat(
932  "array index %ld is not valid for \"(%s) %s\"", child_index,
933  valobj_sp->GetTypeName().AsCString("<invalid type>"),
934  var_expr_path_strm.GetData());
935  }
936  }
937  }
938 
939  if (!child_valobj_sp) {
940  // Invalid array index...
941  return ValueObjectSP();
942  }
943 
944  if (use_dynamic != eNoDynamicValues) {
945  ValueObjectSP dynamic_value_sp(
946  child_valobj_sp->GetDynamicValue(use_dynamic));
947  if (dynamic_value_sp)
948  child_valobj_sp = dynamic_value_sp;
949  }
950  // Break out early from the switch since we were able to find the child
951  // member
952  break;
953  }
954 
955  // this is most probably a BitField, let's take a look
956  if (index_expr.front() != '-') {
957  error.SetErrorStringWithFormat("invalid range expression \"'%s'\"",
958  original_index_expr.str().c_str());
959  return ValueObjectSP();
960  }
961 
962  index_expr = index_expr.drop_front();
963  long final_index = 0;
964  if (index_expr.getAsInteger(0, final_index)) {
965  error.SetErrorStringWithFormat("invalid range expression \"'%s'\"",
966  original_index_expr.str().c_str());
967  return ValueObjectSP();
968  }
969 
970  // if the format given is [high-low], swap range
971  if (child_index > final_index) {
972  long temp = child_index;
973  child_index = final_index;
974  final_index = temp;
975  }
976 
977  if (valobj_sp->GetCompilerType().IsPointerToScalarType() && deref) {
978  // what we have is *ptr[low-high]. the most similar C++ syntax is to
979  // deref ptr and extract bits low thru high out of it. reading array
980  // items low thru high would be done by saying ptr[low-high], without a
981  // deref * sign
982  Status error;
983  ValueObjectSP temp(valobj_sp->Dereference(error));
984  if (error.Fail()) {
985  valobj_sp->GetExpressionPath(var_expr_path_strm);
986  error.SetErrorStringWithFormat(
987  "could not dereference \"(%s) %s\"",
988  valobj_sp->GetTypeName().AsCString("<invalid type>"),
989  var_expr_path_strm.GetData());
990  return ValueObjectSP();
991  }
992  valobj_sp = temp;
993  deref = false;
994  } else if (valobj_sp->GetCompilerType().IsArrayOfScalarType() && deref) {
995  // what we have is *arr[low-high]. the most similar C++ syntax is to
996  // get arr[0] (an operation that is equivalent to deref-ing arr) and
997  // extract bits low thru high out of it. reading array items low thru
998  // high would be done by saying arr[low-high], without a deref * sign
999  Status error;
1000  ValueObjectSP temp(valobj_sp->GetChildAtIndex(0, true));
1001  if (error.Fail()) {
1002  valobj_sp->GetExpressionPath(var_expr_path_strm);
1003  error.SetErrorStringWithFormat(
1004  "could not get item 0 for \"(%s) %s\"",
1005  valobj_sp->GetTypeName().AsCString("<invalid type>"),
1006  var_expr_path_strm.GetData());
1007  return ValueObjectSP();
1008  }
1009  valobj_sp = temp;
1010  deref = false;
1011  }
1012 
1013  child_valobj_sp =
1014  valobj_sp->GetSyntheticBitFieldChild(child_index, final_index, true);
1015  if (!child_valobj_sp) {
1016  valobj_sp->GetExpressionPath(var_expr_path_strm);
1017  error.SetErrorStringWithFormat(
1018  "bitfield range %ld-%ld is not valid for \"(%s) %s\"", child_index,
1019  final_index, valobj_sp->GetTypeName().AsCString("<invalid type>"),
1020  var_expr_path_strm.GetData());
1021  }
1022 
1023  if (!child_valobj_sp) {
1024  // Invalid bitfield range...
1025  return ValueObjectSP();
1026  }
1027 
1028  if (use_dynamic != eNoDynamicValues) {
1029  ValueObjectSP dynamic_value_sp(
1030  child_valobj_sp->GetDynamicValue(use_dynamic));
1031  if (dynamic_value_sp)
1032  child_valobj_sp = dynamic_value_sp;
1033  }
1034  // Break out early from the switch since we were able to find the child
1035  // member
1036  break;
1037  }
1038  default:
1039  // Failure...
1040  {
1041  valobj_sp->GetExpressionPath(var_expr_path_strm);
1042  error.SetErrorStringWithFormat(
1043  "unexpected char '%c' encountered after \"%s\" in \"%s\"",
1044  separator_type, var_expr_path_strm.GetData(),
1045  var_expr.str().c_str());
1046 
1047  return ValueObjectSP();
1048  }
1049  }
1050 
1051  if (child_valobj_sp)
1052  valobj_sp = child_valobj_sp;
1053  }
1054  if (valobj_sp) {
1055  if (deref) {
1056  ValueObjectSP deref_valobj_sp(valobj_sp->Dereference(error));
1057  valobj_sp = deref_valobj_sp;
1058  } else if (address_of) {
1059  ValueObjectSP address_of_valobj_sp(valobj_sp->AddressOf(error));
1060  valobj_sp = address_of_valobj_sp;
1061  }
1062  }
1063  return valobj_sp;
1064 }
1065 
1066 bool StackFrame::GetFrameBaseValue(Scalar &frame_base, Status *error_ptr) {
1067  std::lock_guard<std::recursive_mutex> guard(m_mutex);
1068  if (!m_cfa_is_valid) {
1070  "No frame base available for this historical stack frame.");
1071  return false;
1072  }
1073 
1075  if (m_sc.function) {
1076  m_frame_base.Clear();
1078 
1080  ExecutionContext exe_ctx(shared_from_this());
1081  Value expr_value;
1082  addr_t loclist_base_addr = LLDB_INVALID_ADDRESS;
1084  loclist_base_addr =
1086  exe_ctx.GetTargetPtr());
1087 
1089  &exe_ctx, nullptr, loclist_base_addr, nullptr, nullptr,
1090  expr_value, &m_frame_base_error)) {
1091  // We should really have an error if evaluate returns, but in case we
1092  // don't, lets set the error to something at least.
1095  "Evaluation of the frame base expression failed.");
1096  } else {
1097  m_frame_base = expr_value.ResolveValue(&exe_ctx);
1098  }
1099  } else {
1100  m_frame_base_error.SetErrorString("No function in symbol context.");
1101  }
1102  }
1103 
1105  frame_base = m_frame_base;
1106 
1107  if (error_ptr)
1108  *error_ptr = m_frame_base_error;
1109  return m_frame_base_error.Success();
1110 }
1111 
1113  if (!m_sc.function) {
1114  if (error_ptr) {
1115  error_ptr->SetErrorString("No function in symbol context.");
1116  }
1117  return nullptr;
1118  }
1119 
1121 }
1122 
1123 RegisterContextSP StackFrame::GetRegisterContext() {
1124  std::lock_guard<std::recursive_mutex> guard(m_mutex);
1125  if (!m_reg_context_sp) {
1126  ThreadSP thread_sp(GetThread());
1127  if (thread_sp)
1128  m_reg_context_sp = thread_sp->CreateRegisterContextForFrame(this);
1129  }
1130  return m_reg_context_sp;
1131 }
1132 
1134  GetSymbolContext(eSymbolContextLineEntry);
1135  return m_sc.line_entry.IsValid();
1136 }
1137 
1138 ValueObjectSP
1139 StackFrame::GetValueObjectForFrameVariable(const VariableSP &variable_sp,
1140  DynamicValueType use_dynamic) {
1141  std::lock_guard<std::recursive_mutex> guard(m_mutex);
1142  ValueObjectSP valobj_sp;
1143  if (IsHistorical()) {
1144  return valobj_sp;
1145  }
1146  VariableList *var_list = GetVariableList(true);
1147  if (var_list) {
1148  // Make sure the variable is a frame variable
1149  const uint32_t var_idx = var_list->FindIndexForVariable(variable_sp.get());
1150  const uint32_t num_variables = var_list->GetSize();
1151  if (var_idx < num_variables) {
1153  if (!valobj_sp) {
1154  if (m_variable_list_value_objects.GetSize() < num_variables)
1155  m_variable_list_value_objects.Resize(num_variables);
1156  valobj_sp = ValueObjectVariable::Create(this, variable_sp);
1158  }
1159  }
1160  }
1161  if (use_dynamic != eNoDynamicValues && valobj_sp) {
1162  ValueObjectSP dynamic_sp = valobj_sp->GetDynamicValue(use_dynamic);
1163  if (dynamic_sp)
1164  return dynamic_sp;
1165  }
1166  return valobj_sp;
1167 }
1168 
1170  if (m_sc.block == nullptr)
1171  GetSymbolContext(eSymbolContextBlock);
1172  if (m_sc.block)
1173  return m_sc.block->GetContainingInlinedBlock() != nullptr;
1174  return false;
1175 }
1176 
1179 }
1180 
1183 }
1184 
1186  CompileUnit *cu = GetSymbolContext(eSymbolContextCompUnit).comp_unit;
1187  if (cu)
1188  return cu->GetLanguage();
1190 }
1191 
1193  LanguageType lang_type = GetLanguage();
1194 
1195  if (lang_type == eLanguageTypeUnknown) {
1196  SymbolContext sc = GetSymbolContext(eSymbolContextFunction
1197  | eSymbolContextSymbol);
1198  if (sc.function) {
1199  lang_type = sc.function->GetMangled().GuessLanguage();
1200  }
1201  else if (sc.symbol)
1202  {
1203  lang_type = sc.symbol->GetMangled().GuessLanguage();
1204  }
1205  }
1206 
1207  return lang_type;
1208 }
1209 
1210 namespace {
1211 std::pair<const Instruction::Operand *, int64_t>
1212 GetBaseExplainingValue(const Instruction::Operand &operand,
1213  RegisterContext &register_context, lldb::addr_t value) {
1214  switch (operand.m_type) {
1219  // These are not currently interesting
1220  return std::make_pair(nullptr, 0);
1222  const Instruction::Operand *immediate_child = nullptr;
1223  const Instruction::Operand *variable_child = nullptr;
1224  if (operand.m_children[0].m_type == Instruction::Operand::Type::Immediate) {
1225  immediate_child = &operand.m_children[0];
1226  variable_child = &operand.m_children[1];
1227  } else if (operand.m_children[1].m_type ==
1229  immediate_child = &operand.m_children[1];
1230  variable_child = &operand.m_children[0];
1231  }
1232  if (!immediate_child) {
1233  return std::make_pair(nullptr, 0);
1234  }
1235  lldb::addr_t adjusted_value = value;
1236  if (immediate_child->m_negative) {
1237  adjusted_value += immediate_child->m_immediate;
1238  } else {
1239  adjusted_value -= immediate_child->m_immediate;
1240  }
1241  std::pair<const Instruction::Operand *, int64_t> base_and_offset =
1242  GetBaseExplainingValue(*variable_child, register_context,
1243  adjusted_value);
1244  if (!base_and_offset.first) {
1245  return std::make_pair(nullptr, 0);
1246  }
1247  if (immediate_child->m_negative) {
1248  base_and_offset.second -= immediate_child->m_immediate;
1249  } else {
1250  base_and_offset.second += immediate_child->m_immediate;
1251  }
1252  return base_and_offset;
1253  }
1255  const RegisterInfo *info =
1256  register_context.GetRegisterInfoByName(operand.m_register.AsCString());
1257  if (!info) {
1258  return std::make_pair(nullptr, 0);
1259  }
1260  RegisterValue reg_value;
1261  if (!register_context.ReadRegister(info, reg_value)) {
1262  return std::make_pair(nullptr, 0);
1263  }
1264  if (reg_value.GetAsUInt64() == value) {
1265  return std::make_pair(&operand, 0);
1266  } else {
1267  return std::make_pair(nullptr, 0);
1268  }
1269  }
1270  }
1271  return std::make_pair(nullptr, 0);
1272 }
1273 
1274 std::pair<const Instruction::Operand *, int64_t>
1275 GetBaseExplainingDereference(const Instruction::Operand &operand,
1276  RegisterContext &register_context,
1277  lldb::addr_t addr) {
1279  return GetBaseExplainingValue(operand.m_children[0], register_context,
1280  addr);
1281  }
1282  return std::make_pair(nullptr, 0);
1283 }
1284 }
1285 
1287  TargetSP target_sp = CalculateTarget();
1288 
1289  const ArchSpec &target_arch = target_sp->GetArchitecture();
1290 
1291  AddressRange pc_range;
1292  pc_range.GetBaseAddress() = GetFrameCodeAddress();
1293  pc_range.SetByteSize(target_arch.GetMaximumOpcodeByteSize());
1294 
1295  const char *plugin_name = nullptr;
1296  const char *flavor = nullptr;
1297  const bool force_live_memory = true;
1298 
1299  DisassemblerSP disassembler_sp =
1300  Disassembler::DisassembleRange(target_arch, plugin_name, flavor,
1301  *target_sp, pc_range, force_live_memory);
1302 
1303  if (!disassembler_sp || !disassembler_sp->GetInstructionList().GetSize()) {
1304  return ValueObjectSP();
1305  }
1306 
1307  InstructionSP instruction_sp =
1308  disassembler_sp->GetInstructionList().GetInstructionAtIndex(0);
1309 
1310  llvm::SmallVector<Instruction::Operand, 3> operands;
1311 
1312  if (!instruction_sp->ParseOperands(operands)) {
1313  return ValueObjectSP();
1314  }
1315 
1316  RegisterContextSP register_context_sp = GetRegisterContext();
1317 
1318  if (!register_context_sp) {
1319  return ValueObjectSP();
1320  }
1321 
1322  for (const Instruction::Operand &operand : operands) {
1323  std::pair<const Instruction::Operand *, int64_t> base_and_offset =
1324  GetBaseExplainingDereference(operand, *register_context_sp, addr);
1325 
1326  if (!base_and_offset.first) {
1327  continue;
1328  }
1329 
1330  switch (base_and_offset.first->m_type) {
1332  lldb_private::Address addr;
1333  if (target_sp->ResolveLoadAddress(base_and_offset.first->m_immediate +
1334  base_and_offset.second,
1335  addr)) {
1336  auto c_type_system_or_err =
1337  target_sp->GetScratchTypeSystemForLanguage(eLanguageTypeC);
1338  if (auto err = c_type_system_or_err.takeError()) {
1341  std::move(err), "Unable to guess value for given address");
1342  return ValueObjectSP();
1343  } else {
1344  CompilerType void_ptr_type =
1345  c_type_system_or_err
1347  .GetPointerType();
1348  return ValueObjectMemory::Create(this, "", addr, void_ptr_type);
1349  }
1350  } else {
1351  return ValueObjectSP();
1352  }
1353  break;
1354  }
1356  return GuessValueForRegisterAndOffset(base_and_offset.first->m_register,
1357  base_and_offset.second);
1358  }
1359  default:
1360  return ValueObjectSP();
1361  }
1362  }
1363 
1364  return ValueObjectSP();
1365 }
1366 
1367 namespace {
1368 ValueObjectSP GetValueForOffset(StackFrame &frame, ValueObjectSP &parent,
1369  int64_t offset) {
1370  if (offset < 0 || uint64_t(offset) >= parent->GetByteSize()) {
1371  return ValueObjectSP();
1372  }
1373 
1374  if (parent->IsPointerOrReferenceType()) {
1375  return parent;
1376  }
1377 
1378  for (int ci = 0, ce = parent->GetNumChildren(); ci != ce; ++ci) {
1379  const bool can_create = true;
1380  ValueObjectSP child_sp = parent->GetChildAtIndex(ci, can_create);
1381 
1382  if (!child_sp) {
1383  return ValueObjectSP();
1384  }
1385 
1386  int64_t child_offset = child_sp->GetByteOffset();
1387  int64_t child_size = child_sp->GetByteSize().getValueOr(0);
1388 
1389  if (offset >= child_offset && offset < (child_offset + child_size)) {
1390  return GetValueForOffset(frame, child_sp, offset - child_offset);
1391  }
1392  }
1393 
1394  if (offset == 0) {
1395  return parent;
1396  } else {
1397  return ValueObjectSP();
1398  }
1399 }
1400 
1401 ValueObjectSP GetValueForDereferincingOffset(StackFrame &frame,
1402  ValueObjectSP &base,
1403  int64_t offset) {
1404  // base is a pointer to something
1405  // offset is the thing to add to the pointer We return the most sensible
1406  // ValueObject for the result of *(base+offset)
1407 
1408  if (!base->IsPointerOrReferenceType()) {
1409  return ValueObjectSP();
1410  }
1411 
1412  Status error;
1413  ValueObjectSP pointee = base->Dereference(error);
1414 
1415  if (!pointee) {
1416  return ValueObjectSP();
1417  }
1418 
1419  if (offset >= 0 && uint64_t(offset) >= pointee->GetByteSize()) {
1420  int64_t index = offset / pointee->GetByteSize().getValueOr(1);
1421  offset = offset % pointee->GetByteSize().getValueOr(1);
1422  const bool can_create = true;
1423  pointee = base->GetSyntheticArrayMember(index, can_create);
1424  }
1425 
1426  if (!pointee || error.Fail()) {
1427  return ValueObjectSP();
1428  }
1429 
1430  return GetValueForOffset(frame, pointee, offset);
1431 }
1432 
1433 /// Attempt to reconstruct the ValueObject for the address contained in a
1434 /// given register plus an offset.
1435 ///
1436 /// \params [in] frame
1437 /// The current stack frame.
1438 ///
1439 /// \params [in] reg
1440 /// The register.
1441 ///
1442 /// \params [in] offset
1443 /// The offset from the register.
1444 ///
1445 /// \param [in] disassembler
1446 /// A disassembler containing instructions valid up to the current PC.
1447 ///
1448 /// \param [in] variables
1449 /// The variable list from the current frame,
1450 ///
1451 /// \param [in] pc
1452 /// The program counter for the instruction considered the 'user'.
1453 ///
1454 /// \return
1455 /// A string describing the base for the ExpressionPath. This could be a
1456 /// variable, a register value, an argument, or a function return value.
1457 /// The ValueObject if found. If valid, it has a valid ExpressionPath.
1458 lldb::ValueObjectSP DoGuessValueAt(StackFrame &frame, ConstString reg,
1459  int64_t offset, Disassembler &disassembler,
1460  VariableList &variables, const Address &pc) {
1461  // Example of operation for Intel:
1462  //
1463  // +14: movq -0x8(%rbp), %rdi
1464  // +18: movq 0x8(%rdi), %rdi
1465  // +22: addl 0x4(%rdi), %eax
1466  //
1467  // f, a pointer to a struct, is known to be at -0x8(%rbp).
1468  //
1469  // DoGuessValueAt(frame, rdi, 4, dis, vars, 0x22) finds the instruction at
1470  // +18 that assigns to rdi, and calls itself recursively for that dereference
1471  // DoGuessValueAt(frame, rdi, 8, dis, vars, 0x18) finds the instruction at
1472  // +14 that assigns to rdi, and calls itself recursively for that
1473  // dereference
1474  // DoGuessValueAt(frame, rbp, -8, dis, vars, 0x14) finds "f" in the
1475  // variable list.
1476  // Returns a ValueObject for f. (That's what was stored at rbp-8 at +14)
1477  // Returns a ValueObject for *(f+8) or f->b (That's what was stored at rdi+8
1478  // at +18)
1479  // Returns a ValueObject for *(f->b+4) or f->b->a (That's what was stored at
1480  // rdi+4 at +22)
1481 
1482  // First, check the variable list to see if anything is at the specified
1483  // location.
1484 
1485  using namespace OperandMatchers;
1486 
1487  const RegisterInfo *reg_info =
1488  frame.GetRegisterContext()->GetRegisterInfoByName(reg.AsCString());
1489  if (!reg_info) {
1490  return ValueObjectSP();
1491  }
1492 
1498  : Instruction::Operand::BuildDereference(
1499  Instruction::Operand::BuildRegister(reg));
1500 
1501  for (VariableSP var_sp : variables) {
1502  if (var_sp->LocationExpression().MatchesOperand(frame, op))
1503  return frame.GetValueObjectForFrameVariable(var_sp, eNoDynamicValues);
1504  }
1505 
1506  const uint32_t current_inst =
1508  if (current_inst == UINT32_MAX) {
1509  return ValueObjectSP();
1510  }
1511 
1512  for (uint32_t ii = current_inst - 1; ii != (uint32_t)-1; --ii) {
1513  // This is not an exact algorithm, and it sacrifices accuracy for
1514  // generality. Recognizing "mov" and "ld" instructions –– and which
1515  // are their source and destination operands -- is something the
1516  // disassembler should do for us.
1517  InstructionSP instruction_sp =
1518  disassembler.GetInstructionList().GetInstructionAtIndex(ii);
1519 
1520  if (instruction_sp->IsCall()) {
1521  ABISP abi_sp = frame.CalculateProcess()->GetABI();
1522  if (!abi_sp) {
1523  continue;
1524  }
1525 
1526  const char *return_register_name;
1527  if (!abi_sp->GetPointerReturnRegister(return_register_name)) {
1528  continue;
1529  }
1530 
1531  const RegisterInfo *return_register_info =
1532  frame.GetRegisterContext()->GetRegisterInfoByName(
1533  return_register_name);
1534  if (!return_register_info) {
1535  continue;
1536  }
1537 
1538  int64_t offset = 0;
1539 
1541  MatchRegOp(*return_register_info))(op) &&
1542  !MatchUnaryOp(
1545  MatchRegOp(*return_register_info),
1546  FetchImmOp(offset)))(op)) {
1547  continue;
1548  }
1549 
1550  llvm::SmallVector<Instruction::Operand, 1> operands;
1551  if (!instruction_sp->ParseOperands(operands) || operands.size() != 1) {
1552  continue;
1553  }
1554 
1555  switch (operands[0].m_type) {
1556  default:
1557  break;
1559  SymbolContext sc;
1560  Address load_address;
1561  if (!frame.CalculateTarget()->ResolveLoadAddress(
1562  operands[0].m_immediate, load_address)) {
1563  break;
1564  }
1565  frame.CalculateTarget()->GetImages().ResolveSymbolContextForAddress(
1566  load_address, eSymbolContextFunction, sc);
1567  if (!sc.function) {
1568  break;
1569  }
1570  CompilerType function_type = sc.function->GetCompilerType();
1571  if (!function_type.IsFunctionType()) {
1572  break;
1573  }
1574  CompilerType return_type = function_type.GetFunctionReturnType();
1575  RegisterValue return_value;
1576  if (!frame.GetRegisterContext()->ReadRegister(return_register_info,
1577  return_value)) {
1578  break;
1579  }
1580  std::string name_str(
1581  sc.function->GetName().AsCString("<unknown function>"));
1582  name_str.append("()");
1583  Address return_value_address(return_value.GetAsUInt64());
1584  ValueObjectSP return_value_sp = ValueObjectMemory::Create(
1585  &frame, name_str, return_value_address, return_type);
1586  return GetValueForDereferincingOffset(frame, return_value_sp, offset);
1587  }
1588  }
1589 
1590  continue;
1591  }
1592 
1593  llvm::SmallVector<Instruction::Operand, 2> operands;
1594  if (!instruction_sp->ParseOperands(operands) || operands.size() != 2) {
1595  continue;
1596  }
1597 
1598  Instruction::Operand *origin_operand = nullptr;
1599  auto clobbered_reg_matcher = [reg_info](const Instruction::Operand &op) {
1600  return MatchRegOp(*reg_info)(op) && op.m_clobbered;
1601  };
1602 
1603  if (clobbered_reg_matcher(operands[0])) {
1604  origin_operand = &operands[1];
1605  }
1606  else if (clobbered_reg_matcher(operands[1])) {
1607  origin_operand = &operands[0];
1608  }
1609  else {
1610  continue;
1611  }
1612 
1613  // We have an origin operand. Can we track its value down?
1614  ValueObjectSP source_path;
1615  ConstString origin_register;
1616  int64_t origin_offset = 0;
1617 
1618  if (FetchRegOp(origin_register)(*origin_operand)) {
1619  source_path = DoGuessValueAt(frame, origin_register, 0, disassembler,
1620  variables, instruction_sp->GetAddress());
1621  } else if (MatchUnaryOp(
1623  FetchRegOp(origin_register))(*origin_operand) ||
1624  MatchUnaryOp(
1627  FetchRegOp(origin_register),
1628  FetchImmOp(origin_offset)))(*origin_operand)) {
1629  source_path =
1630  DoGuessValueAt(frame, origin_register, origin_offset, disassembler,
1631  variables, instruction_sp->GetAddress());
1632  if (!source_path) {
1633  continue;
1634  }
1635  source_path =
1636  GetValueForDereferincingOffset(frame, source_path, offset);
1637  }
1638 
1639  if (source_path) {
1640  return source_path;
1641  }
1642  }
1643 
1644  return ValueObjectSP();
1645 }
1646 }
1647 
1649  int64_t offset) {
1650  TargetSP target_sp = CalculateTarget();
1651 
1652  const ArchSpec &target_arch = target_sp->GetArchitecture();
1653 
1654  Block *frame_block = GetFrameBlock();
1655 
1656  if (!frame_block) {
1657  return ValueObjectSP();
1658  }
1659 
1660  Function *function = frame_block->CalculateSymbolContextFunction();
1661  if (!function) {
1662  return ValueObjectSP();
1663  }
1664 
1665  AddressRange pc_range = function->GetAddressRange();
1666 
1667  if (GetFrameCodeAddress().GetFileAddress() <
1668  pc_range.GetBaseAddress().GetFileAddress() ||
1669  GetFrameCodeAddress().GetFileAddress() -
1670  pc_range.GetBaseAddress().GetFileAddress() >=
1671  pc_range.GetByteSize()) {
1672  return ValueObjectSP();
1673  }
1674 
1675  const char *plugin_name = nullptr;
1676  const char *flavor = nullptr;
1677  const bool force_live_memory = true;
1678  DisassemblerSP disassembler_sp =
1679  Disassembler::DisassembleRange(target_arch, plugin_name, flavor,
1680  *target_sp, pc_range, force_live_memory);
1681 
1682  if (!disassembler_sp || !disassembler_sp->GetInstructionList().GetSize()) {
1683  return ValueObjectSP();
1684  }
1685 
1686  const bool get_file_globals = false;
1687  VariableList *variables = GetVariableList(get_file_globals);
1688 
1689  if (!variables) {
1690  return ValueObjectSP();
1691  }
1692 
1693  return DoGuessValueAt(*this, reg, offset, *disassembler_sp, *variables,
1695 }
1696 
1697 lldb::ValueObjectSP StackFrame::FindVariable(ConstString name) {
1698  ValueObjectSP value_sp;
1699 
1700  if (!name)
1701  return value_sp;
1702 
1703  TargetSP target_sp = CalculateTarget();
1704  ProcessSP process_sp = CalculateProcess();
1705 
1706  if (!target_sp && !process_sp)
1707  return value_sp;
1708 
1709  VariableList variable_list;
1710  VariableSP var_sp;
1711  SymbolContext sc(GetSymbolContext(eSymbolContextBlock));
1712 
1713  if (sc.block) {
1714  const bool can_create = true;
1715  const bool get_parent_variables = true;
1716  const bool stop_if_block_is_inlined_function = true;
1717 
1718  if (sc.block->AppendVariables(
1719  can_create, get_parent_variables, stop_if_block_is_inlined_function,
1720  [this](Variable *v) { return v->IsInScope(this); },
1721  &variable_list)) {
1722  var_sp = variable_list.FindVariable(name);
1723  }
1724 
1725  if (var_sp)
1727  }
1728 
1729  return value_sp;
1730 }
1731 
1733  TargetSP target_sp;
1734  ThreadSP thread_sp(GetThread());
1735  if (thread_sp) {
1736  ProcessSP process_sp(thread_sp->CalculateProcess());
1737  if (process_sp)
1738  target_sp = process_sp->CalculateTarget();
1739  }
1740  return target_sp;
1741 }
1742 
1744  ProcessSP process_sp;
1745  ThreadSP thread_sp(GetThread());
1746  if (thread_sp)
1747  process_sp = thread_sp->CalculateProcess();
1748  return process_sp;
1749 }
1750 
1751 ThreadSP StackFrame::CalculateThread() { return GetThread(); }
1752 
1753 StackFrameSP StackFrame::CalculateStackFrame() { return shared_from_this(); }
1754 
1756  exe_ctx.SetContext(shared_from_this());
1757 }
1758 
1759 void StackFrame::DumpUsingSettingsFormat(Stream *strm, bool show_unique,
1760  const char *frame_marker) {
1761  if (strm == nullptr)
1762  return;
1763 
1764  GetSymbolContext(eSymbolContextEverything);
1765  ExecutionContext exe_ctx(shared_from_this());
1766  StreamString s;
1767 
1768  if (frame_marker)
1769  s.PutCString(frame_marker);
1770 
1771  const FormatEntity::Entry *frame_format = nullptr;
1772  Target *target = exe_ctx.GetTargetPtr();
1773  if (target) {
1774  if (show_unique) {
1775  frame_format = target->GetDebugger().GetFrameFormatUnique();
1776  } else {
1777  frame_format = target->GetDebugger().GetFrameFormat();
1778  }
1779  }
1780  if (frame_format && FormatEntity::Format(*frame_format, s, &m_sc, &exe_ctx,
1781  nullptr, nullptr, false, false)) {
1782  strm->PutCString(s.GetString());
1783  } else {
1784  Dump(strm, true, false);
1785  strm->EOL();
1786  }
1787 }
1788 
1789 void StackFrame::Dump(Stream *strm, bool show_frame_index,
1790  bool show_fullpaths) {
1791  if (strm == nullptr)
1792  return;
1793 
1794  if (show_frame_index)
1795  strm->Printf("frame #%u: ", m_frame_index);
1796  ExecutionContext exe_ctx(shared_from_this());
1797  Target *target = exe_ctx.GetTargetPtr();
1798  strm->Printf("0x%0*" PRIx64 " ",
1799  target ? (target->GetArchitecture().GetAddressByteSize() * 2)
1800  : 16,
1801  GetFrameCodeAddress().GetLoadAddress(target));
1802  GetSymbolContext(eSymbolContextEverything);
1803  const bool show_module = true;
1804  const bool show_inline = true;
1805  const bool show_function_arguments = true;
1806  const bool show_function_name = true;
1808  GetFrameCodeAddress(), show_fullpaths, show_module,
1809  show_inline, show_function_arguments,
1810  show_function_name);
1811 }
1812 
1814  std::lock_guard<std::recursive_mutex> guard(m_mutex);
1815  assert(GetStackID() ==
1816  prev_frame.GetStackID()); // TODO: remove this after some testing
1819  if (!m_disassembly.GetString().empty()) {
1820  m_disassembly.Clear();
1822  }
1823 }
1824 
1826  std::lock_guard<std::recursive_mutex> guard(m_mutex);
1827  assert(GetStackID() ==
1828  curr_frame.GetStackID()); // TODO: remove this after some testing
1829  m_id.SetPC(curr_frame.m_id.GetPC()); // Update the Stack ID PC value
1830  assert(GetThread() == curr_frame.GetThread());
1831  m_frame_index = curr_frame.m_frame_index;
1833  m_reg_context_sp = curr_frame.m_reg_context_sp;
1834  m_frame_code_addr = curr_frame.m_frame_code_addr;
1836  assert(!m_sc.target_sp || !curr_frame.m_sc.target_sp ||
1837  m_sc.target_sp.get() == curr_frame.m_sc.target_sp.get());
1838  assert(!m_sc.module_sp || !curr_frame.m_sc.module_sp ||
1839  m_sc.module_sp.get() == curr_frame.m_sc.module_sp.get());
1840  assert(m_sc.comp_unit == nullptr || curr_frame.m_sc.comp_unit == nullptr ||
1841  m_sc.comp_unit == curr_frame.m_sc.comp_unit);
1842  assert(m_sc.function == nullptr || curr_frame.m_sc.function == nullptr ||
1843  m_sc.function == curr_frame.m_sc.function);
1844  m_sc = curr_frame.m_sc;
1845  m_flags.Clear(GOT_FRAME_BASE | eSymbolContextEverything);
1847  m_frame_base.Clear();
1849 }
1850 
1852  if (m_variable_list_sp)
1853  return true;
1855  return true;
1856  if (!m_disassembly.GetString().empty())
1857  return true;
1858  return false;
1859 }
1860 
1861 bool StackFrame::GetStatus(Stream &strm, bool show_frame_info, bool show_source,
1862  bool show_unique, const char *frame_marker) {
1863  if (show_frame_info) {
1864  strm.Indent();
1865  DumpUsingSettingsFormat(&strm, show_unique, frame_marker);
1866  }
1867 
1868  if (show_source) {
1869  ExecutionContext exe_ctx(shared_from_this());
1870  bool have_source = false, have_debuginfo = false;
1871  Debugger::StopDisassemblyType disasm_display =
1873  Target *target = exe_ctx.GetTargetPtr();
1874  if (target) {
1875  Debugger &debugger = target->GetDebugger();
1876  const uint32_t source_lines_before =
1877  debugger.GetStopSourceLineCount(true);
1878  const uint32_t source_lines_after =
1879  debugger.GetStopSourceLineCount(false);
1880  disasm_display = debugger.GetStopDisassemblyDisplay();
1881 
1882  GetSymbolContext(eSymbolContextCompUnit | eSymbolContextLineEntry);
1883  if (m_sc.comp_unit && m_sc.line_entry.IsValid()) {
1884  have_debuginfo = true;
1885  if (source_lines_before > 0 || source_lines_after > 0) {
1886  size_t num_lines =
1889  m_sc.line_entry.column, source_lines_before,
1890  source_lines_after, "->", &strm);
1891  if (num_lines != 0)
1892  have_source = true;
1893  // TODO: Give here a one time warning if source file is missing.
1894  }
1895  }
1896  switch (disasm_display) {
1898  break;
1899 
1901  if (have_debuginfo)
1902  break;
1903  LLVM_FALLTHROUGH;
1904 
1906  if (have_source)
1907  break;
1908  LLVM_FALLTHROUGH;
1909 
1911  if (target) {
1912  const uint32_t disasm_lines = debugger.GetDisassemblyLineCount();
1913  if (disasm_lines > 0) {
1914  const ArchSpec &target_arch = target->GetArchitecture();
1915  const char *plugin_name = nullptr;
1916  const char *flavor = nullptr;
1917  const bool mixed_source_and_assembly = false;
1919  target->GetDebugger(), target_arch, plugin_name, flavor,
1920  exe_ctx, GetFrameCodeAddress(),
1921  {Disassembler::Limit::Instructions, disasm_lines},
1922  mixed_source_and_assembly, 0,
1924  }
1925  }
1926  break;
1927  }
1928  }
1929  }
1930  return true;
1931 }
1932 
1933 RecognizedStackFrameSP StackFrame::GetRecognizedFrame() {
1934  if (!m_recognized_frame_sp) {
1936  ->GetProcess()
1937  ->GetTarget()
1938  .GetFrameRecognizerManager()
1939  .RecognizeFrame(CalculateStackFrame());
1940  }
1941  return m_recognized_frame_sp;
1942 }
lldb_private::StackFrame::CalculateTarget
lldb::TargetSP CalculateTarget() override
Definition: StackFrame.cpp:1732
lldb_private::AddressRange::GetBaseAddress
Address & GetBaseAddress()
Get accessor for the base address of the range.
Definition: AddressRange.h:209
lldb_private::StackID::SetPC
void SetPC(lldb::addr_t pc)
Definition: StackID.h:68
lldb_private::ValueObjectList::Resize
void Resize(size_t size)
Definition: ValueObjectList.cpp:37
lldb_private::SymbolContext::block
Block * block
The Block for a given query.
Definition: SymbolContext.h:321
lldb_private::ExecutionContext
Definition: ExecutionContext.h:292
lldb_private::SymbolContext::comp_unit
CompileUnit * comp_unit
The CompileUnit for a given query.
Definition: SymbolContext.h:319
lldb_private::CompileUnit::GetVariableList
lldb::VariableListSP GetVariableList(bool can_create)
Get the variable list for a compile unit.
Definition: CompileUnit.cpp:208
lldb_private::StackFrame::m_sc
SymbolContext m_sc
Definition: StackFrame.h:509
lldb_private::LineEntry::file
FileSpec file
The source file, possibly mapped by the target.source-map setting.
Definition: LineEntry.h:140
lldb_private::StackFrame::m_stack_frame_kind
Kind m_stack_frame_kind
Definition: StackFrame.h:515
lldb_private::StackFrame::HasCachedData
bool HasCachedData() const
Definition: StackFrame.cpp:1851
lldb_private::ArchSpec
Definition: ArchSpec.h:33
lldb_private::Debugger::GetDisassemblyLineCount
uint32_t GetDisassemblyLineCount() const
Definition: Debugger.cpp:431
Mangled.h
lldb_private::Instruction::Operand::m_immediate
lldb::addr_t m_immediate
Definition: Disassembler.h:195
lldb_private::Instruction::Operand::m_negative
bool m_negative
Definition: Disassembler.h:197
lldb_private::ArchSpec::GetMaximumOpcodeByteSize
uint32_t GetMaximumOpcodeByteSize() const
Definition: ArchSpec.cpp:923
lldb_private::Address::IsValid
bool IsValid() const
Check if the object state is valid.
Definition: Address.h:336
lldb_private::CompilerType::IsAnonymousType
bool IsAnonymousType() const
Definition: CompilerType.cpp:37
lldb_private::Instruction::Operand::m_register
ConstString m_register
Definition: Disassembler.h:196
lldb_private::StackFrame::m_flags
Flags m_flags
Definition: StackFrame.h:510
CompileUnit.h
lldb_private::LineEntry::IsValid
bool IsValid() const
Check if a line entry object is valid.
Definition: LineEntry.cpp:46
lldb_private::OperandMatchers::FetchImmOp
std::function< bool(const Instruction::Operand &)> FetchImmOp(int64_t &imm)
Definition: Disassembler.h:261
lldb_private::RegisterValue
Definition: RegisterValue.h:28
lldb_private::Function::GetAddressRange
const AddressRange & GetAddressRange()
Definition: Function.h:461
lldb_private::Value
Definition: Value.h:38
lldb::eNoDynamicValues
@ eNoDynamicValues
Definition: lldb-enumerations.h:495
lldb_private::StackFrame::GetVariableList
VariableList * GetVariableList(bool get_file_globals)
Retrieve the list of variables that are in scope at this StackFrame's pc.
Definition: StackFrame.cpp:422
lldb_private::OperandMatchers::MatchOpType
std::function< bool(const Instruction::Operand &)> MatchOpType(Instruction::Operand::Type type)
Definition: Disassembler.h:264
lldb_private::ValueObjectList::GetValueObjectAtIndex
lldb::ValueObjectSP GetValueObjectAtIndex(size_t idx)
Definition: ValueObjectList.cpp:39
lldb_private::SymbolContext::target_sp
lldb::TargetSP target_sp
The Target for a given query.
Definition: SymbolContext.h:317
lldb_private::StackFrame::DumpUsingSettingsFormat
void DumpUsingSettingsFormat(Stream *strm, bool show_unique=false, const char *frame_marker=nullptr)
Print a description for this frame using the frame-format formatter settings.
Definition: StackFrame.cpp:1759
lldb_private::StackFrame::GetFrameCodeAddress
const Address & GetFrameCodeAddress()
Get an Address for the current pc value in this StackFrame.
Definition: StackFrame.cpp:188
lldb_private::ValueObjectList::Swap
void Swap(ValueObjectList &value_object_list)
Definition: ValueObjectList.cpp:107
lldb_private::RegisterContext::ReadRegister
virtual bool ReadRegister(const RegisterInfo *reg_info, RegisterValue &reg_value)=0
lldb_private::Scalar
Definition: Scalar.h:34
lldb_private::StackFrame::GuessValueForRegisterAndOffset
lldb::ValueObjectSP GuessValueForRegisterAndOffset(ConstString reg, int64_t offset)
Attempt to reconstruct the ValueObject for the address contained in a given register plus an offset.
Definition: StackFrame.cpp:1648
lldb_private::Flags::Clear
ValueType Clear(ValueType mask=~static_cast< ValueType >(0))
Clear one or more flags.
Definition: Flags.h:61
lldb_private::AddressRange::GetByteSize
lldb::addr_t GetByteSize() const
Get accessor for the byte size of this range.
Definition: AddressRange.h:221
Module.h
lldb_private::StackFrame::GetFrameBlock
Block * GetFrameBlock()
Get the current lexical scope block for this StackFrame, if possible.
Definition: StackFrame.cpp:273
RESOLVED_GLOBAL_VARIABLES
#define RESOLVED_GLOBAL_VARIABLES
Definition: StackFrame.cpp:49
lldb_private::VariableList::GetSize
size_t GetSize() const
Definition: VariableList.cpp:165
lldb_private::StackFrame::Kind::History
@ History
A historical stack frame – possibly without CFA or registers or local variables.
lldb::LanguageType
LanguageType
Programming language type.
Definition: lldb-enumerations.h:436
lldb_private::VariableList::FindVariable
lldb::VariableSP FindVariable(ConstString name, bool include_static_members=true)
Definition: VariableList.cpp:72
lldb_private::ConstString::AsCString
const char * AsCString(const char *value_if_empty=nullptr) const
Get the string value as a C string.
Definition: ConstString.h:193
lldb_private::ValueObjectMemory::Create
static lldb::ValueObjectSP Create(ExecutionContextScope *exe_scope, llvm::StringRef name, const Address &address, lldb::TypeSP &type_sp)
Definition: ValueObjectMemory.cpp:31
RegisterValue.h
lldb::eBasicTypeChar
@ eBasicTypeChar
Definition: lldb-enumerations.h:744
Disassembler.h
StackFrame.h
lldb_private::StackFrame::m_frame_base
Scalar m_frame_base
Definition: StackFrame.h:511
lldb_private::SourceManager::DisplaySourceLinesWithLineNumbers
size_t DisplaySourceLinesWithLineNumbers(const FileSpec &file, uint32_t line, uint32_t column, uint32_t context_before, uint32_t context_after, const char *current_line_cstr, Stream *s, const SymbolContextList *bp_locs=nullptr)
Definition: SourceManager.cpp:242
lldb_private::InstructionList::GetInstructionAtIndex
lldb::InstructionSP GetInstructionAtIndex(size_t idx) const
Definition: Disassembler.cpp:945
ValueObjectMemory.h
lldb_private::Instruction
Definition: Disassembler.h:58
lldb_private::Stream
Definition: Stream.h:28
lldb_private::StackFrame::FindVariable
lldb::ValueObjectSP FindVariable(ConstString name)
Attempt to reconstruct the ValueObject for a variable with a given name from within the current Stack...
Definition: StackFrame.cpp:1697
lldb::addr_t
uint64_t addr_t
Definition: lldb-types.h:83
pc
@ pc
Definition: CompactUnwindInfo.cpp:1250
lldb_private::Debugger::eStopDisassemblyTypeNever
@ eStopDisassemblyTypeNever
Definition: Debugger.h:281
lldb_private::Instruction::Operand::m_children
std::vector< Operand > m_children
Definition: Disassembler.h:194
lldb_private::Target::GetDebugger
Debugger & GetDebugger()
Definition: Target.h:1000
lldb_private::StackFrame::eExpressionPathOptionsNoFragileObjcIvar
@ eExpressionPathOptionsNoFragileObjcIvar
Definition: StackFrame.h:45
Debugger.h
lldb_private::SymbolContext
Definition: SymbolContext.h:33
lldb_private::Target
Definition: Target.h:451
lldb_private::Address::GetOpcodeLoadAddress
lldb::addr_t GetOpcodeLoadAddress(Target *target, AddressClass addr_class=AddressClass::eInvalid) const
Get the load address as an opcode load address.
Definition: Address.cpp:367
lldb_private::StackFrame::HasDebugInformation
bool HasDebugInformation()
Determine whether this StackFrame has debug information available or not.
Definition: StackFrame.cpp:1133
ABI.h
lldb_private::VariableList
Definition: VariableList.h:18
lldb_private::StreamString::GetString
llvm::StringRef GetString() const
Definition: StreamString.cpp:51
lldb_private::StackID::GetSymbolContextScope
SymbolContextScope * GetSymbolContextScope() const
Definition: StackID.h:37
lldb_private::StackFrame::m_behaves_like_zeroth_frame
bool m_behaves_like_zeroth_frame
Definition: StackFrame.h:521
Process.h
lldb_private::RegisterValue::GetAsUInt64
uint64_t GetAsUInt64(uint64_t fail_value=UINT64_MAX, bool *success_ptr=nullptr) const
Definition: RegisterValue.cpp:563
lldb_private::CompileUnit
Definition: CompileUnit.h:38
Target.h
lldb_private::StackFrame::m_frame_code_addr
Address m_frame_code_addr
Definition: StackFrame.h:506
lldb_private::Debugger::eStopDisassemblyTypeAlways
@ eStopDisassemblyTypeAlways
Definition: Debugger.h:284
lldb_private::Instruction::Operand::Type::Sum
@ Sum
error
static llvm::raw_ostream & error(Stream &strm)
Definition: CommandReturnObject.cpp:17
lldb_private::SymbolContext::symbol
Symbol * symbol
The Symbol for a given query.
Definition: SymbolContext.h:323
RESOLVED_VARIABLES
#define RESOLVED_VARIABLES
Definition: StackFrame.cpp:48
lldb_private::Status::Success
bool Success() const
Test for success condition.
Definition: Status.cpp:288
lldb_private::Function
Definition: Function.h:413
lldb_private::LineEntry::ApplyFileMappings
void ApplyFileMappings(lldb::TargetSP target_sp)
Apply file mappings from target.source-map to the LineEntry's file.
Definition: LineEntry.cpp:253
lldb_private::StackFrame::m_frame_index
uint32_t m_frame_index
Definition: StackFrame.h:502
lldb_private::Variable::IsInScope
bool IsInScope(StackFrame *frame)
Definition: Variable.cpp:280
lldb_private::OperandMatchers::FetchRegOp
std::function< bool(const Instruction::Operand &)> FetchRegOp(ConstString &reg)
Definition: Disassembler.h:257
lldb_private::SymbolContext::DumpStopContext
bool DumpStopContext(Stream *s, ExecutionContextScope *exe_scope, const Address &so_addr, bool show_fullpaths, bool show_module, bool show_inlined_frames, bool show_function_arguments, bool show_function_name) const
Dump the stop context in this object to a Stream.
Definition: SymbolContext.cpp:67
lldb_private::Disassembler::DisassembleRange
static lldb::DisassemblerSP DisassembleRange(const ArchSpec &arch, const char *plugin_name, const char *flavor, Target &target, const AddressRange &disasm_range, bool force_live_memory=false)
Definition: Disassembler.cpp:122
lldb_private::Stream::Indent
size_t Indent(llvm::StringRef s="")
Indent the current line in the stream.
Definition: Stream.cpp:130
lldb_private::OperandMatchers::MatchBinaryOp
std::function< bool(const Instruction::Operand &)> MatchBinaryOp(std::function< bool(const Instruction::Operand &)> base, std::function< bool(const Instruction::Operand &)> left, std::function< bool(const Instruction::Operand &)> right)
Definition: Disassembler.h:246
lldb_private::StackFrame::IsInlined
bool IsInlined()
Query whether this frame is a concrete frame on the call stack, or if it is an inlined frame derived ...
Definition: StackFrame.cpp:1169
lldb_private::CompilerType::IsFunctionType
bool IsFunctionType() const
Definition: CompilerType.cpp:101
lldb_private::Function::GetName
ConstString GetName() const
Definition: Function.cpp:655
lldb_private::StackFrame::m_id
StackID m_id
Definition: StackFrame.h:505
Log.h
lldb_private::StackFrame::CalculateThread
lldb::ThreadSP CalculateThread() override
Definition: StackFrame.cpp:1751
lldb_private::StackFrame::UpdateCurrentFrameFromPreviousFrame
void UpdateCurrentFrameFromPreviousFrame(StackFrame &prev_frame)
Definition: StackFrame.cpp:1813
lldb_private::Function::GetBlock
Block & GetBlock(bool can_create)
Get accessor for the block list.
Definition: Function.cpp:344
lldb_private::ValueObjectList::GetSize
size_t GetSize() const
Definition: ValueObjectList.cpp:35
lldb_private::ValueObjectList::SetValueObjectAtIndex
void SetValueObjectAtIndex(size_t idx, const lldb::ValueObjectSP &valobj_sp)
Definition: ValueObjectList.cpp:55
lldb_private::StackFrame::eExpressionPathOptionCheckPtrVsMember
@ eExpressionPathOptionCheckPtrVsMember
Definition: StackFrame.h:44
lldb_private::StackFrame::m_recognized_frame_sp
lldb::RecognizedStackFrameSP m_recognized_frame_sp
Definition: StackFrame.h:526
lldb_private::StreamString::Clear
void Clear()
Definition: StreamString.cpp:31
lldb_private::StreamString::GetData
const char * GetData() const
Definition: StreamString.h:43
lldb_private::StackID::SetSymbolContextScope
void SetSymbolContextScope(SymbolContextScope *symbol_scope)
Definition: StackID.h:39
lldb_private::SymbolContext::function
Function * function
The Function for a given query.
Definition: SymbolContext.h:320
lldb_private::Address::GetFileAddress
lldb::addr_t GetFileAddress() const
Get the file address.
Definition: Address.cpp:290
Type.h
lldb_private::Debugger::eStopDisassemblyTypeNoDebugInfo
@ eStopDisassemblyTypeNoDebugInfo
Definition: Debugger.h:282
lldb_private::Block::CalculateSymbolContextFunction
Function * CalculateSymbolContextFunction() override
Definition: Block.cpp:153
lldb_private::DWARFExpression
Definition: DWARFExpression.h:35
SymbolContextScope.h
lldb_private::StackFrame::GetValueForVariableExpressionPath
lldb::ValueObjectSP GetValueForVariableExpressionPath(llvm::StringRef var_expr, lldb::DynamicValueType use_dynamic, uint32_t options, lldb::VariableSP &var_sp, Status &error)
Create a ValueObject for a variable name / pathname, possibly including simple dereference/child sele...
Definition: StackFrame.cpp:494
lldb_private::Disassembler::Disassemble
static bool Disassemble(Debugger &debugger, const ArchSpec &arch, const char *plugin_name, const char *flavor, const ExecutionContext &exe_ctx, const Address &start, Limit limit, bool mixed_source_and_assembly, uint32_t num_mixed_context_lines, uint32_t options, Stream &strm)
Definition: Disassembler.cpp:168
lldb_private::ConstString
Definition: ConstString.h:40
lldb_private::ExecutionContext::SetContext
void SetContext(const lldb::TargetSP &target_sp, bool get_process)
Definition: ExecutionContext.cpp:290
lldb_private::StreamString
Definition: StreamString.h:23
lldb_private::StackID::GetPC
lldb::addr_t GetPC() const
Definition: StackID.h:33
lldb-enumerations.h
lldb_private::AddressRange
Definition: AddressRange.h:25
lldb_private::Scalar::Clear
void Clear()
Definition: Scalar.h:97
lldb_private::Instruction::Operand::BuildDereference
static Operand BuildDereference(const Operand &ref)
Definition: Disassembler.cpp:1199
lldb_private::Instruction::Operand
Definition: Disassembler.h:185
lldb::DynamicValueType
DynamicValueType
Definition: lldb-enumerations.h:494
lldb_private::Debugger
Definition: Debugger.h:70
GOT_FRAME_BASE
#define GOT_FRAME_BASE
Definition: StackFrame.cpp:47
lldb_private::StreamString::Empty
bool Empty() const
Definition: StreamString.cpp:36
lldb_private::Instruction::Operand::BuildImmediate
static Operand BuildImmediate(lldb::addr_t imm, bool neg)
Definition: Disassembler.cpp:1176
lldb_private::Block::AppendBlockVariables
uint32_t AppendBlockVariables(bool can_create, bool get_child_block_variables, bool stop_if_child_block_is_inlined_function, const std::function< bool(Variable *)> &filter, VariableList *variable_list)
Get the variable list for this block and optionally all child blocks if get_child_variables is true.
Definition: Block.cpp:412
lldb::eLanguageTypeObjC
@ eLanguageTypeObjC
Objective-C.
Definition: lldb-enumerations.h:453
string
string(SUBSTRING ${p} 10 -1 pStripped) if($
Definition: Plugins/CMakeLists.txt:40
lldb_private::StackFrame::GetFrameBaseValue
bool GetFrameBaseValue(Scalar &value, Status *error_ptr)
Return the Canonical Frame Address (DWARF term) for this frame.
Definition: StackFrame.cpp:1066
lldb_private::Address::SetOpcodeLoadAddress
bool SetOpcodeLoadAddress(lldb::addr_t load_addr, Target *target, AddressClass addr_class=AddressClass::eInvalid, bool allow_section_end=false)
Definition: Address.cpp:378
lldb_private::ConstString::GetLength
size_t GetLength() const
Get the length in bytes of string value.
Definition: ConstString.cpp:238
lldb_private::CompileUnit::GetLanguage
lldb::LanguageType GetLanguage()
Definition: CompileUnit.cpp:150
Thread.h
lldb_private::LineEntry::column
uint16_t column
The column number of the source line, or zero if there is no column information.
Definition: LineEntry.h:146
lldb_private::DWARFExpression::IsLocationList
bool IsLocationList() const
Return true if a location list was provided.
Definition: DWARFExpression.cpp:105
lldb_private::Symbol::GetMangled
Mangled & GetMangled()
Definition: Symbol.h:121
lldb_private::CompilerType::GetFunctionReturnType
CompilerType GetFunctionReturnType() const
Definition: CompilerType.cpp:373
lldb_private::Instruction::Operand::BuildRegister
static Operand BuildRegister(ConstString &r)
Definition: Disassembler.cpp:1169
VariableList.h
lldb_private::RegisterContext
Definition: RegisterContext.h:17
lldb_private::Debugger::StopDisassemblyType
StopDisassemblyType
Definition: Debugger.h:280
lldb_private::Disassembler::eOptionMarkPCAddress
@ eOptionMarkPCAddress
Definition: Disassembler.h:377
lldb_private::StackFrame::m_frame_base_error
Status m_frame_base_error
Definition: StackFrame.h:512
lldb_private::Flags::Reset
void Reset(ValueType flags)
Set accessor for all flags.
Definition: Flags.h:52
lldb_private::ArchSpec::GetAddressByteSize
uint32_t GetAddressByteSize() const
Returns the size in bytes of an address of the current architecture.
Definition: ArchSpec.cpp:683
lldb_private::Instruction::Operand::Type::Register
@ Register
RESOLVED_FRAME_CODE_ADDR
#define RESOLVED_FRAME_CODE_ADDR
Definition: StackFrame.cpp:45
lldb_private::StackFrame::GetStatus
bool GetStatus(Stream &strm, bool show_frame_info, bool show_source, bool show_unique=false, const char *frame_marker=nullptr)
Print a description of this stack frame and/or the source context/assembly for this stack frame.
Definition: StackFrame.cpp:1861
lldb_private::SymbolContextScope
Definition: SymbolContextScope.h:64
lldb_private::LineEntry::line
uint32_t line
The source line number, or zero if there is no line number information.
Definition: LineEntry.h:143
lldb_private::Address::SetRawAddress
void SetRawAddress(lldb::addr_t addr)
Definition: Address.h:435
lldb_private::StackFrame::GetStackID
StackID & GetStackID()
Definition: StackFrame.cpp:143
lldb_private::FormatEntity::Format
static bool Format(const Entry &entry, Stream &s, const SymbolContext *sc, const ExecutionContext *exe_ctx, const Address *addr, ValueObject *valobj, bool function_changed, bool initial_function)
Definition: FormatEntity.cpp:1080
lldb_private::Instruction::Operand::Type::Invalid
@ Invalid
ValueObjectConstResult.h
lldb_private::Value::ResolveValue
Scalar & ResolveValue(ExecutionContext *exe_ctx)
Definition: Value.cpp:563
lldb_private::StackFrame::eExpressionPathOptionsNoSyntheticChildren
@ eExpressionPathOptionsNoSyntheticChildren
Definition: StackFrame.h:46
lldb_private::Block::AppendVariables
uint32_t AppendVariables(bool can_create, bool get_parent_variables, bool stop_if_block_is_inlined_function, const std::function< bool(Variable *)> &filter, VariableList *variable_list)
Appends the variables from this block, and optionally from all parent blocks, to variable_list.
Definition: Block.cpp:442
lldb_private::Instruction::Operand::Type::Dereference
@ Dereference
Symbol.h
lldb_private::StackFrame::CalculateStackFrame
lldb::StackFrameSP CalculateStackFrame() override
Definition: StackFrame.cpp:1753
lldb_private::Debugger::eStopDisassemblyTypeNoSource
@ eStopDisassemblyTypeNoSource
Definition: Debugger.h:283
lldb_private::OperandMatchers::MatchRegOp
std::function< bool(const Instruction::Operand &)> MatchRegOp(const RegisterInfo &info)
Definition: Disassembler.h:255
lldb_private::Debugger::GetStopDisassemblyDisplay
StopDisassemblyType GetStopDisassemblyDisplay() const
Definition: Debugger.cpp:424
lldb_private::Target::GetArchitecture
const ArchSpec & GetArchitecture() const
Definition: Target.h:967
lldb_private::StackFrame::m_disassembly
StreamString m_disassembly
Definition: StackFrame.h:527
lldb_private::Instruction::Operand::BuildSum
static Operand BuildSum(const Operand &lhs, const Operand &rhs)
Definition: Disassembler.cpp:1206
lldb_private::Status
Definition: Status.h:44
lldb_private::CompilerType::GetPointerType
CompilerType GetPointerType() const
Return a new CompilerType that is a pointer to this type.
Definition: CompilerType.cpp:407
lldb_private::StackFrame::GetThread
lldb::ThreadSP GetThread() const
Definition: StackFrame.h:125
lldb_private::StackFrame::GuessValueForAddress
lldb::ValueObjectSP GuessValueForAddress(lldb::addr_t addr)
Attempt to econstruct the ValueObject for a given raw address touched by the current instruction.
Definition: StackFrame.cpp:1286
lldb_private::Block
Definition: Block.h:41
lldb::eLanguageTypeUnknown
@ eLanguageTypeUnknown
Unknown or invalid language value.
Definition: lldb-enumerations.h:437
lldb_private::OperandMatchers::MatchUnaryOp
std::function< bool(const Instruction::Operand &)> MatchUnaryOp(std::function< bool(const Instruction::Operand &)> base, std::function< bool(const Instruction::Operand &)> child)
Definition: Disassembler.h:251
uint32_t
lldb_private::StackFrame::CalculateExecutionContext
void CalculateExecutionContext(ExecutionContext &exe_ctx) override
Reconstruct the object's execution context into sc.
Definition: StackFrame.cpp:1755
lldb_private::StackFrame::m_mutex
std::recursive_mutex m_mutex
Definition: StackFrame.h:528
lldb_private::ExecutionContext::GetBestExecutionContextScope
ExecutionContextScope * GetBestExecutionContextScope() const
Definition: ExecutionContext.cpp:216
lldb_private::Flags::Get
ValueType Get() const
Get accessor for all flags.
Definition: Flags.h:40
lldb_private::Address
Definition: Address.h:59
lldb_private::SymbolContext::GetFunctionMethodInfo
bool GetFunctionMethodInfo(lldb::LanguageType &language, bool &is_instance_method, ConstString &language_object_name)
If this symbol context represents a function that is a method, return true and provide information ab...
Definition: SymbolContext.cpp:545
lldb_private::Disassembler::Limit::Instructions
@ Instructions
Definition: Disassembler.h:401
lldb_private::Stream::EOL
size_t EOL()
Output and End of Line character to the stream.
Definition: Stream.cpp:128
lldb_private::SymbolContext::GetResolvedMask
uint32_t GetResolvedMask() const
Definition: SymbolContext.cpp:284
lldb_private::StackFrame::GuessLanguage
lldb::LanguageType GuessLanguage()
Definition: StackFrame.cpp:1192
lldb_private::StackFrame::GetLanguage
lldb::LanguageType GetLanguage()
Query this frame to determine what the default language should be when parsing expressions given the ...
Definition: StackFrame.cpp:1185
lldb_private::Type
Definition: Type.h:66
lldb_private::Status::SetErrorString
void SetErrorString(llvm::StringRef err_str)
Set the current error string to err_str.
Definition: Status.cpp:242
lldb_private::Address::GetLoadAddress
lldb::addr_t GetLoadAddress(Target *target) const
Get the load address.
Definition: Address.cpp:310
lldb_private::StackFrame::IsArtificial
bool IsArtificial() const
Query whether this frame is artificial (e.g a synthesized result of inferring missing tail call frame...
Definition: StackFrame.cpp:1181
lldb_private::AddressClass::eCode
@ eCode
lldb_private::StackFrame::Disassemble
const char * Disassemble()
Return the disassembly for the instructions of this StackFrame's function as a single C string.
Definition: StackFrame.cpp:259
lldb_private::Type::GetForwardCompilerType
CompilerType GetForwardCompilerType()
Definition: Type.cpp:656
lldb_private::FormatEntity::Entry
Definition: FormatEntity.h:40
UINT32_MAX
#define UINT32_MAX
Definition: lldb-defines.h:31
FormatEntity.h
lldb_private::SymbolContext::module_sp
lldb::ModuleSP module_sp
The Module for a given query.
Definition: SymbolContext.h:318
lldb_private::StackFrame::Dump
void Dump(Stream *strm, bool show_frame_index, bool show_fullpaths)
Print a description for this frame using a default format.
Definition: StackFrame.cpp:1789
lldb_private::Address::SetOffset
bool SetOffset(lldb::addr_t offset)
Set accessor for the offset.
Definition: Address.h:429
lldb_private::AddressRange::SetByteSize
void SetByteSize(lldb::addr_t byte_size)
Set accessor for the byte size of this range.
Definition: AddressRange.h:237
LLDB_INVALID_ADDRESS
#define LLDB_INVALID_ADDRESS
Definition: lldb-defines.h:86
lldb_private::ConstString::GetCString
const char * GetCString() const
Get the string value as a C string.
Definition: ConstString.h:216
lldb_private::Instruction::Operand::m_type
enum lldb_private::Instruction::Operand::Type m_type
lldb_private::CompilerType::GetBasicTypeFromAST
CompilerType GetBasicTypeFromAST(lldb::BasicType basic_type) const
Create related types using the current type's AST.
Definition: CompilerType.cpp:474
lldb_private::CompilerType
Generic representation of a type in a programming language.
Definition: CompilerType.h:33
Function.h
lldb_private::StackFrame::eExpressionPathOptionsAllowDirectIVarAccess
@ eExpressionPathOptionsAllowDirectIVarAccess
Definition: StackFrame.h:48
lldb_private::Stream::Printf
size_t Printf(const char *format,...) __attribute__((format(printf
Output printf formatted output to the stream.
Definition: Stream.cpp:107
lldb_private::StackFrame::CalculateProcess
lldb::ProcessSP CalculateProcess() override
Definition: StackFrame.cpp:1743
lldb_private::StackFrame::Kind::Artificial
@ Artificial
An artificial stack frame (e.g.
lldb_private::Function::GetMangled
const Mangled & GetMangled() const
Definition: Function.h:542
lldb::user_id_t
uint64_t user_id_t
Definition: lldb-types.h:84
lldb_private::SymbolContext::Clear
void Clear(bool clear_target)
Clear the object's state.
Definition: SymbolContext.cpp:55
lldb_private::Disassembler
Definition: Disassembler.h:368
RESOLVED_FRAME_ID_SYMBOL_SCOPE
#define RESOLVED_FRAME_ID_SYMBOL_SCOPE
Definition: StackFrame.cpp:46
lldb::eLanguageTypeC
@ eLanguageTypeC
Non-standardized C, such as K&R.
Definition: lldb-enumerations.h:439
lldb_private::StackFrame::m_variable_list_value_objects
ValueObjectList m_variable_list_value_objects
Definition: StackFrame.h:523
lldb_private
A class that represents a running process on the host machine.
Definition: SBCommandInterpreterRunOptions.h:16
lldb_private::Instruction::Operand::Type::Product
@ Product
lldb_private::Debugger::GetFrameFormatUnique
const FormatEntity::Entry * GetFrameFormatUnique() const
Definition: Debugger.cpp:266
lldb_private::StackFrame::Kind
Kind
Definition: StackFrame.h:52
lldb_private::Disassembler::GetInstructionList
InstructionList & GetInstructionList()
Definition: Disassembler.cpp:1100
lldb_private::StackFrame::GetRegisterContext
lldb::RegisterContextSP GetRegisterContext()
Get the RegisterContext for this frame, if possible.
Definition: StackFrame.cpp:1123
lldb_private::StackFrame::GetFrameCodeAddressForSymbolication
Address GetFrameCodeAddressForSymbolication()
Get the current code Address suitable for symbolication, may not be the same as GetFrameCodeAddress()...
Definition: StackFrame.cpp:220
lldb_private::StackFrame::GetFrameBaseExpression
DWARFExpression * GetFrameBaseExpression(Status *error_ptr)
Get the DWARFExpression corresponding to the Canonical Frame Address.
Definition: StackFrame.cpp:1112
lldb_private::StackFrame::m_reg_context_sp
lldb::RegisterContextSP m_reg_context_sp
Definition: StackFrame.h:504
lldb_private::Function::GetCompilerType
CompilerType GetCompilerType()
Definition: Function.cpp:522
lldb_private::StackFrame::IsHistorical
bool IsHistorical() const
Query whether this frame is part of a historical backtrace.
Definition: StackFrame.cpp:1177
lldb_private::Address::IsSectionOffset
bool IsSectionOffset() const
Check if an address is section offset.
Definition: Address.h:323
lldb_private::Status::Clear
void Clear()
Clear the object state.
Definition: Status.cpp:168
lldb_private::Flags::Set
ValueType Set(ValueType mask)
Set one or more flags by logical OR'ing mask with the current flags.
Definition: Flags.h:73
lldb_private::StackID
Definition: StackID.h:17
lldb_private::Address::GetOffset
lldb::addr_t GetOffset() const
Get the section relative offset value.
Definition: Address.h:310
lldb_private::StackFrame::GetRecognizedFrame
lldb::RecognizedStackFrameSP GetRecognizedFrame()
Definition: StackFrame.cpp:1933
ValueObjectVariable.h
lldb_private::Address::GetModule
lldb::ModuleSP GetModule() const
Get accessor for the module for this address.
Definition: Address.cpp:282
lldb_private::VariableList::FindIndexForVariable
uint32_t FindIndexForVariable(Variable *variable)
Definition: VariableList.cpp:145
lldb_private::Debugger::GetStopSourceLineCount
uint32_t GetStopSourceLineCount(bool before) const
Definition: Debugger.cpp:417
lldb_private::StackFrame::GetFrameIndex
uint32_t GetFrameIndex() const
Query this frame to find what frame it is in this Thread's StackFrameList.
Definition: StackFrame.cpp:173
lldb_private::Variable
Definition: Variable.h:25
lldb_private::Variable::LocationIsValidForFrame
bool LocationIsValidForFrame(StackFrame *frame)
Definition: Variable.cpp:224
lldb_private::Stream::PutCString
size_t PutCString(llvm::StringRef cstr)
Output a C string to the stream.
Definition: Stream.cpp:63
lldb_private::Function::GetFrameBaseExpression
DWARFExpression & GetFrameBaseExpression()
Get accessor for the frame base location.
Definition: Function.h:528
lldb_private::StackFrame::GetInScopeVariableList
lldb::VariableListSP GetInScopeVariableList(bool get_file_globals, bool must_have_valid_location=false)
Retrieve the list of variables that are in scope at this StackFrame's pc.
Definition: StackFrame.cpp:461
lldb_private::DWARFExpression::Evaluate
bool Evaluate(ExecutionContextScope *exe_scope, lldb::addr_t func_load_addr, const Value *initial_value_ptr, const Value *object_address_ptr, Value &result, Status *error_ptr) const
Wrapper for the static evaluate function that accepts an ExecutionContextScope instead of an Executio...
Definition: DWARFExpression.cpp:847
lldb_private::Target::GetSourceManager
SourceManager & GetSourceManager()
Definition: Target.cpp:2595
lldb_private::ValueObjectVariable::Create
static lldb::ValueObjectSP Create(ExecutionContextScope *exe_scope, const lldb::VariableSP &var_sp)
Definition: ValueObjectVariable.cpp:51
lldb_private::GetLogIfAnyCategoriesSet
Log * GetLogIfAnyCategoriesSet(uint32_t mask)
Definition: Logging.cpp:62
lldb_private::SymbolContext::line_entry
LineEntry line_entry
The LineEntry for a given query.
Definition: SymbolContext.h:322
lldb_private::InstructionList::GetIndexOfInstructionAtAddress
uint32_t GetIndexOfInstructionAtAddress(const Address &addr)
Definition: Disassembler.cpp:1016
lldb_private::StackFrame::m_cfa_is_valid
bool m_cfa_is_valid
Definition: StackFrame.h:513
lldb_private::StackFrame
Definition: StackFrame.h:40
lldb_private::StackFrame::m_variable_list_sp
lldb::VariableListSP m_variable_list_sp
Definition: StackFrame.h:522
lldb
Definition: SBAddress.h:15
StackFrameRecognizer.h
LIBLLDB_LOG_THREAD
#define LIBLLDB_LOG_THREAD
Definition: Logging.h:16
RegisterContext.h
LLDB_LOG_ERROR
#define LLDB_LOG_ERROR(log, error,...)
Definition: Log.h:265
Value.h
lldb_private::Flags::IsClear
bool IsClear(ValueType bit) const
Test a single flag bit to see if it is clear (zero).
Definition: Flags.h:111
lldb_private::StackFrame::GetSymbolContext
const SymbolContext & GetSymbolContext(lldb::SymbolContextItem resolve_scope)
Provide a SymbolContext for this StackFrame's current pc value.
Definition: StackFrame.cpp:298
lldb_private::StackFrame::SetSymbolContextScope
void SetSymbolContextScope(SymbolContextScope *symbol_scope)
Definition: StackFrame.cpp:182
lldb_private::Block::GetContainingInlinedBlock
Block * GetContainingInlinedBlock()
Get the inlined block that contains this block.
Definition: Block.cpp:207
lldb_private::ExecutionContext::GetTargetPtr
Target * GetTargetPtr() const
Returns a pointer to the target object.
Definition: ExecutionContext.cpp:200
ExecutionContext.h
lldb_private::StackFrame::ChangePC
bool ChangePC(lldb::addr_t pc)
Change the pc value for a given thread.
Definition: StackFrame.cpp:245
lldb_private::Instruction::Operand::m_clobbered
bool m_clobbered
Definition: Disassembler.h:198
lldb_private::RegisterContext::GetRegisterInfoByName
const RegisterInfo * GetRegisterInfoByName(llvm::StringRef reg_name, uint32_t start_idx=0)
Definition: RegisterContext.cpp:52
lldb_private::StackFrame::eExpressionPathOptionsInspectAnonymousUnions
@ eExpressionPathOptionsInspectAnonymousUnions
Definition: StackFrame.h:49
lldb_private::StackFrame::UpdatePreviousFrameFromCurrentFrame
void UpdatePreviousFrameFromCurrentFrame(StackFrame &curr_frame)
Definition: StackFrame.cpp:1825
lldb_private::StackFrame::m_concrete_frame_index
uint32_t m_concrete_frame_index
Definition: StackFrame.h:503
lldb_private::StackFrame::GetValueObjectForFrameVariable
lldb::ValueObjectSP GetValueObjectForFrameVariable(const lldb::VariableSP &variable_sp, lldb::DynamicValueType use_dynamic)
Create a ValueObject for a given Variable in this StackFrame.
Definition: StackFrame.cpp:1139
lldb_private::Instruction::Operand::Type::Immediate
@ Immediate
lldb_private::Debugger::GetFrameFormat
const FormatEntity::Entry * GetFrameFormat() const
Definition: Debugger.cpp:261