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