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