LLDB  mainline
RegisterContextUnwind.cpp
Go to the documentation of this file.
1 //===-- RegisterContextUnwind.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/Address.h"
11 #include "lldb/Core/AddressRange.h"
12 #include "lldb/Core/Module.h"
13 #include "lldb/Core/Value.h"
19 #include "lldb/Symbol/Function.h"
20 #include "lldb/Symbol/ObjectFile.h"
21 #include "lldb/Symbol/Symbol.h"
23 #include "lldb/Symbol/SymbolFile.h"
24 #include "lldb/Target/ABI.h"
28 #include "lldb/Target/Platform.h"
29 #include "lldb/Target/Process.h"
31 #include "lldb/Target/StackFrame.h"
32 #include "lldb/Target/Target.h"
33 #include "lldb/Target/Thread.h"
35 #include "lldb/Utility/LLDBLog.h"
36 #include "lldb/Utility/Log.h"
38 #include "lldb/Utility/VASPrintf.h"
39 #include "lldb/lldb-private.h"
40 #include <memory>
41 
42 using namespace lldb;
43 using namespace lldb_private;
44 
46  if (sym_ctx.symbol)
47  return sym_ctx.symbol->GetName();
48  else if (sym_ctx.function)
49  return sym_ctx.function->GetName();
50  return ConstString();
51 }
52 
53 RegisterContextUnwind::RegisterContextUnwind(Thread &thread,
54  const SharedPtr &next_frame,
55  SymbolContext &sym_ctx,
56  uint32_t frame_number,
57  UnwindLLDB &unwind_lldb)
58  : RegisterContext(thread, frame_number), m_thread(thread),
59  m_fast_unwind_plan_sp(), m_full_unwind_plan_sp(),
60  m_fallback_unwind_plan_sp(), m_all_registers_available(false),
61  m_frame_type(-1), m_cfa(LLDB_INVALID_ADDRESS),
62  m_afa(LLDB_INVALID_ADDRESS), m_start_pc(), m_current_pc(),
63  m_current_offset(0), m_current_offset_backed_up_one(0),
64  m_behaves_like_zeroth_frame(false), m_sym_ctx(sym_ctx),
65  m_sym_ctx_valid(false), m_frame_number(frame_number), m_registers(),
66  m_parent_unwind(unwind_lldb) {
67  m_sym_ctx.Clear(false);
68  m_sym_ctx_valid = false;
69 
70  if (IsFrameZero()) {
72  } else {
74  }
75 
76  // This same code exists over in the GetFullUnwindPlanForFrame() but it may
77  // not have been executed yet
78  if (IsFrameZero() || next_frame->m_frame_type == eTrapHandlerFrame ||
79  next_frame->m_frame_type == eDebuggerFrame) {
81  }
82 }
83 
85  lldb::UnwindPlanSP unwind_plan_sp) {
86  if (!unwind_plan_sp)
87  return false;
88 
89  // check if m_current_pc is valid
90  if (unwind_plan_sp->PlanValidAtAddress(m_current_pc)) {
91  // yes - current offset can be used as is
92  return true;
93  }
94 
95  // if m_current_offset <= 0, we've got nothing else to try
96  if (m_current_offset <= 0)
97  return false;
98 
99  // check pc - 1 to see if it's valid
100  Address pc_minus_one(m_current_pc);
101  pc_minus_one.SetOffset(m_current_pc.GetOffset() - 1);
102  if (unwind_plan_sp->PlanValidAtAddress(pc_minus_one)) {
103  return true;
104  }
105 
106  return false;
107 }
108 
109 // Initialize a RegisterContextUnwind which is the first frame of a stack -- the
110 // zeroth frame or currently executing frame.
111 
113  Log *log = GetLog(LLDBLog::Unwind);
114  ExecutionContext exe_ctx(m_thread.shared_from_this());
115  RegisterContextSP reg_ctx_sp = m_thread.GetRegisterContext();
116 
117  if (reg_ctx_sp.get() == nullptr) {
119  UnwindLogMsg("frame does not have a register context");
120  return;
121  }
122 
123  addr_t current_pc = reg_ctx_sp->GetPC();
124 
125  if (current_pc == LLDB_INVALID_ADDRESS) {
127  UnwindLogMsg("frame does not have a pc");
128  return;
129  }
130 
131  Process *process = exe_ctx.GetProcessPtr();
132 
133  // Let ABIs fixup code addresses to make sure they are valid. In ARM ABIs
134  // this will strip bit zero in case we read a PC from memory or from the LR.
135  // (which would be a no-op in frame 0 where we get it from the register set,
136  // but still a good idea to make the call here for other ABIs that may
137  // exist.)
138  ABI *abi = process->GetABI().get();
139  if (abi)
140  current_pc = abi->FixCodeAddress(current_pc);
141 
142  UnwindPlanSP lang_runtime_plan_sp = LanguageRuntime::GetRuntimeUnwindPlan(
144  if (lang_runtime_plan_sp.get()) {
145  UnwindLogMsg("This is an async frame");
146  }
147 
148  // Initialize m_current_pc, an Address object, based on current_pc, an
149  // addr_t.
150  m_current_pc.SetLoadAddress(current_pc, &process->GetTarget());
151 
152  // If we don't have a Module for some reason, we're not going to find
153  // symbol/function information - just stick in some reasonable defaults and
154  // hope we can unwind past this frame.
155  ModuleSP pc_module_sp(m_current_pc.GetModule());
156  if (!m_current_pc.IsValid() || !pc_module_sp) {
157  UnwindLogMsg("using architectural default unwind method");
158  }
159 
160  AddressRange addr_range;
162 
163  if (m_sym_ctx.symbol) {
164  UnwindLogMsg("with pc value of 0x%" PRIx64 ", symbol name is '%s'",
165  current_pc, GetSymbolOrFunctionName(m_sym_ctx).AsCString(""));
166  } else if (m_sym_ctx.function) {
167  UnwindLogMsg("with pc value of 0x%" PRIx64 ", function name is '%s'",
168  current_pc, GetSymbolOrFunctionName(m_sym_ctx).AsCString(""));
169  } else {
170  UnwindLogMsg("with pc value of 0x%" PRIx64
171  ", no symbol/function name is known.",
172  current_pc);
173  }
174 
175  if (IsTrapHandlerSymbol(process, m_sym_ctx)) {
177  } else {
178  // FIXME: Detect eDebuggerFrame here.
180  }
181 
182  // If we were able to find a symbol/function, set addr_range to the bounds of
183  // that symbol/function. else treat the current pc value as the start_pc and
184  // record no offset.
185  if (addr_range.GetBaseAddress().IsValid()) {
186  m_start_pc = addr_range.GetBaseAddress();
189  } else if (m_current_pc.GetModule() == m_start_pc.GetModule()) {
190  // This means that whatever symbol we kicked up isn't really correct ---
191  // we should not cross section boundaries ... We really should NULL out
192  // the function/symbol in this case unless there is a bad assumption here
193  // due to inlined functions?
196  }
198  } else {
200  m_current_offset = -1;
202  }
203 
204  // We've set m_frame_type and m_sym_ctx before these calls.
205 
208 
209  UnwindPlan::RowSP active_row;
210  lldb::RegisterKind row_register_kind = eRegisterKindGeneric;
211 
212  // If we have LanguageRuntime UnwindPlan for this unwind, use those
213  // rules to find the caller frame instead of the function's normal
214  // UnwindPlans. The full unwind plan for this frame will be
215  // the LanguageRuntime-provided unwind plan, and there will not be a
216  // fast unwind plan.
217  if (lang_runtime_plan_sp.get()) {
218  active_row =
219  lang_runtime_plan_sp->GetRowForFunctionOffset(m_current_offset);
220  row_register_kind = lang_runtime_plan_sp->GetRegisterKind();
221  if (!ReadFrameAddress(row_register_kind, active_row->GetCFAValue(),
222  m_cfa)) {
223  UnwindLogMsg("Cannot set cfa");
224  } else {
225  m_full_unwind_plan_sp = lang_runtime_plan_sp;
226  if (log) {
227  StreamString active_row_strm;
228  active_row->Dump(active_row_strm, lang_runtime_plan_sp.get(), &m_thread,
230  UnwindLogMsg("async active row: %s", active_row_strm.GetData());
231  }
232  UnwindLogMsg("m_cfa = 0x%" PRIx64 " m_afa = 0x%" PRIx64, m_cfa, m_afa);
233  UnwindLogMsg(
234  "initialized async frame current pc is 0x%" PRIx64
235  " cfa is 0x%" PRIx64 " afa is 0x%" PRIx64,
236  (uint64_t)m_current_pc.GetLoadAddress(exe_ctx.GetTargetPtr()),
237  (uint64_t)m_cfa, (uint64_t)m_afa);
238 
239  return;
240  }
241  }
242 
243  if (m_full_unwind_plan_sp &&
244  m_full_unwind_plan_sp->PlanValidAtAddress(m_current_pc)) {
245  active_row =
246  m_full_unwind_plan_sp->GetRowForFunctionOffset(m_current_offset);
247  row_register_kind = m_full_unwind_plan_sp->GetRegisterKind();
248  if (active_row.get() && log) {
249  StreamString active_row_strm;
250  active_row->Dump(active_row_strm, m_full_unwind_plan_sp.get(), &m_thread,
252  UnwindLogMsg("%s", active_row_strm.GetData());
253  }
254  }
255 
256  if (!active_row.get()) {
257  UnwindLogMsg("could not find an unwindplan row for this frame's pc");
259  return;
260  }
261 
262  if (!ReadFrameAddress(row_register_kind, active_row->GetCFAValue(), m_cfa)) {
263  // Try the fall back unwind plan since the
264  // full unwind plan failed.
265  FuncUnwindersSP func_unwinders_sp;
266  UnwindPlanSP call_site_unwind_plan;
267  bool cfa_status = false;
268 
269  if (m_sym_ctx_valid) {
270  func_unwinders_sp =
271  pc_module_sp->GetUnwindTable().GetFuncUnwindersContainingAddress(
273  }
274 
275  if (func_unwinders_sp.get() != nullptr)
276  call_site_unwind_plan = func_unwinders_sp->GetUnwindPlanAtCallSite(
277  process->GetTarget(), m_thread);
278 
279  if (call_site_unwind_plan.get() != nullptr) {
280  m_fallback_unwind_plan_sp = call_site_unwind_plan;
281  if (TryFallbackUnwindPlan())
282  cfa_status = true;
283  }
284  if (!cfa_status) {
285  UnwindLogMsg("could not read CFA value for first frame.");
287  return;
288  }
289  } else
290  ReadFrameAddress(row_register_kind, active_row->GetAFAValue(), m_afa);
291 
292  UnwindLogMsg("initialized frame current pc is 0x%" PRIx64 " cfa is 0x%" PRIx64
293  " afa is 0x%" PRIx64 " using %s UnwindPlan",
294  (uint64_t)m_current_pc.GetLoadAddress(exe_ctx.GetTargetPtr()),
295  (uint64_t)m_cfa,
296  (uint64_t)m_afa,
297  m_full_unwind_plan_sp->GetSourceName().GetCString());
298 }
299 
300 // Initialize a RegisterContextUnwind for the non-zeroth frame -- rely on the
301 // RegisterContextUnwind "below" it to provide things like its current pc value.
302 
304  Log *log = GetLog(LLDBLog::Unwind);
305  if (IsFrameZero()) {
307  UnwindLogMsg("non-zeroth frame tests positive for IsFrameZero -- that "
308  "shouldn't happen.");
309  return;
310  }
311 
312  if (!GetNextFrame().get() || !GetNextFrame()->IsValid()) {
314  UnwindLogMsg("Could not get next frame, marking this frame as invalid.");
315  return;
316  }
317  if (!m_thread.GetRegisterContext()) {
319  UnwindLogMsg("Could not get register context for this thread, marking this "
320  "frame as invalid.");
321  return;
322  }
323 
324  ExecutionContext exe_ctx(m_thread.shared_from_this());
325  Process *process = exe_ctx.GetProcessPtr();
326 
327  // Some languages may have a logical parent stack frame which is
328  // not a real stack frame, but the programmer would consider it to
329  // be the caller of the frame, e.g. Swift asynchronous frames.
330  //
331  // A LanguageRuntime may provide an UnwindPlan that is used in this
332  // stack trace base on the RegisterContext contents, intsead
333  // of the normal UnwindPlans we would use for the return-pc.
334  UnwindPlanSP lang_runtime_plan_sp = LanguageRuntime::GetRuntimeUnwindPlan(
336  if (lang_runtime_plan_sp.get()) {
337  UnwindLogMsg("This is an async frame");
338  }
339 
340  addr_t pc;
342  UnwindLogMsg("could not get pc value");
344  return;
345  }
346 
347  // Let ABIs fixup code addresses to make sure they are valid. In ARM ABIs
348  // this will strip bit zero in case we read a PC from memory or from the LR.
349  ABI *abi = process->GetABI().get();
350  if (abi)
351  pc = abi->FixCodeAddress(pc);
352 
353  if (log) {
354  UnwindLogMsg("pc = 0x%" PRIx64, pc);
355  addr_t reg_val;
357  UnwindLogMsg("fp = 0x%" PRIx64, reg_val);
359  UnwindLogMsg("sp = 0x%" PRIx64, reg_val);
360  }
361 
362  // A pc of 0x0 means it's the end of the stack crawl unless we're above a trap
363  // handler function
364  bool above_trap_handler = false;
365  if (GetNextFrame().get() && GetNextFrame()->IsValid() &&
367  above_trap_handler = true;
368 
369  if (pc == 0 || pc == 0x1) {
370  if (!above_trap_handler) {
372  UnwindLogMsg("this frame has a pc of 0x0");
373  return;
374  }
375  }
376 
377  const bool allow_section_end = true;
378  m_current_pc.SetLoadAddress(pc, &process->GetTarget(), allow_section_end);
379 
380  // If we don't have a Module for some reason, we're not going to find
381  // symbol/function information - just stick in some reasonable defaults and
382  // hope we can unwind past this frame. If we're above a trap handler,
383  // we may be at a bogus address because we jumped through a bogus function
384  // pointer and trapped, so don't force the arch default unwind plan in that
385  // case.
386  ModuleSP pc_module_sp(m_current_pc.GetModule());
387  if ((!m_current_pc.IsValid() || !pc_module_sp) &&
388  above_trap_handler == false) {
389  UnwindLogMsg("using architectural default unwind method");
390 
391  // Test the pc value to see if we know it's in an unmapped/non-executable
392  // region of memory.
393  uint32_t permissions;
394  if (process->GetLoadAddressPermissions(pc, permissions) &&
395  (permissions & ePermissionsExecutable) == 0) {
396  // If this is the second frame off the stack, we may have unwound the
397  // first frame incorrectly. But using the architecture default unwind
398  // plan may get us back on track -- albeit possibly skipping a real
399  // frame. Give this frame a clearly-invalid pc and see if we can get any
400  // further.
401  if (GetNextFrame().get() && GetNextFrame()->IsValid() &&
402  GetNextFrame()->IsFrameZero()) {
403  UnwindLogMsg("had a pc of 0x%" PRIx64 " which is not in executable "
404  "memory but on frame 1 -- "
405  "allowing it once.",
406  (uint64_t)pc);
408  } else {
409  // anywhere other than the second frame, a non-executable pc means
410  // we're off in the weeds -- stop now.
412  UnwindLogMsg("pc is in a non-executable section of memory and this "
413  "isn't the 2nd frame in the stack walk.");
414  return;
415  }
416  }
417 
418  if (abi) {
419  m_fast_unwind_plan_sp.reset();
421  std::make_shared<UnwindPlan>(lldb::eRegisterKindGeneric);
423  if (m_frame_type != eSkipFrame) // don't override eSkipFrame
424  {
426  }
428  m_current_offset = -1;
430  RegisterKind row_register_kind = m_full_unwind_plan_sp->GetRegisterKind();
431  UnwindPlan::RowSP row = m_full_unwind_plan_sp->GetRowForFunctionOffset(0);
432  if (row.get()) {
433  if (!ReadFrameAddress(row_register_kind, row->GetCFAValue(), m_cfa)) {
434  UnwindLogMsg("failed to get cfa value");
435  if (m_frame_type != eSkipFrame) // don't override eSkipFrame
436  {
438  }
439  return;
440  }
441 
442  ReadFrameAddress(row_register_kind, row->GetAFAValue(), m_afa);
443 
444  // A couple of sanity checks..
445  if (m_cfa == LLDB_INVALID_ADDRESS || m_cfa == 0 || m_cfa == 1) {
446  UnwindLogMsg("could not find a valid cfa address");
448  return;
449  }
450 
451  // m_cfa should point into the stack memory; if we can query memory
452  // region permissions, see if the memory is allocated & readable.
453  if (process->GetLoadAddressPermissions(m_cfa, permissions) &&
454  (permissions & ePermissionsReadable) == 0) {
456  UnwindLogMsg(
457  "the CFA points to a region of memory that is not readable");
458  return;
459  }
460  } else {
461  UnwindLogMsg("could not find a row for function offset zero");
463  return;
464  }
465 
466  if (CheckIfLoopingStack()) {
468  if (CheckIfLoopingStack()) {
469  UnwindLogMsg("same CFA address as next frame, assuming the unwind is "
470  "looping - stopping");
472  return;
473  }
474  }
475 
476  UnwindLogMsg("initialized frame cfa is 0x%" PRIx64 " afa is 0x%" PRIx64,
477  (uint64_t)m_cfa, (uint64_t)m_afa);
478  return;
479  }
481  UnwindLogMsg("could not find any symbol for this pc, or a default unwind "
482  "plan, to continue unwind.");
483  return;
484  }
485 
486  AddressRange addr_range;
488 
489  if (m_sym_ctx.symbol) {
490  UnwindLogMsg("with pc value of 0x%" PRIx64 ", symbol name is '%s'", pc,
491  GetSymbolOrFunctionName(m_sym_ctx).AsCString(""));
492  } else if (m_sym_ctx.function) {
493  UnwindLogMsg("with pc value of 0x%" PRIx64 ", function name is '%s'", pc,
494  GetSymbolOrFunctionName(m_sym_ctx).AsCString(""));
495  } else {
496  UnwindLogMsg("with pc value of 0x%" PRIx64
497  ", no symbol/function name is known.",
498  pc);
499  }
500 
501  bool decr_pc_and_recompute_addr_range;
502 
503  if (!m_sym_ctx_valid) {
504  // Always decrement and recompute if the symbol lookup failed
505  decr_pc_and_recompute_addr_range = true;
506  } else if (GetNextFrame()->m_frame_type == eTrapHandlerFrame ||
508  // Don't decrement if we're "above" an asynchronous event like
509  // sigtramp.
510  decr_pc_and_recompute_addr_range = false;
511  } else if (!addr_range.GetBaseAddress().IsValid() ||
512  addr_range.GetBaseAddress().GetSection() != m_current_pc.GetSection() ||
513  addr_range.GetBaseAddress().GetOffset() != m_current_pc.GetOffset()) {
514  // If our "current" pc isn't the start of a function, decrement the pc
515  // if we're up the stack.
517  decr_pc_and_recompute_addr_range = false;
518  else
519  decr_pc_and_recompute_addr_range = true;
520  } else if (IsTrapHandlerSymbol(process, m_sym_ctx)) {
521  // Signal dispatch may set the return address of the handler it calls to
522  // point to the first byte of a return trampoline (like __kernel_rt_sigreturn),
523  // so do not decrement and recompute if the symbol we already found is a trap
524  // handler.
525  decr_pc_and_recompute_addr_range = false;
526  } else if (m_behaves_like_zeroth_frame) {
527  decr_pc_and_recompute_addr_range = false;
528  } else {
529  // Decrement to find the function containing the call.
530  decr_pc_and_recompute_addr_range = true;
531  }
532 
533  // We need to back up the pc by 1 byte and re-search for the Symbol to handle
534  // the case where the "saved pc" value is pointing to the next function, e.g.
535  // if a function ends with a CALL instruction.
536  // FIXME this may need to be an architectural-dependent behavior; if so we'll
537  // need to add a member function
538  // to the ABI plugin and consult that.
539  if (decr_pc_and_recompute_addr_range) {
540  UnwindLogMsg("Backing up the pc value of 0x%" PRIx64
541  " by 1 and re-doing symbol lookup; old symbol was %s",
542  pc, GetSymbolOrFunctionName(m_sym_ctx).AsCString(""));
543  Address temporary_pc;
544  temporary_pc.SetLoadAddress(pc - 1, &process->GetTarget());
545  m_sym_ctx.Clear(false);
546  m_sym_ctx_valid = temporary_pc.ResolveFunctionScope(m_sym_ctx, &addr_range);
547 
548  UnwindLogMsg("Symbol is now %s",
549  GetSymbolOrFunctionName(m_sym_ctx).AsCString(""));
550  }
551 
552  // If we were able to find a symbol/function, set addr_range_ptr to the
553  // bounds of that symbol/function. else treat the current pc value as the
554  // start_pc and record no offset.
555  if (addr_range.GetBaseAddress().IsValid()) {
556  m_start_pc = addr_range.GetBaseAddress();
559  if (decr_pc_and_recompute_addr_range &&
562  if (m_sym_ctx_valid) {
563  m_current_pc.SetLoadAddress(pc - 1, &process->GetTarget());
564  }
565  }
566  } else {
568  m_current_offset = -1;
570  }
571 
572  if (IsTrapHandlerSymbol(process, m_sym_ctx)) {
574  } else {
575  // FIXME: Detect eDebuggerFrame here.
576  if (m_frame_type != eSkipFrame) // don't override eSkipFrame
577  {
579  }
580  }
581 
582  UnwindPlan::RowSP active_row;
583  RegisterKind row_register_kind = eRegisterKindGeneric;
584 
585  // If we have LanguageRuntime UnwindPlan for this unwind, use those
586  // rules to find the caller frame instead of the function's normal
587  // UnwindPlans. The full unwind plan for this frame will be
588  // the LanguageRuntime-provided unwind plan, and there will not be a
589  // fast unwind plan.
590  if (lang_runtime_plan_sp.get()) {
591  active_row =
592  lang_runtime_plan_sp->GetRowForFunctionOffset(m_current_offset);
593  row_register_kind = lang_runtime_plan_sp->GetRegisterKind();
594  if (!ReadFrameAddress(row_register_kind, active_row->GetCFAValue(),
595  m_cfa)) {
596  UnwindLogMsg("Cannot set cfa");
597  } else {
598  m_full_unwind_plan_sp = lang_runtime_plan_sp;
599  if (log) {
600  StreamString active_row_strm;
601  active_row->Dump(active_row_strm, lang_runtime_plan_sp.get(), &m_thread,
603  UnwindLogMsg("async active row: %s", active_row_strm.GetData());
604  }
605  UnwindLogMsg("m_cfa = 0x%" PRIx64 " m_afa = 0x%" PRIx64, m_cfa, m_afa);
606  UnwindLogMsg(
607  "initialized async frame current pc is 0x%" PRIx64
608  " cfa is 0x%" PRIx64 " afa is 0x%" PRIx64,
609  (uint64_t)m_current_pc.GetLoadAddress(exe_ctx.GetTargetPtr()),
610  (uint64_t)m_cfa, (uint64_t)m_afa);
611 
612  return;
613  }
614  }
615 
616  // We've set m_frame_type and m_sym_ctx before this call.
618 
619  // Try to get by with just the fast UnwindPlan if possible - the full
620  // UnwindPlan may be expensive to get (e.g. if we have to parse the entire
621  // eh_frame section of an ObjectFile for the first time.)
622 
623  if (m_fast_unwind_plan_sp &&
624  m_fast_unwind_plan_sp->PlanValidAtAddress(m_current_pc)) {
625  active_row =
626  m_fast_unwind_plan_sp->GetRowForFunctionOffset(m_current_offset);
627  row_register_kind = m_fast_unwind_plan_sp->GetRegisterKind();
629  if (active_row.get() && log) {
630  StreamString active_row_strm;
631  active_row->Dump(active_row_strm, m_fast_unwind_plan_sp.get(), &m_thread,
633  UnwindLogMsg("Using fast unwind plan '%s'",
634  m_fast_unwind_plan_sp->GetSourceName().AsCString());
635  UnwindLogMsg("active row: %s", active_row_strm.GetData());
636  }
637  } else {
640  active_row = m_full_unwind_plan_sp->GetRowForFunctionOffset(
642  row_register_kind = m_full_unwind_plan_sp->GetRegisterKind();
644  if (active_row.get() && log) {
645  StreamString active_row_strm;
646  active_row->Dump(active_row_strm, m_full_unwind_plan_sp.get(),
647  &m_thread,
649  UnwindLogMsg("Using full unwind plan '%s'",
650  m_full_unwind_plan_sp->GetSourceName().AsCString());
651  UnwindLogMsg("active row: %s", active_row_strm.GetData());
652  }
653  }
654  }
655 
656  if (!active_row.get()) {
658  UnwindLogMsg("could not find unwind row for this pc");
659  return;
660  }
661 
662  if (!ReadFrameAddress(row_register_kind, active_row->GetCFAValue(), m_cfa)) {
663  UnwindLogMsg("failed to get cfa");
665  return;
666  }
667 
668  ReadFrameAddress(row_register_kind, active_row->GetAFAValue(), m_afa);
669 
670  UnwindLogMsg("m_cfa = 0x%" PRIx64 " m_afa = 0x%" PRIx64, m_cfa, m_afa);
671 
672  if (CheckIfLoopingStack()) {
674  if (CheckIfLoopingStack()) {
675  UnwindLogMsg("same CFA address as next frame, assuming the unwind is "
676  "looping - stopping");
678  return;
679  }
680  }
681 
682  UnwindLogMsg("initialized frame current pc is 0x%" PRIx64
683  " cfa is 0x%" PRIx64 " afa is 0x%" PRIx64,
684  (uint64_t)m_current_pc.GetLoadAddress(exe_ctx.GetTargetPtr()),
685  (uint64_t)m_cfa,
686  (uint64_t)m_afa);
687 }
688 
690  // If we have a bad stack setup, we can get the same CFA value multiple times
691  // -- or even more devious, we can actually oscillate between two CFA values.
692  // Detect that here and break out to avoid a possible infinite loop in lldb
693  // trying to unwind the stack. To detect when we have the same CFA value
694  // multiple times, we compare the
695  // CFA of the current
696  // frame with the 2nd next frame because in some specail case (e.g. signal
697  // hanlders, hand written assembly without ABI compliance) we can have 2
698  // frames with the same
699  // CFA (in theory we
700  // can have arbitrary number of frames with the same CFA, but more then 2 is
701  // very very unlikely)
702 
704  if (next_frame) {
705  RegisterContextUnwind::SharedPtr next_next_frame =
706  next_frame->GetNextFrame();
707  addr_t next_next_frame_cfa = LLDB_INVALID_ADDRESS;
708  if (next_next_frame && next_next_frame->GetCFA(next_next_frame_cfa)) {
709  if (next_next_frame_cfa == m_cfa) {
710  // We have a loop in the stack unwind
711  return true;
712  }
713  }
714  }
715  return false;
716 }
717 
719 
721  if (m_frame_number == 0)
722  return true;
724  return true;
725  return false;
726 }
727 
728 // Find a fast unwind plan for this frame, if possible.
729 //
730 // On entry to this method,
731 //
732 // 1. m_frame_type should already be set to eTrapHandlerFrame/eDebuggerFrame
733 // if either of those are correct,
734 // 2. m_sym_ctx should already be filled in, and
735 // 3. m_current_pc should have the current pc value for this frame
736 // 4. m_current_offset_backed_up_one should have the current byte offset into
737 // the function, maybe backed up by 1, -1 if unknown
738 
740  UnwindPlanSP unwind_plan_sp;
741  ModuleSP pc_module_sp(m_current_pc.GetModule());
742 
743  if (!m_current_pc.IsValid() || !pc_module_sp ||
744  pc_module_sp->GetObjectFile() == nullptr)
745  return unwind_plan_sp;
746 
747  if (IsFrameZero())
748  return unwind_plan_sp;
749 
750  FuncUnwindersSP func_unwinders_sp(
751  pc_module_sp->GetUnwindTable().GetFuncUnwindersContainingAddress(
753  if (!func_unwinders_sp)
754  return unwind_plan_sp;
755 
756  // If we're in _sigtramp(), unwinding past this frame requires special
757  // knowledge.
759  return unwind_plan_sp;
760 
761  unwind_plan_sp = func_unwinders_sp->GetUnwindPlanFastUnwind(
763  if (unwind_plan_sp) {
764  if (unwind_plan_sp->PlanValidAtAddress(m_current_pc)) {
766  return unwind_plan_sp;
767  } else {
768  unwind_plan_sp.reset();
769  }
770  }
771  return unwind_plan_sp;
772 }
773 
774 // On entry to this method,
775 //
776 // 1. m_frame_type should already be set to eTrapHandlerFrame/eDebuggerFrame
777 // if either of those are correct,
778 // 2. m_sym_ctx should already be filled in, and
779 // 3. m_current_pc should have the current pc value for this frame
780 // 4. m_current_offset_backed_up_one should have the current byte offset into
781 // the function, maybe backed up by 1, -1 if unknown
782 
784  UnwindPlanSP unwind_plan_sp;
785  UnwindPlanSP arch_default_unwind_plan_sp;
786  ExecutionContext exe_ctx(m_thread.shared_from_this());
787  Process *process = exe_ctx.GetProcessPtr();
788  ABI *abi = process ? process->GetABI().get() : nullptr;
789  if (abi) {
790  arch_default_unwind_plan_sp =
791  std::make_shared<UnwindPlan>(lldb::eRegisterKindGeneric);
792  abi->CreateDefaultUnwindPlan(*arch_default_unwind_plan_sp);
793  } else {
794  UnwindLogMsg(
795  "unable to get architectural default UnwindPlan from ABI plugin");
796  }
797 
801  // If this frame behaves like a 0th frame (currently executing or
802  // interrupted asynchronously), all registers can be retrieved.
804  }
805 
806  // If we've done a jmp 0x0 / bl 0x0 (called through a null function pointer)
807  // so the pc is 0x0 in the zeroth frame, we need to use the "unwind at first
808  // instruction" arch default UnwindPlan Also, if this Process can report on
809  // memory region attributes, any non-executable region means we jumped
810  // through a bad function pointer - handle the same way as 0x0. Note, if we
811  // have a symbol context & a symbol, we don't want to follow this code path.
812  // This is for jumping to memory regions without any information available.
813 
814  if ((!m_sym_ctx_valid ||
815  (m_sym_ctx.function == nullptr && m_sym_ctx.symbol == nullptr)) &&
817  uint32_t permissions;
818  addr_t current_pc_addr =
820  if (current_pc_addr == 0 ||
821  (process &&
822  process->GetLoadAddressPermissions(current_pc_addr, permissions) &&
823  (permissions & ePermissionsExecutable) == 0)) {
824  if (abi) {
825  unwind_plan_sp =
826  std::make_shared<UnwindPlan>(lldb::eRegisterKindGeneric);
827  abi->CreateFunctionEntryUnwindPlan(*unwind_plan_sp);
829  return unwind_plan_sp;
830  }
831  }
832  }
833 
834  // No Module for the current pc, try using the architecture default unwind.
835  ModuleSP pc_module_sp(m_current_pc.GetModule());
836  if (!m_current_pc.IsValid() || !pc_module_sp ||
837  pc_module_sp->GetObjectFile() == nullptr) {
839  return arch_default_unwind_plan_sp;
840  }
841 
842  FuncUnwindersSP func_unwinders_sp;
843  if (m_sym_ctx_valid) {
844  func_unwinders_sp =
845  pc_module_sp->GetUnwindTable().GetFuncUnwindersContainingAddress(
847  }
848 
849  // No FuncUnwinders available for this pc (stripped function symbols, lldb
850  // could not augment its function table with another source, like
851  // LC_FUNCTION_STARTS or eh_frame in ObjectFileMachO). See if eh_frame or the
852  // .ARM.exidx tables have unwind information for this address, else fall back
853  // to the architectural default unwind.
854  if (!func_unwinders_sp) {
856 
857  if (!pc_module_sp || !pc_module_sp->GetObjectFile() ||
859  return arch_default_unwind_plan_sp;
860 
861  // Even with -fomit-frame-pointer, we can try eh_frame to get back on
862  // track.
863  DWARFCallFrameInfo *eh_frame =
864  pc_module_sp->GetUnwindTable().GetEHFrameInfo();
865  if (eh_frame) {
866  unwind_plan_sp = std::make_shared<UnwindPlan>(lldb::eRegisterKindGeneric);
867  if (eh_frame->GetUnwindPlan(m_current_pc, *unwind_plan_sp))
868  return unwind_plan_sp;
869  else
870  unwind_plan_sp.reset();
871  }
872 
873  ArmUnwindInfo *arm_exidx =
874  pc_module_sp->GetUnwindTable().GetArmUnwindInfo();
875  if (arm_exidx) {
876  unwind_plan_sp = std::make_shared<UnwindPlan>(lldb::eRegisterKindGeneric);
877  if (arm_exidx->GetUnwindPlan(exe_ctx.GetTargetRef(), m_current_pc,
878  *unwind_plan_sp))
879  return unwind_plan_sp;
880  else
881  unwind_plan_sp.reset();
882  }
883 
884  CallFrameInfo *object_file_unwind =
885  pc_module_sp->GetUnwindTable().GetObjectFileUnwindInfo();
886  if (object_file_unwind) {
887  unwind_plan_sp = std::make_shared<UnwindPlan>(lldb::eRegisterKindGeneric);
888  if (object_file_unwind->GetUnwindPlan(m_current_pc, *unwind_plan_sp))
889  return unwind_plan_sp;
890  else
891  unwind_plan_sp.reset();
892  }
893 
894  return arch_default_unwind_plan_sp;
895  }
896 
897  if (m_frame_type == eTrapHandlerFrame && process) {
898  m_fast_unwind_plan_sp.reset();
899 
900  // On some platforms the unwind information for signal handlers is not
901  // present or correct. Give the platform plugins a chance to provide
902  // substitute plan. Otherwise, use eh_frame.
903  if (m_sym_ctx_valid) {
904  lldb::PlatformSP platform = process->GetTarget().GetPlatform();
905  unwind_plan_sp = platform->GetTrapHandlerUnwindPlan(
906  process->GetTarget().GetArchitecture().GetTriple(),
908 
909  if (unwind_plan_sp)
910  return unwind_plan_sp;
911  }
912 
913  unwind_plan_sp =
914  func_unwinders_sp->GetEHFrameUnwindPlan(process->GetTarget());
915  if (!unwind_plan_sp)
916  unwind_plan_sp =
917  func_unwinders_sp->GetObjectFileUnwindPlan(process->GetTarget());
918  if (unwind_plan_sp && unwind_plan_sp->PlanValidAtAddress(m_current_pc) &&
919  unwind_plan_sp->GetSourcedFromCompiler() == eLazyBoolYes) {
920  return unwind_plan_sp;
921  }
922  }
923 
924  // Ask the DynamicLoader if the eh_frame CFI should be trusted in this frame
925  // even when it's frame zero This comes up if we have hand-written functions
926  // in a Module and hand-written eh_frame. The assembly instruction
927  // inspection may fail and the eh_frame CFI were probably written with some
928  // care to do the right thing. It'd be nice if there was a way to ask the
929  // eh_frame directly if it is asynchronous (can be trusted at every
930  // instruction point) or synchronous (the normal case - only at call sites).
931  // But there is not.
932  if (process && process->GetDynamicLoader() &&
934  // We must specifically call the GetEHFrameUnwindPlan() method here --
935  // normally we would call GetUnwindPlanAtCallSite() -- because CallSite may
936  // return an unwind plan sourced from either eh_frame (that's what we
937  // intend) or compact unwind (this won't work)
938  unwind_plan_sp =
939  func_unwinders_sp->GetEHFrameUnwindPlan(process->GetTarget());
940  if (!unwind_plan_sp)
941  unwind_plan_sp =
942  func_unwinders_sp->GetObjectFileUnwindPlan(process->GetTarget());
943  if (unwind_plan_sp && unwind_plan_sp->PlanValidAtAddress(m_current_pc)) {
944  UnwindLogMsgVerbose("frame uses %s for full UnwindPlan because the "
945  "DynamicLoader suggested we prefer it",
946  unwind_plan_sp->GetSourceName().GetCString());
947  return unwind_plan_sp;
948  }
949  }
950 
951  // Typically the NonCallSite UnwindPlan is the unwind created by inspecting
952  // the assembly language instructions
953  if (m_behaves_like_zeroth_frame && process) {
954  unwind_plan_sp = func_unwinders_sp->GetUnwindPlanAtNonCallSite(
955  process->GetTarget(), m_thread);
956  if (unwind_plan_sp && unwind_plan_sp->PlanValidAtAddress(m_current_pc)) {
957  if (unwind_plan_sp->GetSourcedFromCompiler() == eLazyBoolNo) {
958  // We probably have an UnwindPlan created by inspecting assembly
959  // instructions. The assembly profilers work really well with compiler-
960  // generated functions but hand- written assembly can be problematic.
961  // We set the eh_frame based unwind plan as our fallback unwind plan if
962  // instruction emulation doesn't work out even for non call sites if it
963  // is available and use the architecture default unwind plan if it is
964  // not available. The eh_frame unwind plan is more reliable even on non
965  // call sites then the architecture default plan and for hand written
966  // assembly code it is often written in a way that it valid at all
967  // location what helps in the most common cases when the instruction
968  // emulation fails.
969  UnwindPlanSP call_site_unwind_plan =
970  func_unwinders_sp->GetUnwindPlanAtCallSite(process->GetTarget(),
971  m_thread);
972  if (call_site_unwind_plan &&
973  call_site_unwind_plan.get() != unwind_plan_sp.get() &&
974  call_site_unwind_plan->GetSourceName() !=
975  unwind_plan_sp->GetSourceName()) {
976  m_fallback_unwind_plan_sp = call_site_unwind_plan;
977  } else {
978  m_fallback_unwind_plan_sp = arch_default_unwind_plan_sp;
979  }
980  }
981  UnwindLogMsgVerbose("frame uses %s for full UnwindPlan because this "
982  "is the non-call site unwind plan and this is a "
983  "zeroth frame",
984  unwind_plan_sp->GetSourceName().GetCString());
985  return unwind_plan_sp;
986  }
987 
988  // If we're on the first instruction of a function, and we have an
989  // architectural default UnwindPlan for the initial instruction of a
990  // function, use that.
991  if (m_current_offset == 0) {
992  unwind_plan_sp =
993  func_unwinders_sp->GetUnwindPlanArchitectureDefaultAtFunctionEntry(
994  m_thread);
995  if (unwind_plan_sp) {
996  UnwindLogMsgVerbose("frame uses %s for full UnwindPlan because we are at "
997  "the first instruction of a function",
998  unwind_plan_sp->GetSourceName().GetCString());
999  return unwind_plan_sp;
1000  }
1001  }
1002  }
1003 
1004  // Typically this is unwind info from an eh_frame section intended for
1005  // exception handling; only valid at call sites
1006  if (process) {
1007  unwind_plan_sp = func_unwinders_sp->GetUnwindPlanAtCallSite(
1008  process->GetTarget(), m_thread);
1009  }
1010  if (IsUnwindPlanValidForCurrentPC(unwind_plan_sp)) {
1011  UnwindLogMsgVerbose("frame uses %s for full UnwindPlan because this "
1012  "is the call-site unwind plan",
1013  unwind_plan_sp->GetSourceName().GetCString());
1014  return unwind_plan_sp;
1015  }
1016 
1017  // We'd prefer to use an UnwindPlan intended for call sites when we're at a
1018  // call site but if we've struck out on that, fall back to using the non-
1019  // call-site assembly inspection UnwindPlan if possible.
1020  if (process) {
1021  unwind_plan_sp = func_unwinders_sp->GetUnwindPlanAtNonCallSite(
1022  process->GetTarget(), m_thread);
1023  }
1024  if (unwind_plan_sp &&
1025  unwind_plan_sp->GetSourcedFromCompiler() == eLazyBoolNo) {
1026  // We probably have an UnwindPlan created by inspecting assembly
1027  // instructions. The assembly profilers work really well with compiler-
1028  // generated functions but hand- written assembly can be problematic. We
1029  // set the eh_frame based unwind plan as our fallback unwind plan if
1030  // instruction emulation doesn't work out even for non call sites if it is
1031  // available and use the architecture default unwind plan if it is not
1032  // available. The eh_frame unwind plan is more reliable even on non call
1033  // sites then the architecture default plan and for hand written assembly
1034  // code it is often written in a way that it valid at all location what
1035  // helps in the most common cases when the instruction emulation fails.
1036  UnwindPlanSP call_site_unwind_plan =
1037  func_unwinders_sp->GetUnwindPlanAtCallSite(process->GetTarget(),
1038  m_thread);
1039  if (call_site_unwind_plan &&
1040  call_site_unwind_plan.get() != unwind_plan_sp.get() &&
1041  call_site_unwind_plan->GetSourceName() !=
1042  unwind_plan_sp->GetSourceName()) {
1043  m_fallback_unwind_plan_sp = call_site_unwind_plan;
1044  } else {
1045  m_fallback_unwind_plan_sp = arch_default_unwind_plan_sp;
1046  }
1047  }
1048 
1049  if (IsUnwindPlanValidForCurrentPC(unwind_plan_sp)) {
1050  UnwindLogMsgVerbose("frame uses %s for full UnwindPlan because we "
1051  "failed to find a call-site unwind plan that would work",
1052  unwind_plan_sp->GetSourceName().GetCString());
1053  return unwind_plan_sp;
1054  }
1055 
1056  // If nothing else, use the architectural default UnwindPlan and hope that
1057  // does the job.
1058  if (arch_default_unwind_plan_sp)
1060  "frame uses %s for full UnwindPlan because we are falling back "
1061  "to the arch default plan",
1062  arch_default_unwind_plan_sp->GetSourceName().GetCString());
1063  else
1064  UnwindLogMsg(
1065  "Unable to find any UnwindPlan for full unwind of this frame.");
1066 
1067  return arch_default_unwind_plan_sp;
1068 }
1069 
1072 }
1073 
1075  return m_thread.GetRegisterContext()->GetRegisterCount();
1076 }
1077 
1078 const RegisterInfo *RegisterContextUnwind::GetRegisterInfoAtIndex(size_t reg) {
1079  return m_thread.GetRegisterContext()->GetRegisterInfoAtIndex(reg);
1080 }
1081 
1083  return m_thread.GetRegisterContext()->GetRegisterSetCount();
1084 }
1085 
1086 const RegisterSet *RegisterContextUnwind::GetRegisterSet(size_t reg_set) {
1087  return m_thread.GetRegisterContext()->GetRegisterSet(reg_set);
1088 }
1089 
1091  lldb::RegisterKind kind, uint32_t num) {
1092  return m_thread.GetRegisterContext()->ConvertRegisterKindToRegisterNumber(
1093  kind, num);
1094 }
1095 
1098  const RegisterInfo *reg_info, RegisterValue &value) {
1099  if (!IsValid())
1100  return false;
1101  bool success = false;
1102 
1103  switch (regloc.type) {
1105  const RegisterInfo *other_reg_info =
1107 
1108  if (!other_reg_info)
1109  return false;
1110 
1111  success =
1112  m_thread.GetRegisterContext()->ReadRegister(other_reg_info, value);
1113  } break;
1115  const RegisterInfo *other_reg_info =
1117 
1118  if (!other_reg_info)
1119  return false;
1120 
1121  if (IsFrameZero()) {
1122  success =
1123  m_thread.GetRegisterContext()->ReadRegister(other_reg_info, value);
1124  } else {
1125  success = GetNextFrame()->ReadRegister(other_reg_info, value);
1126  }
1127  } break;
1129  success =
1130  value.SetUInt(regloc.location.inferred_value, reg_info->byte_size);
1131  break;
1132 
1134  break;
1136  llvm_unreachable("FIXME debugger inferior function call unwind");
1139  reg_info, regloc.location.target_memory_location, reg_info->byte_size,
1140  value));
1141  success = error.Success();
1142  } break;
1143  default:
1144  llvm_unreachable("Unknown RegisterLocation type.");
1145  }
1146  return success;
1147 }
1148 
1151  const RegisterInfo *reg_info, const RegisterValue &value) {
1152  if (!IsValid())
1153  return false;
1154 
1155  bool success = false;
1156 
1157  switch (regloc.type) {
1159  const RegisterInfo *other_reg_info =
1161  success =
1162  m_thread.GetRegisterContext()->WriteRegister(other_reg_info, value);
1163  } break;
1165  const RegisterInfo *other_reg_info =
1167  if (IsFrameZero()) {
1168  success =
1169  m_thread.GetRegisterContext()->WriteRegister(other_reg_info, value);
1170  } else {
1171  success = GetNextFrame()->WriteRegister(other_reg_info, value);
1172  }
1173  } break;
1176  break;
1178  llvm_unreachable("FIXME debugger inferior function call unwind");
1181  reg_info, regloc.location.target_memory_location, reg_info->byte_size,
1182  value));
1183  success = error.Success();
1184  } break;
1185  default:
1186  llvm_unreachable("Unknown RegisterLocation type.");
1187  }
1188  return success;
1189 }
1190 
1192  return m_frame_type != eNotAValidFrame;
1193 }
1194 
1195 // After the final stack frame in a stack walk we'll get one invalid
1196 // (eNotAValidFrame) stack frame -- one past the end of the stack walk. But
1197 // higher-level code will need to tell the difference between "the unwind plan
1198 // below this frame failed" versus "we successfully completed the stack walk"
1199 // so this method helps to disambiguate that.
1200 
1202  return m_frame_type == eTrapHandlerFrame;
1203 }
1204 
1205 // A skip frame is a bogus frame on the stack -- but one where we're likely to
1206 // find a real frame farther
1207 // up the stack if we keep looking. It's always the second frame in an unwind
1208 // (i.e. the first frame after frame zero) where unwinding can be the
1209 // trickiest. Ideally we'll mark up this frame in some way so the user knows
1210 // we're displaying bad data and we may have skipped one frame of their real
1211 // program in the process of getting back on track.
1212 
1214  return m_frame_type == eSkipFrame;
1215 }
1216 
1218  lldb_private::Process *process,
1219  const lldb_private::SymbolContext &m_sym_ctx) const {
1220  PlatformSP platform_sp(process->GetTarget().GetPlatform());
1221  if (platform_sp) {
1222  const std::vector<ConstString> trap_handler_names(
1223  platform_sp->GetTrapHandlerSymbolNames());
1224  for (ConstString name : trap_handler_names) {
1225  if ((m_sym_ctx.function && m_sym_ctx.function->GetName() == name) ||
1226  (m_sym_ctx.symbol && m_sym_ctx.symbol->GetName() == name)) {
1227  return true;
1228  }
1229  }
1230  }
1231  const std::vector<ConstString> user_specified_trap_handler_names(
1233  for (ConstString name : user_specified_trap_handler_names) {
1234  if ((m_sym_ctx.function && m_sym_ctx.function->GetName() == name) ||
1235  (m_sym_ctx.symbol && m_sym_ctx.symbol->GetName() == name)) {
1236  return true;
1237  }
1238  }
1239 
1240  return false;
1241 }
1242 
1243 // Answer the question: Where did THIS frame save the CALLER frame ("previous"
1244 // frame)'s register value?
1245 
1249  RegisterNumber regnum(m_thread, eRegisterKindLLDB, lldb_regnum);
1250  Log *log = GetLog(LLDBLog::Unwind);
1251 
1252  // Have we already found this register location?
1253  if (!m_registers.empty()) {
1254  std::map<uint32_t,
1256  iterator;
1257  iterator = m_registers.find(regnum.GetAsKind(eRegisterKindLLDB));
1258  if (iterator != m_registers.end()) {
1259  regloc = iterator->second;
1260  UnwindLogMsg("supplying caller's saved %s (%d)'s location, cached",
1261  regnum.GetName(), regnum.GetAsKind(eRegisterKindLLDB));
1262  return UnwindLLDB::RegisterSearchResult::eRegisterFound;
1263  }
1264  }
1265 
1266  // Look through the available UnwindPlans for the register location.
1267 
1268  UnwindPlan::Row::RegisterLocation unwindplan_regloc;
1269  bool have_unwindplan_regloc = false;
1270  RegisterKind unwindplan_registerkind = kNumRegisterKinds;
1271 
1272  if (m_fast_unwind_plan_sp) {
1273  UnwindPlan::RowSP active_row =
1274  m_fast_unwind_plan_sp->GetRowForFunctionOffset(m_current_offset);
1275  unwindplan_registerkind = m_fast_unwind_plan_sp->GetRegisterKind();
1276  if (regnum.GetAsKind(unwindplan_registerkind) == LLDB_INVALID_REGNUM) {
1277  UnwindLogMsg("could not convert lldb regnum %s (%d) into %d RegisterKind "
1278  "reg numbering scheme",
1279  regnum.GetName(), regnum.GetAsKind(eRegisterKindLLDB),
1280  (int)unwindplan_registerkind);
1281  return UnwindLLDB::RegisterSearchResult::eRegisterNotFound;
1282  }
1283  // The architecture default unwind plan marks unknown registers as
1284  // Undefined so that we don't forward them up the stack when a
1285  // jitted stack frame may have overwritten them. But when the
1286  // arch default unwind plan is used as the Fast Unwind Plan, we
1287  // need to recognize this & switch over to the Full Unwind Plan
1288  // to see what unwind rule that (more knoweldgeable, probably)
1289  // UnwindPlan has. If the full UnwindPlan says the register
1290  // location is Undefined, then it really is.
1291  if (active_row->GetRegisterInfo(regnum.GetAsKind(unwindplan_registerkind),
1292  unwindplan_regloc) &&
1293  !unwindplan_regloc.IsUndefined()) {
1294  UnwindLogMsg(
1295  "supplying caller's saved %s (%d)'s location using FastUnwindPlan",
1296  regnum.GetName(), regnum.GetAsKind(eRegisterKindLLDB));
1297  have_unwindplan_regloc = true;
1298  }
1299  }
1300 
1301  if (!have_unwindplan_regloc) {
1302  // m_full_unwind_plan_sp being NULL means that we haven't tried to find a
1303  // full UnwindPlan yet
1304  bool got_new_full_unwindplan = false;
1305  if (!m_full_unwind_plan_sp) {
1307  got_new_full_unwindplan = true;
1308  }
1309 
1310  if (m_full_unwind_plan_sp) {
1313 
1314  UnwindPlan::RowSP active_row =
1315  m_full_unwind_plan_sp->GetRowForFunctionOffset(
1317  unwindplan_registerkind = m_full_unwind_plan_sp->GetRegisterKind();
1318 
1319  if (got_new_full_unwindplan && active_row.get() && log) {
1320  StreamString active_row_strm;
1321  ExecutionContext exe_ctx(m_thread.shared_from_this());
1322  active_row->Dump(active_row_strm, m_full_unwind_plan_sp.get(),
1323  &m_thread,
1325  UnwindLogMsg("Using full unwind plan '%s'",
1326  m_full_unwind_plan_sp->GetSourceName().AsCString());
1327  UnwindLogMsg("active row: %s", active_row_strm.GetData());
1328  }
1329  RegisterNumber return_address_reg;
1330 
1331  // If we're fetching the saved pc and this UnwindPlan defines a
1332  // ReturnAddress register (e.g. lr on arm), look for the return address
1333  // register number in the UnwindPlan's row.
1334  if (pc_regnum.IsValid() && pc_regnum == regnum &&
1335  m_full_unwind_plan_sp->GetReturnAddressRegister() !=
1337  // If this is a trap handler frame, we should have access to
1338  // the complete register context when the interrupt/async
1339  // signal was received, we should fetch the actual saved $pc
1340  // value instead of the Return Address register.
1341  // If $pc is not available, fall back to the RA reg.
1344  active_row->GetRegisterInfo
1345  (pc_regnum.GetAsKind (unwindplan_registerkind), scratch)) {
1346  UnwindLogMsg("Providing pc register instead of rewriting to "
1347  "RA reg because this is a trap handler and there is "
1348  "a location for the saved pc register value.");
1349  } else {
1350  return_address_reg.init(
1351  m_thread, m_full_unwind_plan_sp->GetRegisterKind(),
1352  m_full_unwind_plan_sp->GetReturnAddressRegister());
1353  regnum = return_address_reg;
1354  UnwindLogMsg("requested caller's saved PC but this UnwindPlan uses a "
1355  "RA reg; getting %s (%d) instead",
1356  return_address_reg.GetName(),
1357  return_address_reg.GetAsKind(eRegisterKindLLDB));
1358  }
1359  } else {
1360  if (regnum.GetAsKind(unwindplan_registerkind) == LLDB_INVALID_REGNUM) {
1361  if (unwindplan_registerkind == eRegisterKindGeneric) {
1362  UnwindLogMsg("could not convert lldb regnum %s (%d) into "
1363  "eRegisterKindGeneric reg numbering scheme",
1364  regnum.GetName(), regnum.GetAsKind(eRegisterKindLLDB));
1365  } else {
1366  UnwindLogMsg("could not convert lldb regnum %s (%d) into %d "
1367  "RegisterKind reg numbering scheme",
1368  regnum.GetName(), regnum.GetAsKind(eRegisterKindLLDB),
1369  (int)unwindplan_registerkind);
1370  }
1371  return UnwindLLDB::RegisterSearchResult::eRegisterNotFound;
1372  }
1373  }
1374 
1375  if (regnum.IsValid() &&
1376  active_row->GetRegisterInfo(regnum.GetAsKind(unwindplan_registerkind),
1377  unwindplan_regloc)) {
1378  have_unwindplan_regloc = true;
1379  UnwindLogMsg(
1380  "supplying caller's saved %s (%d)'s location using %s UnwindPlan",
1381  regnum.GetName(), regnum.GetAsKind(eRegisterKindLLDB),
1382  m_full_unwind_plan_sp->GetSourceName().GetCString());
1383  }
1384 
1385  // This is frame 0 and we're retrieving the PC and it's saved in a Return
1386  // Address register and it hasn't been saved anywhere yet -- that is,
1387  // it's still live in the actual register. Handle this specially.
1388 
1389  if (!have_unwindplan_regloc && return_address_reg.IsValid() &&
1390  IsFrameZero()) {
1391  if (return_address_reg.GetAsKind(eRegisterKindLLDB) !=
1394  new_regloc.type =
1396  new_regloc.location.register_number =
1397  return_address_reg.GetAsKind(eRegisterKindLLDB);
1398  m_registers[regnum.GetAsKind(eRegisterKindLLDB)] = new_regloc;
1399  regloc = new_regloc;
1400  UnwindLogMsg("supplying caller's register %s (%d) from the live "
1401  "RegisterContext at frame 0, saved in %d",
1402  return_address_reg.GetName(),
1403  return_address_reg.GetAsKind(eRegisterKindLLDB),
1404  return_address_reg.GetAsKind(eRegisterKindLLDB));
1405  return UnwindLLDB::RegisterSearchResult::eRegisterFound;
1406  }
1407  }
1408 
1409  // If this architecture stores the return address in a register (it
1410  // defines a Return Address register) and we're on a non-zero stack frame
1411  // and the Full UnwindPlan says that the pc is stored in the
1412  // RA registers (e.g. lr on arm), then we know that the full unwindplan is
1413  // not trustworthy -- this
1414  // is an impossible situation and the instruction emulation code has
1415  // likely been misled. If this stack frame meets those criteria, we need
1416  // to throw away the Full UnwindPlan that the instruction emulation came
1417  // up with and fall back to the architecture's Default UnwindPlan so the
1418  // stack walk can get past this point.
1419 
1420  // Special note: If the Full UnwindPlan was generated from the compiler,
1421  // don't second-guess it when we're at a call site location.
1422 
1423  // arch_default_ra_regnum is the return address register # in the Full
1424  // UnwindPlan register numbering
1425  RegisterNumber arch_default_ra_regnum(m_thread, eRegisterKindGeneric,
1427 
1428  if (arch_default_ra_regnum.GetAsKind(unwindplan_registerkind) !=
1430  pc_regnum == regnum && unwindplan_regloc.IsInOtherRegister() &&
1431  unwindplan_regloc.GetRegisterNumber() ==
1432  arch_default_ra_regnum.GetAsKind(unwindplan_registerkind) &&
1433  m_full_unwind_plan_sp->GetSourcedFromCompiler() != eLazyBoolYes &&
1435  UnwindLogMsg("%s UnwindPlan tried to restore the pc from the link "
1436  "register but this is a non-zero frame",
1437  m_full_unwind_plan_sp->GetSourceName().GetCString());
1438 
1439  // Throw away the full unwindplan; install the arch default unwindplan
1441  // Update for the possibly new unwind plan
1442  unwindplan_registerkind = m_full_unwind_plan_sp->GetRegisterKind();
1443  UnwindPlan::RowSP active_row =
1444  m_full_unwind_plan_sp->GetRowForFunctionOffset(m_current_offset);
1445 
1446  // Sanity check: Verify that we can fetch a pc value and CFA value
1447  // with this unwind plan
1448 
1449  RegisterNumber arch_default_pc_reg(m_thread, eRegisterKindGeneric,
1451  bool can_fetch_pc_value = false;
1452  bool can_fetch_cfa = false;
1453  addr_t cfa_value;
1454  if (active_row) {
1455  if (arch_default_pc_reg.GetAsKind(unwindplan_registerkind) !=
1457  active_row->GetRegisterInfo(
1458  arch_default_pc_reg.GetAsKind(unwindplan_registerkind),
1459  unwindplan_regloc)) {
1460  can_fetch_pc_value = true;
1461  }
1462  if (ReadFrameAddress(unwindplan_registerkind,
1463  active_row->GetCFAValue(), cfa_value)) {
1464  can_fetch_cfa = true;
1465  }
1466  }
1467 
1468  have_unwindplan_regloc = can_fetch_pc_value && can_fetch_cfa;
1469  } else {
1470  // We were unable to fall back to another unwind plan
1471  have_unwindplan_regloc = false;
1472  }
1473  }
1474  }
1475  }
1476 
1477  ExecutionContext exe_ctx(m_thread.shared_from_this());
1478  Process *process = exe_ctx.GetProcessPtr();
1479  if (!have_unwindplan_regloc) {
1480  // If the UnwindPlan failed to give us an unwind location for this
1481  // register, we may be able to fall back to some ABI-defined default. For
1482  // example, some ABIs allow to determine the caller's SP via the CFA. Also,
1483  // the ABI may set volatile registers to the undefined state.
1484  ABI *abi = process ? process->GetABI().get() : nullptr;
1485  if (abi) {
1486  const RegisterInfo *reg_info =
1488  if (reg_info &&
1489  abi->GetFallbackRegisterLocation(reg_info, unwindplan_regloc)) {
1490  UnwindLogMsg(
1491  "supplying caller's saved %s (%d)'s location using ABI default",
1492  regnum.GetName(), regnum.GetAsKind(eRegisterKindLLDB));
1493  have_unwindplan_regloc = true;
1494  }
1495  }
1496  }
1497 
1498  if (!have_unwindplan_regloc) {
1499  if (IsFrameZero()) {
1500  // This is frame 0 - we should return the actual live register context
1501  // value
1503  new_regloc.type =
1505  new_regloc.location.register_number = regnum.GetAsKind(eRegisterKindLLDB);
1506  m_registers[regnum.GetAsKind(eRegisterKindLLDB)] = new_regloc;
1507  regloc = new_regloc;
1508  UnwindLogMsg("supplying caller's register %s (%d) from the live "
1509  "RegisterContext at frame 0",
1510  regnum.GetName(), regnum.GetAsKind(eRegisterKindLLDB));
1511  return UnwindLLDB::RegisterSearchResult::eRegisterFound;
1512  } else {
1513  std::string unwindplan_name;
1514  if (m_full_unwind_plan_sp) {
1515  unwindplan_name += "via '";
1516  unwindplan_name += m_full_unwind_plan_sp->GetSourceName().AsCString();
1517  unwindplan_name += "'";
1518  }
1519  UnwindLogMsg("no save location for %s (%d) %s", regnum.GetName(),
1520  regnum.GetAsKind(eRegisterKindLLDB),
1521  unwindplan_name.c_str());
1522  }
1523  return UnwindLLDB::RegisterSearchResult::eRegisterNotFound;
1524  }
1525 
1526  // unwindplan_regloc has valid contents about where to retrieve the register
1527  if (unwindplan_regloc.IsUnspecified()) {
1530  m_registers[regnum.GetAsKind(eRegisterKindLLDB)] = new_regloc;
1531  UnwindLogMsg("save location for %s (%d) is unspecified, continue searching",
1532  regnum.GetName(), regnum.GetAsKind(eRegisterKindLLDB));
1533  return UnwindLLDB::RegisterSearchResult::eRegisterNotFound;
1534  }
1535 
1536  if (unwindplan_regloc.IsUndefined()) {
1537  UnwindLogMsg(
1538  "did not supply reg location for %s (%d) because it is volatile",
1539  regnum.GetName(), regnum.GetAsKind(eRegisterKindLLDB));
1540  return UnwindLLDB::RegisterSearchResult::eRegisterIsVolatile;
1541  }
1542 
1543  if (unwindplan_regloc.IsSame()) {
1544  if (!IsFrameZero() &&
1547  UnwindLogMsg("register %s (%d) is marked as 'IsSame' - it is a pc or "
1548  "return address reg on a non-zero frame -- treat as if we "
1549  "have no information",
1550  regnum.GetName(), regnum.GetAsKind(eRegisterKindLLDB));
1551  return UnwindLLDB::RegisterSearchResult::eRegisterNotFound;
1552  } else {
1555  m_registers[regnum.GetAsKind(eRegisterKindLLDB)] = regloc;
1556  UnwindLogMsg(
1557  "supplying caller's register %s (%d), saved in register %s (%d)",
1558  regnum.GetName(), regnum.GetAsKind(eRegisterKindLLDB),
1559  regnum.GetName(), regnum.GetAsKind(eRegisterKindLLDB));
1560  return UnwindLLDB::RegisterSearchResult::eRegisterFound;
1561  }
1562  }
1563 
1564  if (unwindplan_regloc.IsCFAPlusOffset()) {
1565  int offset = unwindplan_regloc.GetOffset();
1567  regloc.location.inferred_value = m_cfa + offset;
1568  m_registers[regnum.GetAsKind(eRegisterKindLLDB)] = regloc;
1569  UnwindLogMsg("supplying caller's register %s (%d), value is CFA plus "
1570  "offset %d [value is 0x%" PRIx64 "]",
1571  regnum.GetName(), regnum.GetAsKind(eRegisterKindLLDB), offset,
1572  regloc.location.inferred_value);
1573  return UnwindLLDB::RegisterSearchResult::eRegisterFound;
1574  }
1575 
1576  if (unwindplan_regloc.IsAtCFAPlusOffset()) {
1577  int offset = unwindplan_regloc.GetOffset();
1579  regloc.location.target_memory_location = m_cfa + offset;
1580  m_registers[regnum.GetAsKind(eRegisterKindLLDB)] = regloc;
1581  UnwindLogMsg("supplying caller's register %s (%d) from the stack, saved at "
1582  "CFA plus offset %d [saved at 0x%" PRIx64 "]",
1583  regnum.GetName(), regnum.GetAsKind(eRegisterKindLLDB), offset,
1585  return UnwindLLDB::RegisterSearchResult::eRegisterFound;
1586  }
1587 
1588  if (unwindplan_regloc.IsAFAPlusOffset()) {
1589  if (m_afa == LLDB_INVALID_ADDRESS)
1590  return UnwindLLDB::RegisterSearchResult::eRegisterNotFound;
1591 
1592  int offset = unwindplan_regloc.GetOffset();
1594  regloc.location.inferred_value = m_afa + offset;
1595  m_registers[regnum.GetAsKind(eRegisterKindLLDB)] = regloc;
1596  UnwindLogMsg("supplying caller's register %s (%d), value is AFA plus "
1597  "offset %d [value is 0x%" PRIx64 "]",
1598  regnum.GetName(), regnum.GetAsKind(eRegisterKindLLDB), offset,
1599  regloc.location.inferred_value);
1600  return UnwindLLDB::RegisterSearchResult::eRegisterFound;
1601  }
1602 
1603  if (unwindplan_regloc.IsAtAFAPlusOffset()) {
1604  if (m_afa == LLDB_INVALID_ADDRESS)
1605  return UnwindLLDB::RegisterSearchResult::eRegisterNotFound;
1606 
1607  int offset = unwindplan_regloc.GetOffset();
1609  regloc.location.target_memory_location = m_afa + offset;
1610  m_registers[regnum.GetAsKind(eRegisterKindLLDB)] = regloc;
1611  UnwindLogMsg("supplying caller's register %s (%d) from the stack, saved at "
1612  "AFA plus offset %d [saved at 0x%" PRIx64 "]",
1613  regnum.GetName(), regnum.GetAsKind(eRegisterKindLLDB), offset,
1615  return UnwindLLDB::RegisterSearchResult::eRegisterFound;
1616  }
1617 
1618  if (unwindplan_regloc.IsInOtherRegister()) {
1619  uint32_t unwindplan_regnum = unwindplan_regloc.GetRegisterNumber();
1620  RegisterNumber row_regnum(m_thread, unwindplan_registerkind,
1621  unwindplan_regnum);
1622  if (row_regnum.GetAsKind(eRegisterKindLLDB) == LLDB_INVALID_REGNUM) {
1623  UnwindLogMsg("could not supply caller's %s (%d) location - was saved in "
1624  "another reg but couldn't convert that regnum",
1625  regnum.GetName(), regnum.GetAsKind(eRegisterKindLLDB));
1626  return UnwindLLDB::RegisterSearchResult::eRegisterNotFound;
1627  }
1629  regloc.location.register_number = row_regnum.GetAsKind(eRegisterKindLLDB);
1630  m_registers[regnum.GetAsKind(eRegisterKindLLDB)] = regloc;
1631  UnwindLogMsg(
1632  "supplying caller's register %s (%d), saved in register %s (%d)",
1633  regnum.GetName(), regnum.GetAsKind(eRegisterKindLLDB),
1634  row_regnum.GetName(), row_regnum.GetAsKind(eRegisterKindLLDB));
1635  return UnwindLLDB::RegisterSearchResult::eRegisterFound;
1636  }
1637 
1638  if (unwindplan_regloc.IsDWARFExpression() ||
1639  unwindplan_regloc.IsAtDWARFExpression()) {
1640  DataExtractor dwarfdata(unwindplan_regloc.GetDWARFExpressionBytes(),
1641  unwindplan_regloc.GetDWARFExpressionLength(),
1642  process->GetByteOrder(),
1643  process->GetAddressByteSize());
1644  ModuleSP opcode_ctx;
1645  DWARFExpression dwarfexpr(opcode_ctx, dwarfdata, nullptr);
1646  dwarfexpr.SetRegisterKind(unwindplan_registerkind);
1647  Value cfa_val = Scalar(m_cfa);
1649  Value result;
1650  Status error;
1651  if (dwarfexpr.Evaluate(&exe_ctx, this, 0, &cfa_val, nullptr, result,
1652  &error)) {
1653  addr_t val;
1654  val = result.GetScalar().ULongLong();
1655  if (unwindplan_regloc.IsDWARFExpression()) {
1657  regloc.location.inferred_value = val;
1658  m_registers[regnum.GetAsKind(eRegisterKindLLDB)] = regloc;
1659  UnwindLogMsg("supplying caller's register %s (%d) via DWARF expression "
1660  "(IsDWARFExpression)",
1661  regnum.GetName(), regnum.GetAsKind(eRegisterKindLLDB));
1662  return UnwindLLDB::RegisterSearchResult::eRegisterFound;
1663  } else {
1664  regloc.type =
1666  regloc.location.target_memory_location = val;
1667  m_registers[regnum.GetAsKind(eRegisterKindLLDB)] = regloc;
1668  UnwindLogMsg("supplying caller's register %s (%d) via DWARF expression "
1669  "(IsAtDWARFExpression)",
1670  regnum.GetName(), regnum.GetAsKind(eRegisterKindLLDB));
1671  return UnwindLLDB::RegisterSearchResult::eRegisterFound;
1672  }
1673  }
1674  UnwindLogMsg("tried to use IsDWARFExpression or IsAtDWARFExpression for %s "
1675  "(%d) but failed",
1676  regnum.GetName(), regnum.GetAsKind(eRegisterKindLLDB));
1677  return UnwindLLDB::RegisterSearchResult::eRegisterNotFound;
1678  }
1679 
1680  UnwindLogMsg("no save location for %s (%d) in this stack frame",
1681  regnum.GetName(), regnum.GetAsKind(eRegisterKindLLDB));
1682 
1683  // FIXME UnwindPlan::Row types atDWARFExpression and isDWARFExpression are
1684  // unsupported.
1685 
1686  return UnwindLLDB::RegisterSearchResult::eRegisterNotFound;
1687 }
1688 
1689 // TryFallbackUnwindPlan() -- this method is a little tricky.
1690 //
1691 // When this is called, the frame above -- the caller frame, the "previous"
1692 // frame -- is invalid or bad.
1693 //
1694 // Instead of stopping the stack walk here, we'll try a different UnwindPlan
1695 // and see if we can get a valid frame above us.
1696 //
1697 // This most often happens when an unwind plan based on assembly instruction
1698 // inspection is not correct -- mostly with hand-written assembly functions or
1699 // functions where the stack frame is set up "out of band", e.g. the kernel
1700 // saved the register context and then called an asynchronous trap handler like
1701 // _sigtramp.
1702 //
1703 // Often in these cases, if we just do a dumb stack walk we'll get past this
1704 // tricky frame and our usual techniques can continue to be used.
1705 
1707  if (m_fallback_unwind_plan_sp.get() == nullptr)
1708  return false;
1709 
1710  if (m_full_unwind_plan_sp.get() == nullptr)
1711  return false;
1712 
1713  if (m_full_unwind_plan_sp.get() == m_fallback_unwind_plan_sp.get() ||
1714  m_full_unwind_plan_sp->GetSourceName() ==
1715  m_fallback_unwind_plan_sp->GetSourceName()) {
1716  return false;
1717  }
1718 
1719  // If a compiler generated unwind plan failed, trying the arch default
1720  // unwindplan isn't going to do any better.
1721  if (m_full_unwind_plan_sp->GetSourcedFromCompiler() == eLazyBoolYes)
1722  return false;
1723 
1724  // Get the caller's pc value and our own CFA value. Swap in the fallback
1725  // unwind plan, re-fetch the caller's pc value and CFA value. If they're the
1726  // same, then the fallback unwind plan provides no benefit.
1727 
1730 
1731  addr_t old_caller_pc_value = LLDB_INVALID_ADDRESS;
1732  addr_t new_caller_pc_value = LLDB_INVALID_ADDRESS;
1735  regloc) ==
1736  UnwindLLDB::RegisterSearchResult::eRegisterFound) {
1737  const RegisterInfo *reg_info =
1739  if (reg_info) {
1740  RegisterValue reg_value;
1741  if (ReadRegisterValueFromRegisterLocation(regloc, reg_info, reg_value)) {
1742  old_caller_pc_value = reg_value.GetAsUInt64();
1743  if (ProcessSP process_sp = m_thread.GetProcess()) {
1744  if (ABISP abi = process_sp->GetABI())
1745  old_caller_pc_value = abi->FixCodeAddress(old_caller_pc_value);
1746  }
1747  }
1748  }
1749  }
1750 
1751  // This is a tricky wrinkle! If SavedLocationForRegister() detects a really
1752  // impossible register location for the full unwind plan, it may call
1753  // ForceSwitchToFallbackUnwindPlan() which in turn replaces the full
1754  // unwindplan with the fallback... in short, we're done, we're using the
1755  // fallback UnwindPlan. We checked if m_fallback_unwind_plan_sp was nullptr
1756  // at the top -- the only way it became nullptr since then is via
1757  // SavedLocationForRegister().
1758  if (m_fallback_unwind_plan_sp.get() == nullptr)
1759  return true;
1760 
1761  // Switch the full UnwindPlan to be the fallback UnwindPlan. If we decide
1762  // this isn't working, we need to restore. We'll also need to save & restore
1763  // the value of the m_cfa ivar. Save is down below a bit in 'old_cfa'.
1764  UnwindPlanSP original_full_unwind_plan_sp = m_full_unwind_plan_sp;
1765  addr_t old_cfa = m_cfa;
1766  addr_t old_afa = m_afa;
1767 
1768  m_registers.clear();
1769 
1771 
1772  UnwindPlan::RowSP active_row =
1773  m_fallback_unwind_plan_sp->GetRowForFunctionOffset(
1775 
1776  if (active_row &&
1777  active_row->GetCFAValue().GetValueType() !=
1779  addr_t new_cfa;
1780  if (!ReadFrameAddress(m_fallback_unwind_plan_sp->GetRegisterKind(),
1781  active_row->GetCFAValue(), new_cfa) ||
1782  new_cfa == 0 || new_cfa == 1 || new_cfa == LLDB_INVALID_ADDRESS) {
1783  UnwindLogMsg("failed to get cfa with fallback unwindplan");
1784  m_fallback_unwind_plan_sp.reset();
1785  m_full_unwind_plan_sp = original_full_unwind_plan_sp;
1786  return false;
1787  }
1788  m_cfa = new_cfa;
1789 
1790  ReadFrameAddress(m_fallback_unwind_plan_sp->GetRegisterKind(),
1791  active_row->GetAFAValue(), m_afa);
1792 
1794  regloc) ==
1795  UnwindLLDB::RegisterSearchResult::eRegisterFound) {
1796  const RegisterInfo *reg_info =
1798  if (reg_info) {
1799  RegisterValue reg_value;
1800  if (ReadRegisterValueFromRegisterLocation(regloc, reg_info,
1801  reg_value)) {
1802  new_caller_pc_value = reg_value.GetAsUInt64();
1803  if (ProcessSP process_sp = m_thread.GetProcess()) {
1804  if (ABISP abi = process_sp->GetABI())
1805  new_caller_pc_value = abi->FixCodeAddress(new_caller_pc_value);
1806  }
1807  }
1808  }
1809  }
1810 
1811  if (new_caller_pc_value == LLDB_INVALID_ADDRESS) {
1812  UnwindLogMsg("failed to get a pc value for the caller frame with the "
1813  "fallback unwind plan");
1814  m_fallback_unwind_plan_sp.reset();
1815  m_full_unwind_plan_sp = original_full_unwind_plan_sp;
1816  m_cfa = old_cfa;
1817  m_afa = old_afa;
1818  return false;
1819  }
1820 
1821  if (old_caller_pc_value == new_caller_pc_value &&
1822  m_cfa == old_cfa &&
1823  m_afa == old_afa) {
1824  UnwindLogMsg("fallback unwind plan got the same values for this frame "
1825  "CFA and caller frame pc, not using");
1826  m_fallback_unwind_plan_sp.reset();
1827  m_full_unwind_plan_sp = original_full_unwind_plan_sp;
1828  return false;
1829  }
1830 
1831  UnwindLogMsg("trying to unwind from this function with the UnwindPlan '%s' "
1832  "because UnwindPlan '%s' failed.",
1833  m_fallback_unwind_plan_sp->GetSourceName().GetCString(),
1834  original_full_unwind_plan_sp->GetSourceName().GetCString());
1835 
1836  // We've copied the fallback unwind plan into the full - now clear the
1837  // fallback.
1838  m_fallback_unwind_plan_sp.reset();
1840  }
1841 
1842  return true;
1843 }
1844 
1846  if (m_fallback_unwind_plan_sp.get() == nullptr)
1847  return false;
1848 
1849  if (m_full_unwind_plan_sp.get() == nullptr)
1850  return false;
1851 
1852  if (m_full_unwind_plan_sp.get() == m_fallback_unwind_plan_sp.get() ||
1853  m_full_unwind_plan_sp->GetSourceName() ==
1854  m_fallback_unwind_plan_sp->GetSourceName()) {
1855  return false;
1856  }
1857 
1858  UnwindPlan::RowSP active_row =
1859  m_fallback_unwind_plan_sp->GetRowForFunctionOffset(m_current_offset);
1860 
1861  if (active_row &&
1862  active_row->GetCFAValue().GetValueType() !=
1864  addr_t new_cfa;
1865  if (!ReadFrameAddress(m_fallback_unwind_plan_sp->GetRegisterKind(),
1866  active_row->GetCFAValue(), new_cfa) ||
1867  new_cfa == 0 || new_cfa == 1 || new_cfa == LLDB_INVALID_ADDRESS) {
1868  UnwindLogMsg("failed to get cfa with fallback unwindplan");
1869  m_fallback_unwind_plan_sp.reset();
1870  return false;
1871  }
1872 
1873  ReadFrameAddress(m_fallback_unwind_plan_sp->GetRegisterKind(),
1874  active_row->GetAFAValue(), m_afa);
1875 
1877  m_fallback_unwind_plan_sp.reset();
1878 
1879  m_registers.clear();
1880 
1881  m_cfa = new_cfa;
1882 
1884 
1885  UnwindLogMsg("switched unconditionally to the fallback unwindplan %s",
1886  m_full_unwind_plan_sp->GetSourceName().GetCString());
1887  return true;
1888  }
1889  return false;
1890 }
1891 
1893  lldb::UnwindPlanSP unwind_plan) {
1894  if (unwind_plan->GetUnwindPlanForSignalTrap() != eLazyBoolYes) {
1895  // Unwind plan does not indicate trap handler. Do nothing. We may
1896  // already be flagged as trap handler flag due to the symbol being
1897  // in the trap handler symbol list, and that should take precedence.
1898  return;
1899  } else if (m_frame_type != eNormalFrame) {
1900  // If this is already a trap handler frame, nothing to do.
1901  // If this is a skip or debug or invalid frame, don't override that.
1902  return;
1903  }
1904 
1906 
1908  // We backed up the pc by 1 to compute the symbol context, but
1909  // now need to undo that because the pc of the trap handler
1910  // frame may in fact be the first instruction of a signal return
1911  // trampoline, rather than the instruction after a call. This
1912  // happens on systems where the signal handler dispatch code, rather
1913  // than calling the handler and being returned to, jumps to the
1914  // handler after pushing the address of a return trampoline on the
1915  // stack -- on these systems, when the handler returns, control will
1916  // be transferred to the return trampoline, so that's the best
1917  // symbol we can present in the callstack.
1918  UnwindLogMsg("Resetting current offset and re-doing symbol lookup; "
1919  "old symbol was %s",
1920  GetSymbolOrFunctionName(m_sym_ctx).AsCString(""));
1922 
1923  AddressRange addr_range;
1925 
1926  UnwindLogMsg("Symbol is now %s",
1927  GetSymbolOrFunctionName(m_sym_ctx).AsCString(""));
1928 
1929  ExecutionContext exe_ctx(m_thread.shared_from_this());
1930  Process *process = exe_ctx.GetProcessPtr();
1931  Target *target = &process->GetTarget();
1932 
1933  m_start_pc = addr_range.GetBaseAddress();
1936  }
1937 }
1938 
1940  lldb::RegisterKind row_register_kind, UnwindPlan::Row::FAValue &fa,
1941  addr_t &address) {
1942  RegisterValue reg_value;
1943 
1944  address = LLDB_INVALID_ADDRESS;
1945  addr_t cfa_reg_contents;
1946 
1947  switch (fa.GetValueType()) {
1949  RegisterNumber cfa_reg(m_thread, row_register_kind,
1950  fa.GetRegisterNumber());
1951  if (ReadGPRValue(cfa_reg, cfa_reg_contents)) {
1952  const RegisterInfo *reg_info =
1954  RegisterValue reg_value;
1955  if (reg_info) {
1957  reg_info, cfa_reg_contents, reg_info->byte_size, reg_value);
1958  if (error.Success()) {
1959  address = reg_value.GetAsUInt64();
1960  if (ABISP abi_sp = m_thread.GetProcess()->GetABI())
1961  address = abi_sp->FixCodeAddress(address);
1962  UnwindLogMsg(
1963  "CFA value via dereferencing reg %s (%d): reg has val 0x%" PRIx64
1964  ", CFA value is 0x%" PRIx64,
1965  cfa_reg.GetName(), cfa_reg.GetAsKind(eRegisterKindLLDB),
1966  cfa_reg_contents, address);
1967  return true;
1968  } else {
1969  UnwindLogMsg("Tried to deref reg %s (%d) [0x%" PRIx64
1970  "] but memory read failed.",
1971  cfa_reg.GetName(), cfa_reg.GetAsKind(eRegisterKindLLDB),
1972  cfa_reg_contents);
1973  }
1974  }
1975  }
1976  break;
1977  }
1979  RegisterNumber cfa_reg(m_thread, row_register_kind,
1980  fa.GetRegisterNumber());
1981  if (ReadGPRValue(cfa_reg, cfa_reg_contents)) {
1982  if (cfa_reg_contents == LLDB_INVALID_ADDRESS || cfa_reg_contents == 0 ||
1983  cfa_reg_contents == 1) {
1984  UnwindLogMsg(
1985  "Got an invalid CFA register value - reg %s (%d), value 0x%" PRIx64,
1986  cfa_reg.GetName(), cfa_reg.GetAsKind(eRegisterKindLLDB),
1987  cfa_reg_contents);
1988  cfa_reg_contents = LLDB_INVALID_ADDRESS;
1989  return false;
1990  }
1991  address = cfa_reg_contents + fa.GetOffset();
1992  UnwindLogMsg(
1993  "CFA is 0x%" PRIx64 ": Register %s (%d) contents are 0x%" PRIx64
1994  ", offset is %d",
1995  address, cfa_reg.GetName(), cfa_reg.GetAsKind(eRegisterKindLLDB),
1996  cfa_reg_contents, fa.GetOffset());
1997  return true;
1998  }
1999  break;
2000  }
2002  ExecutionContext exe_ctx(m_thread.shared_from_this());
2003  Process *process = exe_ctx.GetProcessPtr();
2004  DataExtractor dwarfdata(fa.GetDWARFExpressionBytes(),
2006  process->GetByteOrder(),
2007  process->GetAddressByteSize());
2008  ModuleSP opcode_ctx;
2009  DWARFExpression dwarfexpr(opcode_ctx, dwarfdata, nullptr);
2010  dwarfexpr.SetRegisterKind(row_register_kind);
2011  Value result;
2012  Status error;
2013  if (dwarfexpr.Evaluate(&exe_ctx, this, 0, nullptr, nullptr, result,
2014  &error)) {
2015  address = result.GetScalar().ULongLong();
2016  if (ABISP abi_sp = m_thread.GetProcess()->GetABI())
2017  address = abi_sp->FixCodeAddress(address);
2018 
2019  UnwindLogMsg("CFA value set by DWARF expression is 0x%" PRIx64,
2020  address);
2021  return true;
2022  }
2023  UnwindLogMsg("Failed to set CFA value via DWARF expression: %s",
2024  error.AsCString());
2025  break;
2026  }
2028  Process &process = *m_thread.GetProcess();
2029  lldb::addr_t return_address_hint = GetReturnAddressHint(fa.GetOffset());
2030  if (return_address_hint == LLDB_INVALID_ADDRESS)
2031  return false;
2032  const unsigned max_iterations = 256;
2033  for (unsigned i = 0; i < max_iterations; ++i) {
2034  Status st;
2035  lldb::addr_t candidate_addr =
2036  return_address_hint + i * process.GetAddressByteSize();
2037  lldb::addr_t candidate =
2038  process.ReadPointerFromMemory(candidate_addr, st);
2039  if (st.Fail()) {
2040  UnwindLogMsg("Cannot read memory at 0x%" PRIx64 ": %s", candidate_addr,
2041  st.AsCString());
2042  return false;
2043  }
2044  Address addr;
2045  uint32_t permissions;
2046  if (process.GetLoadAddressPermissions(candidate, permissions) &&
2047  permissions & lldb::ePermissionsExecutable) {
2048  address = candidate_addr;
2049  UnwindLogMsg("Heuristically found CFA: 0x%" PRIx64, address);
2050  return true;
2051  }
2052  }
2053  UnwindLogMsg("No suitable CFA found");
2054  break;
2055  }
2056  default:
2057  return false;
2058  }
2059  return false;
2060 }
2061 
2063  addr_t hint;
2065  return LLDB_INVALID_ADDRESS;
2067  return LLDB_INVALID_ADDRESS;
2068 
2069  hint += plan_offset;
2070 
2071  if (auto next = GetNextFrame()) {
2072  if (!next->m_sym_ctx.module_sp || !next->m_sym_ctx.symbol)
2073  return LLDB_INVALID_ADDRESS;
2074  if (auto expected_size =
2075  next->m_sym_ctx.module_sp->GetSymbolFile()->GetParameterStackSize(
2076  *next->m_sym_ctx.symbol))
2077  hint += *expected_size;
2078  else {
2079  UnwindLogMsgVerbose("Could not retrieve parameter size: %s",
2080  llvm::toString(expected_size.takeError()).c_str());
2081  return LLDB_INVALID_ADDRESS;
2082  }
2083  }
2084  return hint;
2085 }
2086 
2087 // Retrieve a general purpose register value for THIS frame, as saved by the
2088 // NEXT frame, i.e. the frame that
2089 // this frame called. e.g.
2090 //
2091 // foo () { }
2092 // bar () { foo (); }
2093 // main () { bar (); }
2094 //
2095 // stopped in foo() so
2096 // frame 0 - foo
2097 // frame 1 - bar
2098 // frame 2 - main
2099 // and this RegisterContext is for frame 1 (bar) - if we want to get the pc
2100 // value for frame 1, we need to ask
2101 // where frame 0 (the "next" frame) saved that and retrieve the value.
2102 
2104  uint32_t regnum, addr_t &value) {
2105  if (!IsValid())
2106  return false;
2107 
2108  uint32_t lldb_regnum;
2109  if (register_kind == eRegisterKindLLDB) {
2110  lldb_regnum = regnum;
2111  } else if (!m_thread.GetRegisterContext()->ConvertBetweenRegisterKinds(
2112  register_kind, regnum, eRegisterKindLLDB, lldb_regnum)) {
2113  return false;
2114  }
2115 
2116  const RegisterInfo *reg_info = GetRegisterInfoAtIndex(lldb_regnum);
2117  RegisterValue reg_value;
2118  // if this is frame 0 (currently executing frame), get the requested reg
2119  // contents from the actual thread registers
2120  if (IsFrameZero()) {
2121  if (m_thread.GetRegisterContext()->ReadRegister(reg_info, reg_value)) {
2122  value = reg_value.GetAsUInt64();
2123  return true;
2124  }
2125  return false;
2126  }
2127 
2128  bool pc_register = false;
2129  uint32_t generic_regnum;
2130  if (register_kind == eRegisterKindGeneric &&
2131  (regnum == LLDB_REGNUM_GENERIC_PC || regnum == LLDB_REGNUM_GENERIC_RA)) {
2132  pc_register = true;
2133  } else if (m_thread.GetRegisterContext()->ConvertBetweenRegisterKinds(
2134  register_kind, regnum, eRegisterKindGeneric, generic_regnum) &&
2135  (generic_regnum == LLDB_REGNUM_GENERIC_PC ||
2136  generic_regnum == LLDB_REGNUM_GENERIC_RA)) {
2137  pc_register = true;
2138  }
2139 
2142  lldb_regnum, regloc, m_frame_number - 1, pc_register)) {
2143  return false;
2144  }
2145  if (ReadRegisterValueFromRegisterLocation(regloc, reg_info, reg_value)) {
2146  value = reg_value.GetAsUInt64();
2147  if (pc_register) {
2148  if (ProcessSP process_sp = m_thread.GetProcess()) {
2149  if (ABISP abi = process_sp->GetABI())
2150  value = abi->FixCodeAddress(value);
2151  }
2152  }
2153  return true;
2154  }
2155  return false;
2156 }
2157 
2159  addr_t &value) {
2160  return ReadGPRValue(regnum.GetRegisterKind(), regnum.GetRegisterNumber(),
2161  value);
2162 }
2163 
2164 // Find the value of a register in THIS frame
2165 
2166 bool RegisterContextUnwind::ReadRegister(const RegisterInfo *reg_info,
2167  RegisterValue &value) {
2168  if (!IsValid())
2169  return false;
2170 
2171  const uint32_t lldb_regnum = reg_info->kinds[eRegisterKindLLDB];
2172  UnwindLogMsgVerbose("looking for register saved location for reg %d",
2173  lldb_regnum);
2174 
2175  // If this is the 0th frame, hand this over to the live register context
2176  if (IsFrameZero()) {
2177  UnwindLogMsgVerbose("passing along to the live register context for reg %d",
2178  lldb_regnum);
2179  return m_thread.GetRegisterContext()->ReadRegister(reg_info, value);
2180  }
2181 
2182  bool is_pc_regnum = false;
2183  if (reg_info->kinds[eRegisterKindGeneric] == LLDB_REGNUM_GENERIC_PC ||
2184  reg_info->kinds[eRegisterKindGeneric] == LLDB_REGNUM_GENERIC_RA) {
2185  is_pc_regnum = true;
2186  }
2187 
2189  // Find out where the NEXT frame saved THIS frame's register contents
2191  lldb_regnum, regloc, m_frame_number - 1, is_pc_regnum))
2192  return false;
2193 
2194  bool result = ReadRegisterValueFromRegisterLocation(regloc, reg_info, value);
2195  if (result) {
2196  if (is_pc_regnum && value.GetType() == RegisterValue::eTypeUInt64) {
2197  addr_t reg_value = value.GetAsUInt64(LLDB_INVALID_ADDRESS);
2198  if (reg_value != LLDB_INVALID_ADDRESS) {
2199  if(ProcessSP process_sp = m_thread.GetProcess()) {
2200  if (ABISP abi = process_sp->GetABI())
2201  value = abi->FixCodeAddress(reg_value);
2202  }
2203  }
2204  }
2205  }
2206  return result;
2207 }
2208 
2209 bool RegisterContextUnwind::WriteRegister(const RegisterInfo *reg_info,
2210  const RegisterValue &value) {
2211  if (!IsValid())
2212  return false;
2213 
2214  const uint32_t lldb_regnum = reg_info->kinds[eRegisterKindLLDB];
2215  UnwindLogMsgVerbose("looking for register saved location for reg %d",
2216  lldb_regnum);
2217 
2218  // If this is the 0th frame, hand this over to the live register context
2219  if (IsFrameZero()) {
2220  UnwindLogMsgVerbose("passing along to the live register context for reg %d",
2221  lldb_regnum);
2222  return m_thread.GetRegisterContext()->WriteRegister(reg_info, value);
2223  }
2224 
2226  // Find out where the NEXT frame saved THIS frame's register contents
2228  lldb_regnum, regloc, m_frame_number - 1, false))
2229  return false;
2230 
2231  return WriteRegisterValueToRegisterLocation(regloc, reg_info, value);
2232 }
2233 
2234 // Don't need to implement this one
2236  lldb::WritableDataBufferSP &data_sp) {
2237  return false;
2238 }
2239 
2240 // Don't need to implement this one
2242  const lldb::DataBufferSP &data_sp) {
2243  return false;
2244 }
2245 
2246 // Retrieve the pc value for THIS from
2247 
2249  if (!IsValid()) {
2250  return false;
2251  }
2252  if (m_cfa == LLDB_INVALID_ADDRESS) {
2253  return false;
2254  }
2255  cfa = m_cfa;
2256  return true;
2257 }
2258 
2261  if (m_frame_number == 0)
2262  return regctx;
2264 }
2265 
2269 }
2270 
2271 // Retrieve the address of the start of the function of THIS frame
2272 
2274  if (!IsValid())
2275  return false;
2276 
2277  if (!m_start_pc.IsValid()) {
2278  bool read_successfully = ReadPC (start_pc);
2279  if (read_successfully)
2280  {
2281  ProcessSP process_sp (m_thread.GetProcess());
2282  if (process_sp)
2283  {
2284  ABI *abi = process_sp->GetABI().get();
2285  if (abi)
2286  start_pc = abi->FixCodeAddress(start_pc);
2287  }
2288  }
2289  return read_successfully;
2290  }
2291  start_pc = m_start_pc.GetLoadAddress(CalculateTarget().get());
2292  return true;
2293 }
2294 
2295 // Retrieve the current pc value for THIS frame, as saved by the NEXT frame.
2296 
2298  if (!IsValid())
2299  return false;
2300 
2301  bool above_trap_handler = false;
2302  if (GetNextFrame().get() && GetNextFrame()->IsValid() &&
2304  above_trap_handler = true;
2305 
2307  // A pc value of 0 or 1 is impossible in the middle of the stack -- it
2308  // indicates the end of a stack walk.
2309  // On the currently executing frame (or such a frame interrupted
2310  // asynchronously by sigtramp et al) this may occur if code has jumped
2311  // through a NULL pointer -- we want to be able to unwind past that frame
2312  // to help find the bug.
2313 
2314  ProcessSP process_sp (m_thread.GetProcess());
2315  if (process_sp)
2316  {
2317  ABI *abi = process_sp->GetABI().get();
2318  if (abi)
2319  pc = abi->FixCodeAddress(pc);
2320  }
2321 
2322  return !(m_all_registers_available == false &&
2323  above_trap_handler == false && (pc == 0 || pc == 1));
2324  } else {
2325  return false;
2326  }
2327 }
2328 
2329 void RegisterContextUnwind::UnwindLogMsg(const char *fmt, ...) {
2330  Log *log = GetLog(LLDBLog::Unwind);
2331  if (!log)
2332  return;
2333 
2334  va_list args;
2335  va_start(args, fmt);
2336 
2337  llvm::SmallString<0> logmsg;
2338  if (VASprintf(logmsg, fmt, args)) {
2339  LLDB_LOGF(log, "%*sth%d/fr%u %s",
2340  m_frame_number < 100 ? m_frame_number : 100, "",
2341  m_thread.GetIndexID(), m_frame_number, logmsg.c_str());
2342  }
2343  va_end(args);
2344 }
2345 
2347  Log *log = GetLog(LLDBLog::Unwind);
2348  if (!log || !log->GetVerbose())
2349  return;
2350 
2351  va_list args;
2352  va_start(args, fmt);
2353 
2354  llvm::SmallString<0> logmsg;
2355  if (VASprintf(logmsg, fmt, args)) {
2356  LLDB_LOGF(log, "%*sth%d/fr%u %s",
2357  m_frame_number < 100 ? m_frame_number : 100, "",
2358  m_thread.GetIndexID(), m_frame_number, logmsg.c_str());
2359  }
2360  va_end(args);
2361 }
lldb_private::toString
const char * toString(AppleArm64ExceptionClass EC)
Definition: AppleArm64ExceptionClass.h:38
lldb_private::UnwindLLDB::GetUserSpecifiedTrapHandlerFunctionNames
const std::vector< ConstString > & GetUserSpecifiedTrapHandlerFunctionNames()
Provide the list of user-specified trap handler functions.
Definition: UnwindLLDB.h:106
lldb_private::RegisterContextUnwind::ReadPC
bool ReadPC(lldb::addr_t &start_pc)
Definition: RegisterContextUnwind.cpp:2297
lldb_private::UnwindPlan::Row::RegisterLocation::GetOffset
int32_t GetOffset() const
Definition: UnwindPlan.h:141
lldb_private::RegisterContextUnwind::eSkipFrame
@ eSkipFrame
Definition: RegisterContextUnwind.h:81
lldb_private::Address::SetLoadAddress
bool SetLoadAddress(lldb::addr_t load_addr, Target *target, bool allow_section_end=false)
Set the address to represent load_addr.
Definition: Address.cpp:1040
lldb_private::AddressRange::GetBaseAddress
Address & GetBaseAddress()
Get accessor for the base address of the range.
Definition: AddressRange.h:209
lldb_private::ExecutionContext
Definition: ExecutionContext.h:292
lldb_private::RegisterValue::eTypeUInt64
@ eTypeUInt64
Definition: RegisterValue.h:38
lldb_private::RegisterContextUnwind::eTrapHandlerFrame
@ eTrapHandlerFrame
Definition: RegisterContextUnwind.h:78
lldb_private::RegisterContextUnwind::GetRegisterCount
size_t GetRegisterCount() override
Definition: RegisterContextUnwind.cpp:1074
lldb_private::UnwindPlan::Row::RegisterLocation::GetRegisterNumber
uint32_t GetRegisterNumber() const
Definition: UnwindPlan.h:133
lldb_private::UnwindLLDB::RegisterLocation::type
int type
Definition: UnwindLLDB.h:56
lldb_private::Log::GetVerbose
bool GetVerbose() const
Definition: Log.cpp:300
LLDB_INVALID_REGNUM
#define LLDB_INVALID_REGNUM
Definition: lldb-defines.h:79
lldb_private::UnwindPlan::Row::FAValue::GetOffset
int32_t GetOffset() const
Definition: UnwindPlan.h:258
lldb_private::Address::IsValid
bool IsValid() const
Check if the object state is valid.
Definition: Address.h:345
lldb_private::ABI
Definition: ABI.h:27
lldb_private::Thread::GetIndexID
uint32_t GetIndexID() const
Definition: Thread.cpp:1381
lldb_private::RegisterValue
Definition: RegisterValue.h:28
lldb_private::RegisterContext::WriteRegisterValueToMemory
virtual Status WriteRegisterValueToMemory(const lldb_private::RegisterInfo *reg_info, lldb::addr_t dst_addr, uint32_t dst_len, const RegisterValue &reg_value)
Definition: RegisterContext.cpp:368
lldb_private::Value
Definition: Value.h:38
lldb_private::UnwindLLDB::RegisterLocation::inferred_value
uint64_t inferred_value
Definition: UnwindLLDB.h:62
lldb_private::Value::SetValueType
void SetValueType(ValueType value_type)
Definition: Value.h:89
lldb_private::ExecutionContext::GetProcessPtr
Process * GetProcessPtr() const
Returns a pointer to the process object.
Definition: ExecutionContext.cpp:206
lldb::eRegisterKindGeneric
@ eRegisterKindGeneric
insn ptr reg, stack ptr reg, etc not specific to any particular target
Definition: lldb-enumerations.h:230
lldb_private::RegisterContextUnwind::IsUnwindPlanValidForCurrentPC
void void bool IsUnwindPlanValidForCurrentPC(lldb::UnwindPlanSP unwind_plan_sp)
Definition: RegisterContextUnwind.cpp:84
lldb_private::RegisterContextUnwind::TryFallbackUnwindPlan
bool TryFallbackUnwindPlan()
If the unwind has to the caller frame has failed, try something else.
Definition: RegisterContextUnwind.cpp:1706
lldb_private::RegisterContextUnwind::UnwindLogMsg
void UnwindLogMsg(const char *fmt,...) __attribute__((format(printf
Definition: RegisterContextUnwind.cpp:2329
lldb_private::UnwindPlan::Row::FAValue::isRaSearch
@ isRaSearch
Definition: UnwindPlan.h:205
lldb_private::RegisterContextUnwind::SharedPtr
std::shared_ptr< RegisterContextUnwind > SharedPtr
Definition: RegisterContextUnwind.h:27
lldb_private::eLazyBoolYes
@ eLazyBoolYes
Definition: lldb-private-enumerations.h:115
lldb_private::Scalar
Definition: Scalar.h:34
LLDB_LOGF
#define LLDB_LOGF(log,...)
Definition: Log.h:343
lldb_private::RegisterContextUnwind::InitializeNonZerothFrame
void InitializeNonZerothFrame()
Definition: RegisterContextUnwind.cpp:303
lldb_private::Process
Definition: Process.h:338
lldb_private::RegisterContextUnwind::ReadRegisterValueFromRegisterLocation
bool ReadRegisterValueFromRegisterLocation(lldb_private::UnwindLLDB::RegisterLocation regloc, const lldb_private::RegisterInfo *reg_info, lldb_private::RegisterValue &value)
Definition: RegisterContextUnwind.cpp:1096
lldb_private::RegisterContextUnwind::m_sym_ctx_valid
bool m_sym_ctx_valid
Definition: RegisterContextUnwind.h:247
lldb_private::Thread::CalculateTarget
lldb::TargetSP CalculateTarget() override
Definition: Thread.cpp:1383
lldb_private::UnwindPlan::Row::RegisterLocation::IsAtAFAPlusOffset
bool IsAtAFAPlusOffset() const
Definition: UnwindPlan.h:100
Module.h
lldb_private::Process::GetTarget
Target & GetTarget()
Get the target object pointer for this module.
Definition: Process.h:1206
lldb_private::ArmUnwindInfo
Definition: ArmUnwindInfo.h:30
lldb_private::ArmUnwindInfo::GetUnwindPlan
bool GetUnwindPlan(Target &target, const Address &addr, UnwindPlan &unwind_plan)
Definition: ArmUnwindInfo.cpp:99
lldb_private::UnwindLLDB::RegisterLocation::location
union lldb_private::UnwindLLDB::RegisterLocation::@39 location
lldb_private::UnwindPlan::Row::RegisterLocation::IsAtDWARFExpression
bool IsAtDWARFExpression() const
Definition: UnwindPlan.h:104
lldb_private::ABI::GetFallbackRegisterLocation
virtual bool GetFallbackRegisterLocation(const RegisterInfo *reg_info, UnwindPlan::Row::RegisterLocation &unwind_regloc)
Definition: ABI.cpp:178
SectionLoadList.h
lldb::kNumRegisterKinds
@ kNumRegisterKinds
Definition: lldb-enumerations.h:235
lldb_private::Value::ValueType::LoadAddress
@ LoadAddress
A load address value.
RegisterValue.h
StackFrame.h
lldb_private::UnwindLLDB::RegisterLocation::register_number
uint32_t register_number
Definition: UnwindLLDB.h:60
RegisterNumber::GetRegisterNumber
uint32_t GetRegisterNumber() const
Definition: RegisterNumber.cpp:101
lldb_private::RegisterContextUnwind::GetRegisterSet
const lldb_private::RegisterSet * GetRegisterSet(size_t reg_set) override
Definition: RegisterContextUnwind.cpp:1086
lldb_private::ArchSpec::GetTriple
llvm::Triple & GetTriple()
Architecture triple accessor.
Definition: ArchSpec.h:455
lldb::addr_t
uint64_t addr_t
Definition: lldb-types.h:83
pc
@ pc
Definition: CompactUnwindInfo.cpp:1251
lldb_private::RegisterContextUnwind::m_all_registers_available
bool m_all_registers_available
Definition: RegisterContextUnwind.h:222
lldb_private::CallFrameInfo::GetUnwindPlan
virtual bool GetUnwindPlan(const Address &addr, UnwindPlan &unwind_plan)=0
lldb_private::SymbolContext
Definition: SymbolContext.h:33
lldb_private::Target
Definition: Target.h:473
lldb_private::RegisterContextUnwind::InitializeZerothFrame
void InitializeZerothFrame()
Definition: RegisterContextUnwind.cpp:112
lldb_private::RegisterContextUnwind::GetFullUnwindPlanForFrame
lldb::UnwindPlanSP GetFullUnwindPlanForFrame()
Definition: RegisterContextUnwind.cpp:783
lldb_private::RegisterContextUnwind::CheckIfLoopingStack
bool CheckIfLoopingStack()
Definition: RegisterContextUnwind.cpp:689
lldb_private::UnwindLLDB::RegisterLocation::eRegisterSavedAtHostMemoryLocation
@ eRegisterSavedAtHostMemoryLocation
Definition: UnwindLLDB.h:49
ABI.h
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::RegisterContextUnwind::ForceSwitchToFallbackUnwindPlan
bool ForceSwitchToFallbackUnwindPlan()
Switch to the fallback unwind plan unconditionally without any safety checks that it is providing bet...
Definition: RegisterContextUnwind.cpp:1845
lldb_private::RegisterContextUnwind::GetCFA
bool GetCFA(lldb::addr_t &cfa)
Definition: RegisterContextUnwind.cpp:2248
RegisterNumber::init
void init(lldb_private::Thread &thread, lldb::RegisterKind kind, uint32_t num)
Definition: RegisterNumber.cpp:31
Target.h
lldb_private::Value::GetScalar
const Scalar & GetScalar() const
Definition: Value.h:112
lldb_private::Target::GetPlatform
lldb::PlatformSP GetPlatform()
Definition: Target.h:1398
lldb_private::Thread::GetProcess
lldb::ProcessSP GetProcess() const
Definition: Thread.h:153
lldb_private::UnwindPlan::Row::RegisterLocation::IsCFAPlusOffset
bool IsCFAPlusOffset() const
Definition: UnwindPlan.h:94
Platform.h
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
lldb_private::LanguageRuntime::GetRuntimeUnwindPlan
static lldb::UnwindPlanSP GetRuntimeUnwindPlan(lldb_private::Thread &thread, lldb_private::RegisterContext *regctx, bool &behaves_like_zeroth_frame)
A language runtime may be able to provide a special UnwindPlan for the frame represented by the regis...
Definition: LanguageRuntime.cpp:262
lldb_private::DWARFExpression::SetRegisterKind
void SetRegisterKind(lldb::RegisterKind reg_kind)
Set the call-frame-info style register kind.
Definition: DWARFExpression.cpp:104
lldb_private::UnwindPlan::Row::FAValue::GetRegisterNumber
uint32_t GetRegisterNumber() const
Definition: UnwindPlan.h:250
RegisterNumber
A class to represent register numbers, and able to convert between different register numbering schem...
Definition: RegisterNumber.h:19
lldb_private::LLDBLog::Unwind
@ Unwind
lldb_private::RegisterContextUnwind::m_frame_type
int m_frame_type
Definition: RegisterContextUnwind.h:224
lldb_private::UnwindPlan::Row::FAValue::GetValueType
ValueType GetValueType() const
Definition: UnwindPlan.h:256
lldb::eRegisterKindLLDB
@ eRegisterKindLLDB
lldb's internal register numbers
Definition: lldb-enumerations.h:234
lldb_private::Function::GetName
ConstString GetName() const
Definition: Function.cpp:654
lldb_private::DataExtractor
Definition: DataExtractor.h:48
VASPrintf.h
lldb_private::UnwindPlan::Row::FAValue::GetDWARFExpressionBytes
const uint8_t * GetDWARFExpressionBytes()
Definition: UnwindPlan.h:289
lldb_private::Scalar::ULongLong
unsigned long long ULongLong(unsigned long long fail_value=0) const
Definition: Scalar.cpp:334
lldb_private::UnwindLLDB::RegisterSearchResult
RegisterSearchResult
Definition: UnwindLLDB.h:32
Log.h
lldb_private::UnwindPlan::Row::FAValue::isRegisterDereferenced
@ isRegisterDereferenced
Definition: UnwindPlan.h:203
lldb_private::UnwindPlan::Row::FAValue::isDWARFExpression
@ isDWARFExpression
Definition: UnwindPlan.h:204
lldb_private::RegisterContextUnwind::m_frame_number
uint32_t m_frame_number
Definition: RegisterContextUnwind.h:250
lldb_private::Thread
Definition: Thread.h:61
lldb_private::ABI::CreateFunctionEntryUnwindPlan
virtual bool CreateFunctionEntryUnwindPlan(UnwindPlan &unwind_plan)=0
lldb_private::RegisterContextUnwind::GetReturnAddressHint
lldb::addr_t GetReturnAddressHint(int32_t plan_offset)
Definition: RegisterContextUnwind.cpp:2062
lldb_private::Status::Fail
bool Fail() const
Test for error condition.
Definition: Status.cpp:181
lldb_private::RegisterContextUnwind::IsTrapHandlerSymbol
bool IsTrapHandlerSymbol(lldb_private::Process *process, const lldb_private::SymbolContext &m_sym_ctx) const
Determines if a SymbolContext is a trap handler or not.
Definition: RegisterContextUnwind.cpp:1217
lldb_private::RegisterContextUnwind::IsValid
bool IsValid() const
Definition: RegisterContextUnwind.cpp:1191
lldb_private::StreamString::GetData
const char * GetData() const
Definition: StreamString.h:43
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::UnwindLLDB
Definition: UnwindLLDB.h:26
ArmUnwindInfo.h
lldb_private::DWARFExpression
Definition: DWARFExpression.h:36
lldb_private::UnwindPlan::Row::FAValue
Definition: UnwindPlan.h:198
lldb_private::Process::GetAddressByteSize
uint32_t GetAddressByteSize() const
Definition: Process.cpp:3345
lldb_private::UnwindLLDB::RegisterLocation
Definition: UnwindLLDB.h:41
lldb_private::ConstString
Definition: ConstString.h:40
DWARFCallFrameInfo.h
lldb_private::StreamString
Definition: StreamString.h:23
lldb_private::AddressRange
Definition: AddressRange.h:25
lldb_private::DWARFCallFrameInfo::GetUnwindPlan
bool GetUnwindPlan(const Address &addr, UnwindPlan &unwind_plan)
Return an UnwindPlan based on the call frame information encoded in the FDE of this DWARFCallFrameInf...
Definition: DWARFCallFrameInfo.cpp:153
lldb_private::RegisterContextUnwind::ConvertRegisterKindToRegisterNumber
uint32_t ConvertRegisterKindToRegisterNumber(lldb::RegisterKind kind, uint32_t num) override
Convert from a given register numbering scheme to the lldb register numbering scheme.
Definition: RegisterContextUnwind.cpp:1090
RegisterNumber::GetAsKind
uint32_t GetAsKind(lldb::RegisterKind kind)
Definition: RegisterNumber.cpp:80
lldb_private::UnwindPlan::Row::RegisterLocation::IsAtCFAPlusOffset
bool IsAtCFAPlusOffset() const
Definition: UnwindPlan.h:96
lldb_private::RegisterContextUnwind::IsTrapHandlerFrame
bool IsTrapHandlerFrame() const
Definition: RegisterContextUnwind.cpp:1201
RegisterContextUnwind.h
lldb_private::CallFrameInfo
Definition: CallFrameInfo.h:16
lldb_private::UnwindPlan::Row::FAValue::GetDWARFExpressionLength
int GetDWARFExpressionLength()
Definition: UnwindPlan.h:295
lldb_private::UnwindLLDB::RegisterLocation::eRegisterNotSaved
@ eRegisterNotSaved
Definition: UnwindLLDB.h:43
lldb_private::Process::GetDynamicLoader
virtual DynamicLoader * GetDynamicLoader()
Get the dynamic loader plug-in for this process.
Definition: Process.cpp:2649
string
string(SUBSTRING ${p} 10 -1 pStripped) if($
Definition: Plugins/CMakeLists.txt:40
lldb_private::RegisterContextUnwind::m_parent_unwind
lldb_private::UnwindLLDB & m_parent_unwind
Definition: RegisterContextUnwind.h:255
lldb_private::Address::GetSection
lldb::SectionSP GetSection() const
Get const accessor for the section.
Definition: Address.h:429
lldb_private::UnwindLLDB::SearchForSavedLocationForRegister
bool SearchForSavedLocationForRegister(uint32_t lldb_regnum, lldb_private::UnwindLLDB::RegisterLocation &regloc, uint32_t starting_frame_num, bool pc_register)
Definition: UnwindLLDB.cpp:471
lldb_private::RegisterContextUnwind::GetStartPC
bool GetStartPC(lldb::addr_t &start_pc)
Definition: RegisterContextUnwind.cpp:2273
lldb_private::RegisterContextUnwind::m_current_offset_backed_up_one
int m_current_offset_backed_up_one
Definition: RegisterContextUnwind.h:241
Thread.h
lldb_private::VASprintf
bool VASprintf(llvm::SmallVectorImpl< char > &buf, const char *fmt, va_list args)
Definition: VASprintf.cpp:19
GetSymbolOrFunctionName
static ConstString GetSymbolOrFunctionName(const SymbolContext &sym_ctx)
Definition: RegisterContextUnwind.cpp:45
lldb_private::UnwindLLDB::RegisterLocation::eRegisterInRegister
@ eRegisterInRegister
Definition: UnwindLLDB.h:47
lldb_private::RegisterContext::ReadRegisterValueFromMemory
virtual Status ReadRegisterValueFromMemory(const lldb_private::RegisterInfo *reg_info, lldb::addr_t src_addr, uint32_t src_len, RegisterValue &reg_value)
Definition: RegisterContext.cpp:298
Address.h
lldb_private::RegisterContextUnwind::IsFrameZero
bool IsFrameZero() const
Definition: RegisterContextUnwind.cpp:718
lldb_private::RegisterContext
Definition: RegisterContext.h:17
lldb_private::RegisterContextUnwind::GetPrevFrame
SharedPtr GetPrevFrame() const
Definition: RegisterContextUnwind.cpp:2266
lldb_private::RegisterContextUnwind::GetNextFrame
SharedPtr GetNextFrame() const
Definition: RegisterContextUnwind.cpp:2259
lldb_private::UnwindPlan::Row::RegisterLocation::IsUnspecified
bool IsUnspecified() const
Definition: UnwindPlan.h:90
ObjectFile.h
RegisterNumber::GetName
const char * GetName()
Definition: RegisterNumber.cpp:105
lldb_private::UnwindPlan::Row::RegisterLocation::IsAFAPlusOffset
bool IsAFAPlusOffset() const
Definition: UnwindPlan.h:98
lldb::RegisterKind
RegisterKind
Register numbering types.
Definition: lldb-enumerations.h:227
lldb-private.h
lldb_private::UnwindPlan::Row::RegisterLocation
Definition: UnwindPlan.h:57
lldb_private::UnwindPlan::Row::FAValue::isRegisterPlusOffset
@ isRegisterPlusOffset
Definition: UnwindPlan.h:202
lldb_private::RegisterContextUnwind::m_thread
lldb_private::Thread & m_thread
Definition: RegisterContextUnwind.h:210
lldb_private::UnwindPlan::RowSP
std::shared_ptr< Row > RowSP
Definition: UnwindPlan.h:395
Symbol.h
lldb_private::Symbol::GetName
ConstString GetName() const
Definition: Symbol.cpp:501
lldb_private::RegisterContextUnwind::PropagateTrapHandlerFlagFromUnwindPlan
void PropagateTrapHandlerFlagFromUnwindPlan(lldb::UnwindPlanSP unwind_plan)
Check if the given unwind plan indicates a signal trap handler, and update frame type and symbol cont...
Definition: RegisterContextUnwind.cpp:1892
FuncUnwinders.h
lldb_private::Address::ResolveFunctionScope
bool ResolveFunctionScope(lldb_private::SymbolContext &sym_ctx, lldb_private::AddressRange *addr_range_ptr=nullptr)
Resolve this address to its containing function and optionally get that function's address range.
Definition: Address.cpp:266
lldb_private::RegisterContextUnwind::InvalidateAllRegisters
void InvalidateAllRegisters() override
Definition: RegisterContextUnwind.cpp:1070
lldb_private::Target::GetArchitecture
const ArchSpec & GetArchitecture() const
Definition: Target.h:989
lldb_private::Status
Definition: Status.h:44
lldb_private::RegisterValue::GetType
RegisterValue::Type GetType() const
Definition: RegisterValue.h:81
lldb_private::RegisterContextUnwind::IsSkipFrame
bool IsSkipFrame() const
Definition: RegisterContextUnwind.cpp:1213
uint32_t
lldb_private::eLazyBoolNo
@ eLazyBoolNo
Definition: lldb-private-enumerations.h:115
lldb_private::UnwindPlan::Row::RegisterLocation::IsInOtherRegister
bool IsInOtherRegister() const
Definition: UnwindPlan.h:102
lldb_private::RegisterValue::SetUInt
bool SetUInt(uint64_t uint, uint32_t byte_size)
Definition: RegisterValue.cpp:734
lldb_private::UnwindLLDB::RegisterLocation::eRegisterValueInferred
@ eRegisterValueInferred
Definition: UnwindLLDB.h:51
lldb_private::Address
Definition: Address.h:59
lldb_private::RegisterContextUnwind::m_afa
lldb::addr_t m_afa
Definition: RegisterContextUnwind.h:227
LLDB_REGNUM_GENERIC_SP
#define LLDB_REGNUM_GENERIC_SP
Definition: lldb-defines.h:52
lldb_private::RegisterContextUnwind::GetRegisterSetCount
size_t GetRegisterSetCount() override
Definition: RegisterContextUnwind.cpp:1082
lldb_private::RegisterContextUnwind::m_fast_unwind_plan_sp
lldb::UnwindPlanSP m_fast_unwind_plan_sp
Definition: RegisterContextUnwind.h:218
lldb_private::RegisterContextUnwind::eDebuggerFrame
@ eDebuggerFrame
Definition: RegisterContextUnwind.h:79
lldb_private::ABI::FixCodeAddress
virtual lldb::addr_t FixCodeAddress(lldb::addr_t pc)
Some targets might use bits in a code address to indicate a mode switch.
Definition: ABI.h:125
lldb_private::RegisterContextUnwind::m_sym_ctx
lldb_private::SymbolContext & m_sym_ctx
Definition: RegisterContextUnwind.h:246
CallFrameInfo.h
lldb_private::Address::GetLoadAddress
lldb::addr_t GetLoadAddress(Target *target) const
Get the load address.
Definition: Address.cpp:311
lldb_private::RegisterContextUnwind::GetFastUnwindPlanForFrame
lldb::UnwindPlanSP GetFastUnwindPlanForFrame()
Definition: RegisterContextUnwind.cpp:739
lldb_private::RegisterContextUnwind::ReadGPRValue
bool ReadGPRValue(lldb::RegisterKind register_kind, uint32_t regnum, lldb::addr_t &value)
Definition: RegisterContextUnwind.cpp:2103
lldb_private::RegisterContextUnwind::BehavesLikeZerothFrame
bool BehavesLikeZerothFrame() const override
Indicates that this frame is currently executing code, that the PC value is not a return-pc but an ac...
Definition: RegisterContextUnwind.cpp:720
lldb_private::RegisterContextUnwind::m_behaves_like_zeroth_frame
bool m_behaves_like_zeroth_frame
Definition: RegisterContextUnwind.h:244
lldb_private::UnwindLLDB::GetRegisterContextForFrameNum
RegisterContextLLDBSP GetRegisterContextForFrameNum(uint32_t frame_num)
Definition: UnwindLLDB.cpp:464
lldb_private::SymbolContext::module_sp
lldb::ModuleSP module_sp
The Module for a given query.
Definition: SymbolContext.h:318
lldb_private::RegisterContextUnwind::m_cfa
lldb::addr_t m_cfa
Definition: RegisterContextUnwind.h:226
lldb_private::Address::SetOffset
bool SetOffset(lldb::addr_t offset)
Set accessor for the offset.
Definition: Address.h:438
LLDB_INVALID_ADDRESS
#define LLDB_INVALID_ADDRESS
Definition: lldb-defines.h:74
lldb_private::DWARFCallFrameInfo
Definition: DWARFCallFrameInfo.h:33
lldb_private::RegisterContextUnwind::WriteRegisterValueToRegisterLocation
bool WriteRegisterValueToRegisterLocation(lldb_private::UnwindLLDB::RegisterLocation regloc, const lldb_private::RegisterInfo *reg_info, const lldb_private::RegisterValue &value)
Definition: RegisterContextUnwind.cpp:1149
Function.h
DWARFExpression.h
LanguageRuntime.h
lldb_private::ExecutionContext::GetTargetRef
Target & GetTargetRef() const
Returns a reference to the target object.
Definition: ExecutionContext.cpp:224
lldb_private::RegisterContextUnwind::WriteRegister
bool WriteRegister(const lldb_private::RegisterInfo *reg_info, const lldb_private::RegisterValue &value) override
Definition: RegisterContextUnwind.cpp:2209
RegisterNumber::IsValid
bool IsValid() const
Definition: RegisterNumber.cpp:75
SymbolContext.h
lldb_private::RegisterContext::CalculateTarget
lldb::TargetSP CalculateTarget() override
Definition: RegisterContext.cpp:427
lldb_private::SymbolContext::Clear
void Clear(bool clear_target)
Clear the object's state.
Definition: SymbolContext.cpp:56
lldb_private
A class that represents a running process on the host machine.
Definition: SBCommandInterpreterRunOptions.h:16
lldb_private::UnwindPlan::Row::RegisterLocation::IsUndefined
bool IsUndefined() const
Definition: UnwindPlan.h:92
lldb_private::RegisterContextUnwind::eNotAValidFrame
@ eNotAValidFrame
Definition: RegisterContextUnwind.h:83
lldb_private::UnwindLLDB::RegisterLocation::eRegisterInLiveRegisterContext
@ eRegisterInLiveRegisterContext
Definition: UnwindLLDB.h:53
LLDB_REGNUM_GENERIC_FP
#define LLDB_REGNUM_GENERIC_FP
Definition: lldb-defines.h:53
lldb_private::UnwindLLDB::RegisterLocation::target_memory_location
lldb::addr_t target_memory_location
Definition: UnwindLLDB.h:58
lldb_private::RegisterContextUnwind::UnwindLogMsgVerbose
void void UnwindLogMsgVerbose(const char *fmt,...) __attribute__((format(printf
Definition: RegisterContextUnwind.cpp:2346
lldb_private::UnwindLLDB::RegisterLocation::eRegisterSavedAtMemoryLocation
@ eRegisterSavedAtMemoryLocation
Definition: UnwindLLDB.h:45
lldb_private::RegisterContextUnwind::m_start_pc
lldb_private::Address m_start_pc
Definition: RegisterContextUnwind.h:228
lldb_private::DynamicLoader::AlwaysRelyOnEHUnwindInfo
virtual bool AlwaysRelyOnEHUnwindInfo(SymbolContext &sym_ctx)
Ask if the eh_frame information for the given SymbolContext should be relied on even when it's the fi...
Definition: DynamicLoader.h:182
lldb_private::UnwindPlan::Row::FAValue::unspecified
@ unspecified
Definition: UnwindPlan.h:201
lldb_private::RegisterContextUnwind::m_current_offset
int m_current_offset
Definition: RegisterContextUnwind.h:231
lldb_private::ABI::CreateDefaultUnwindPlan
virtual bool CreateDefaultUnwindPlan(UnwindPlan &unwind_plan)=0
LLDB_REGNUM_GENERIC_PC
#define LLDB_REGNUM_GENERIC_PC
Definition: lldb-defines.h:51
lldb_private::Process::GetABI
const lldb::ABISP & GetABI()
Definition: Process.cpp:1482
lldb_private::Address::GetOffset
lldb::addr_t GetOffset() const
Get the section relative offset value.
Definition: Address.h:319
RegisterNumber::GetRegisterKind
lldb::RegisterKind GetRegisterKind() const
Definition: RegisterNumber.cpp:103
lldb_private::Address::GetModule
lldb::ModuleSP GetModule() const
Get accessor for the module for this address.
Definition: Address.cpp:283
lldb_private::Process::GetByteOrder
lldb::ByteOrder GetByteOrder() const
Definition: Process.cpp:3341
lldb_private::Log
Definition: Log.h:115
lldb_private::RegisterContextUnwind::SavedLocationForRegister
lldb_private::UnwindLLDB::RegisterSearchResult SavedLocationForRegister(uint32_t lldb_regnum, lldb_private::UnwindLLDB::RegisterLocation &regloc)
Definition: RegisterContextUnwind.cpp:1247
lldb_private::RegisterContextUnwind::ReadAllRegisterValues
bool ReadAllRegisterValues(lldb::WritableDataBufferSP &data_sp) override
Definition: RegisterContextUnwind.cpp:2235
lldb_private::RegisterContextUnwind::m_current_pc
lldb_private::Address m_current_pc
Definition: RegisterContextUnwind.h:229
lldb_private::DWARFExpression::Evaluate
bool Evaluate(ExecutionContextScope *exe_scope, lldb::addr_t func_load_addr, const Value *initial_value_ptr, const Value *object_address_ptr, Value &result, Status *error_ptr) const
Wrapper for the static evaluate function that accepts an ExecutionContextScope instead of an Executio...
Definition: DWARFExpression.cpp:842
lldb_private::Process::ReadPointerFromMemory
lldb::addr_t ReadPointerFromMemory(lldb::addr_t vm_addr, Status &error)
Definition: Process.cpp:2084
lldb_private::RegisterContextUnwind::ReadRegister
bool ReadRegister(const lldb_private::RegisterInfo *reg_info, lldb_private::RegisterValue &value) override
Definition: RegisterContextUnwind.cpp:2166
lldb_private::RegisterContextUnwind::GetRegisterInfoAtIndex
const lldb_private::RegisterInfo * GetRegisterInfoAtIndex(size_t reg) override
Definition: RegisterContextUnwind.cpp:1078
lldb_private::RegisterContextUnwind::m_fallback_unwind_plan_sp
lldb::UnwindPlanSP m_fallback_unwind_plan_sp
Definition: RegisterContextUnwind.h:220
lldb_private::Thread::GetRegisterContext
virtual lldb::RegisterContextSP GetRegisterContext()=0
lldb_private::GetLog
Log * GetLog(Cat mask)
Retrieve the Log object for the channel associated with the given log enum.
Definition: Log.h:308
lldb_private::RegisterContextUnwind::m_full_unwind_plan_sp
lldb::UnwindPlanSP m_full_unwind_plan_sp
Definition: RegisterContextUnwind.h:219
lldb_private::UnwindPlan::Row::RegisterLocation::IsSame
bool IsSame() const
Definition: UnwindPlan.h:88
lldb_private::RegisterContextUnwind::ReadFrameAddress
bool ReadFrameAddress(lldb::RegisterKind register_kind, UnwindPlan::Row::FAValue &fa, lldb::addr_t &address)
Definition: RegisterContextUnwind.cpp:1939
DynamicLoader.h
AddressRange.h
lldb
Definition: SBAddress.h:15
Value.h
lldb_private::UnwindPlan::Row::RegisterLocation::GetDWARFExpressionLength
int GetDWARFExpressionLength()
Definition: UnwindPlan.h:174
lldb_private::RegisterContextUnwind::WriteAllRegisterValues
bool WriteAllRegisterValues(const lldb::DataBufferSP &data_sp) override
Definition: RegisterContextUnwind.cpp:2241
lldb_private::UnwindPlan::Row::RegisterLocation::IsDWARFExpression
bool IsDWARFExpression() const
Definition: UnwindPlan.h:106
arm64_dwarf::x1
@ x1
Definition: ARM64_DWARF_Registers.h:18
LLDBLog.h
SymbolFile.h
lldb_private::ExecutionContext::GetTargetPtr
Target * GetTargetPtr() const
Returns a pointer to the target object.
Definition: ExecutionContext.cpp:198
ExecutionContext.h
lldb_private::UnwindPlan::Row::RegisterLocation::GetDWARFExpressionBytes
const uint8_t * GetDWARFExpressionBytes()
Definition: UnwindPlan.h:168
DataBufferHeap.h
lldb_private::Process::GetLoadAddressPermissions
virtual bool GetLoadAddressPermissions(lldb::addr_t load_addr, uint32_t &permissions)
Attempt to get the attributes for a region of memory in the process.
Definition: Process.cpp:2373
lldb_private::RegisterContextUnwind::m_registers
std::map< uint32_t, lldb_private::UnwindLLDB::RegisterLocation > m_registers
Definition: RegisterContextUnwind.h:253
lldb_private::Status::AsCString
const char * AsCString(const char *default_error_str="unknown error") const
Get the error string associated with the current error.
Definition: Status.cpp:130
lldb_private::RegisterContextUnwind::eNormalFrame
@ eNormalFrame
Definition: RegisterContextUnwind.h:77
LLDB_REGNUM_GENERIC_RA
#define LLDB_REGNUM_GENERIC_RA
Definition: lldb-defines.h:54