LLDB  mainline
DWARFCallFrameInfo.cpp
Go to the documentation of this file.
1 //===-- DWARFCallFrameInfo.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/Module.h"
11 #include "lldb/Core/Section.h"
12 #include "lldb/Core/dwarf.h"
13 #include "lldb/Host/Host.h"
14 #include "lldb/Symbol/ObjectFile.h"
15 #include "lldb/Symbol/UnwindPlan.h"
17 #include "lldb/Target/Thread.h"
18 #include "lldb/Utility/ArchSpec.h"
19 #include "lldb/Utility/Log.h"
20 #include "lldb/Utility/Timer.h"
21 #include <list>
22 #include <cstring>
23 
24 using namespace lldb;
25 using namespace lldb_private;
26 
27 // GetDwarfEHPtr
28 //
29 // Used for calls when the value type is specified by a DWARF EH Frame pointer
30 // encoding.
31 static uint64_t
32 GetGNUEHPointer(const DataExtractor &DE, offset_t *offset_ptr,
33  uint32_t eh_ptr_enc, addr_t pc_rel_addr, addr_t text_addr,
34  addr_t data_addr) //, BSDRelocs *data_relocs) const
35 {
36  if (eh_ptr_enc == DW_EH_PE_omit)
37  return ULLONG_MAX; // Value isn't in the buffer...
38 
39  uint64_t baseAddress = 0;
40  uint64_t addressValue = 0;
41  const uint32_t addr_size = DE.GetAddressByteSize();
42  assert(addr_size == 4 || addr_size == 8);
43 
44  bool signExtendValue = false;
45  // Decode the base part or adjust our offset
46  switch (eh_ptr_enc & 0x70) {
47  case DW_EH_PE_pcrel:
48  signExtendValue = true;
49  baseAddress = *offset_ptr;
50  if (pc_rel_addr != LLDB_INVALID_ADDRESS)
51  baseAddress += pc_rel_addr;
52  // else
53  // Log::GlobalWarning ("PC relative pointer encoding found with
54  // invalid pc relative address.");
55  break;
56 
57  case DW_EH_PE_textrel:
58  signExtendValue = true;
59  if (text_addr != LLDB_INVALID_ADDRESS)
60  baseAddress = text_addr;
61  // else
62  // Log::GlobalWarning ("text relative pointer encoding being
63  // decoded with invalid text section address, setting base address
64  // to zero.");
65  break;
66 
67  case DW_EH_PE_datarel:
68  signExtendValue = true;
69  if (data_addr != LLDB_INVALID_ADDRESS)
70  baseAddress = data_addr;
71  // else
72  // Log::GlobalWarning ("data relative pointer encoding being
73  // decoded with invalid data section address, setting base address
74  // to zero.");
75  break;
76 
77  case DW_EH_PE_funcrel:
78  signExtendValue = true;
79  break;
80 
81  case DW_EH_PE_aligned: {
82  // SetPointerSize should be called prior to extracting these so the pointer
83  // size is cached
84  assert(addr_size != 0);
85  if (addr_size) {
86  // Align to a address size boundary first
87  uint32_t alignOffset = *offset_ptr % addr_size;
88  if (alignOffset)
89  offset_ptr += addr_size - alignOffset;
90  }
91  } break;
92 
93  default:
94  break;
95  }
96 
97  // Decode the value part
98  switch (eh_ptr_enc & DW_EH_PE_MASK_ENCODING) {
99  case DW_EH_PE_absptr: {
100  addressValue = DE.GetAddress(offset_ptr);
101  // if (data_relocs)
102  // addressValue = data_relocs->Relocate(*offset_ptr -
103  // addr_size, *this, addressValue);
104  } break;
105  case DW_EH_PE_uleb128:
106  addressValue = DE.GetULEB128(offset_ptr);
107  break;
108  case DW_EH_PE_udata2:
109  addressValue = DE.GetU16(offset_ptr);
110  break;
111  case DW_EH_PE_udata4:
112  addressValue = DE.GetU32(offset_ptr);
113  break;
114  case DW_EH_PE_udata8:
115  addressValue = DE.GetU64(offset_ptr);
116  break;
117  case DW_EH_PE_sleb128:
118  addressValue = DE.GetSLEB128(offset_ptr);
119  break;
120  case DW_EH_PE_sdata2:
121  addressValue = (int16_t)DE.GetU16(offset_ptr);
122  break;
123  case DW_EH_PE_sdata4:
124  addressValue = (int32_t)DE.GetU32(offset_ptr);
125  break;
126  case DW_EH_PE_sdata8:
127  addressValue = (int64_t)DE.GetU64(offset_ptr);
128  break;
129  default:
130  // Unhandled encoding type
131  assert(eh_ptr_enc);
132  break;
133  }
134 
135  // Since we promote everything to 64 bit, we may need to sign extend
136  if (signExtendValue && addr_size < sizeof(baseAddress)) {
137  uint64_t sign_bit = 1ull << ((addr_size * 8ull) - 1ull);
138  if (sign_bit & addressValue) {
139  uint64_t mask = ~sign_bit + 1;
140  addressValue |= mask;
141  }
142  }
143  return baseAddress + addressValue;
144 }
145 
146 DWARFCallFrameInfo::DWARFCallFrameInfo(ObjectFile &objfile,
147  SectionSP &section_sp, Type type)
148  : m_objfile(objfile), m_section_sp(section_sp), m_type(type) {}
149 
151  UnwindPlan &unwind_plan) {
152  return GetUnwindPlan(AddressRange(addr, 1), unwind_plan);
153 }
154 
156  UnwindPlan &unwind_plan) {
157  FDEEntryMap::Entry fde_entry;
158  Address addr = range.GetBaseAddress();
159 
160  // Make sure that the Address we're searching for is the same object file as
161  // this DWARFCallFrameInfo, we only store File offsets in m_fde_index.
162  ModuleSP module_sp = addr.GetModule();
163  if (module_sp.get() == nullptr || module_sp->GetObjectFile() == nullptr ||
164  module_sp->GetObjectFile() != &m_objfile)
165  return false;
166 
167  if (llvm::Optional<FDEEntryMap::Entry> entry = GetFirstFDEEntryInRange(range))
168  return FDEToUnwindPlan(entry->data, addr, unwind_plan);
169  return false;
170 }
171 
173 
174  // Make sure that the Address we're searching for is the same object file as
175  // this DWARFCallFrameInfo, we only store File offsets in m_fde_index.
176  ModuleSP module_sp = addr.GetModule();
177  if (module_sp.get() == nullptr || module_sp->GetObjectFile() == nullptr ||
178  module_sp->GetObjectFile() != &m_objfile)
179  return false;
180 
181  if (m_section_sp.get() == nullptr || m_section_sp->IsEncrypted())
182  return false;
183  GetFDEIndex();
184  FDEEntryMap::Entry *fde_entry =
186  if (!fde_entry)
187  return false;
188 
189  range = AddressRange(fde_entry->base, fde_entry->size,
191  return true;
192 }
193 
194 llvm::Optional<DWARFCallFrameInfo::FDEEntryMap::Entry>
196  if (!m_section_sp || m_section_sp->IsEncrypted())
197  return llvm::None;
198 
199  GetFDEIndex();
200 
201  addr_t start_file_addr = range.GetBaseAddress().GetFileAddress();
202  const FDEEntryMap::Entry *fde =
204  if (fde && fde->DoesIntersect(
205  FDEEntryMap::Range(start_file_addr, range.GetByteSize())))
206  return *fde;
207 
208  return llvm::None;
209 }
210 
212  FunctionAddressAndSizeVector &function_info) {
213  GetFDEIndex();
214  const size_t count = m_fde_index.GetSize();
215  function_info.Clear();
216  if (count > 0)
217  function_info.Reserve(count);
218  for (size_t i = 0; i < count; ++i) {
219  const FDEEntryMap::Entry *func_offset_data_entry =
221  if (func_offset_data_entry) {
222  FunctionAddressAndSizeVector::Entry function_offset_entry(
223  func_offset_data_entry->base, func_offset_data_entry->size);
224  function_info.Append(function_offset_entry);
225  }
226  }
227 }
228 
231  cie_map_t::iterator pos = m_cie_map.find(cie_offset);
232 
233  if (pos != m_cie_map.end()) {
234  // Parse and cache the CIE
235  if (pos->second == nullptr)
236  pos->second = ParseCIE(cie_offset);
237 
238  return pos->second.get();
239  }
240  return nullptr;
241 }
242 
245  CIESP cie_sp(new CIE(cie_offset));
246  lldb::offset_t offset = cie_offset;
248  GetCFIData();
249  uint32_t length = m_cfi_data.GetU32(&offset);
250  dw_offset_t cie_id, end_offset;
251  bool is_64bit = (length == UINT32_MAX);
252  if (is_64bit) {
253  length = m_cfi_data.GetU64(&offset);
254  cie_id = m_cfi_data.GetU64(&offset);
255  end_offset = cie_offset + length + 12;
256  } else {
257  cie_id = m_cfi_data.GetU32(&offset);
258  end_offset = cie_offset + length + 4;
259  }
260  if (length > 0 && ((m_type == DWARF && cie_id == UINT32_MAX) ||
261  (m_type == EH && cie_id == 0ul))) {
262  size_t i;
263  // cie.offset = cie_offset;
264  // cie.length = length;
265  // cie.cieID = cieID;
266  cie_sp->ptr_encoding = DW_EH_PE_absptr; // default
267  cie_sp->version = m_cfi_data.GetU8(&offset);
268  if (cie_sp->version > CFI_VERSION4) {
270  "CIE parse error: CFI version %d is not supported\n",
271  cie_sp->version);
272  return nullptr;
273  }
274 
275  for (i = 0; i < CFI_AUG_MAX_SIZE; ++i) {
276  cie_sp->augmentation[i] = m_cfi_data.GetU8(&offset);
277  if (cie_sp->augmentation[i] == '\0') {
278  // Zero out remaining bytes in augmentation string
279  for (size_t j = i + 1; j < CFI_AUG_MAX_SIZE; ++j)
280  cie_sp->augmentation[j] = '\0';
281 
282  break;
283  }
284  }
285 
286  if (i == CFI_AUG_MAX_SIZE &&
287  cie_sp->augmentation[CFI_AUG_MAX_SIZE - 1] != '\0') {
289  "CIE parse error: CIE augmentation string was too large "
290  "for the fixed sized buffer of %d bytes.\n",
292  return nullptr;
293  }
294 
295  // m_cfi_data uses address size from target architecture of the process may
296  // ignore these fields?
297  if (m_type == DWARF && cie_sp->version >= CFI_VERSION4) {
298  cie_sp->address_size = m_cfi_data.GetU8(&offset);
299  cie_sp->segment_size = m_cfi_data.GetU8(&offset);
300  }
301 
302  cie_sp->code_align = (uint32_t)m_cfi_data.GetULEB128(&offset);
303  cie_sp->data_align = (int32_t)m_cfi_data.GetSLEB128(&offset);
304 
305  cie_sp->return_addr_reg_num =
306  m_type == DWARF && cie_sp->version >= CFI_VERSION3
307  ? static_cast<uint32_t>(m_cfi_data.GetULEB128(&offset))
308  : m_cfi_data.GetU8(&offset);
309 
310  if (cie_sp->augmentation[0]) {
311  // Get the length of the eh_frame augmentation data which starts with a
312  // ULEB128 length in bytes
313  const size_t aug_data_len = (size_t)m_cfi_data.GetULEB128(&offset);
314  const size_t aug_data_end = offset + aug_data_len;
315  const size_t aug_str_len = strlen(cie_sp->augmentation);
316  // A 'z' may be present as the first character of the string.
317  // If present, the Augmentation Data field shall be present. The contents
318  // of the Augmentation Data shall be interpreted according to other
319  // characters in the Augmentation String.
320  if (cie_sp->augmentation[0] == 'z') {
321  // Extract the Augmentation Data
322  size_t aug_str_idx = 0;
323  for (aug_str_idx = 1; aug_str_idx < aug_str_len; aug_str_idx++) {
324  char aug = cie_sp->augmentation[aug_str_idx];
325  switch (aug) {
326  case 'L':
327  // Indicates the presence of one argument in the Augmentation Data
328  // of the CIE, and a corresponding argument in the Augmentation
329  // Data of the FDE. The argument in the Augmentation Data of the
330  // CIE is 1-byte and represents the pointer encoding used for the
331  // argument in the Augmentation Data of the FDE, which is the
332  // address of a language-specific data area (LSDA). The size of the
333  // LSDA pointer is specified by the pointer encoding used.
334  cie_sp->lsda_addr_encoding = m_cfi_data.GetU8(&offset);
335  break;
336 
337  case 'P':
338  // Indicates the presence of two arguments in the Augmentation Data
339  // of the CIE. The first argument is 1-byte and represents the
340  // pointer encoding used for the second argument, which is the
341  // address of a personality routine handler. The size of the
342  // personality routine pointer is specified by the pointer encoding
343  // used.
344  //
345  // The address of the personality function will be stored at this
346  // location. Pre-execution, it will be all zero's so don't read it
347  // until we're trying to do an unwind & the reloc has been
348  // resolved.
349  {
350  uint8_t arg_ptr_encoding = m_cfi_data.GetU8(&offset);
351  const lldb::addr_t pc_rel_addr = m_section_sp->GetFileAddress();
352  cie_sp->personality_loc = GetGNUEHPointer(
353  m_cfi_data, &offset, arg_ptr_encoding, pc_rel_addr,
355  }
356  break;
357 
358  case 'R':
359  // A 'R' may be present at any position after the
360  // first character of the string. The Augmentation Data shall
361  // include a 1 byte argument that represents the pointer encoding
362  // for the address pointers used in the FDE. Example: 0x1B ==
363  // DW_EH_PE_pcrel | DW_EH_PE_sdata4
364  cie_sp->ptr_encoding = m_cfi_data.GetU8(&offset);
365  break;
366  }
367  }
368  } else if (strcmp(cie_sp->augmentation, "eh") == 0) {
369  // If the Augmentation string has the value "eh", then the EH Data
370  // field shall be present
371  }
372 
373  // Set the offset to be the end of the augmentation data just in case we
374  // didn't understand any of the data.
375  offset = (uint32_t)aug_data_end;
376  }
377 
378  if (end_offset > offset) {
379  cie_sp->inst_offset = offset;
380  cie_sp->inst_length = end_offset - offset;
381  }
382  while (offset < end_offset) {
383  uint8_t inst = m_cfi_data.GetU8(&offset);
384  uint8_t primary_opcode = inst & 0xC0;
385  uint8_t extended_opcode = inst & 0x3F;
386 
387  if (!HandleCommonDwarfOpcode(primary_opcode, extended_opcode,
388  cie_sp->data_align, offset,
389  cie_sp->initial_row))
390  break; // Stop if we hit an unrecognized opcode
391  }
392  }
393 
394  return cie_sp;
395 }
396 
398  if (!m_cfi_data_initialized) {
400  if (log)
401  m_objfile.GetModule()->LogMessage(log, "Reading EH frame info");
403  m_cfi_data_initialized = true;
404  }
405 }
406 // Scan through the eh_frame or debug_frame section looking for FDEs and noting
407 // the start/end addresses of the functions and a pointer back to the
408 // function's FDE for later expansion. Internalize CIEs as we come across them.
409 
411  if (m_section_sp.get() == nullptr || m_section_sp->IsEncrypted())
412  return;
413 
415  return;
416 
417  std::lock_guard<std::mutex> guard(m_fde_index_mutex);
418 
419  if (m_fde_index_initialized) // if two threads hit the locker
420  return;
421 
422  LLDB_SCOPED_TIMERF("%s - %s", LLVM_PRETTY_FUNCTION,
424 
425  bool clear_address_zeroth_bit = false;
426  if (ArchSpec arch = m_objfile.GetArchitecture()) {
427  if (arch.GetTriple().getArch() == llvm::Triple::arm ||
428  arch.GetTriple().getArch() == llvm::Triple::thumb)
429  clear_address_zeroth_bit = true;
430  }
431 
432  lldb::offset_t offset = 0;
434  GetCFIData();
435  while (m_cfi_data.ValidOffsetForDataOfSize(offset, 8)) {
436  const dw_offset_t current_entry = offset;
437  dw_offset_t cie_id, next_entry, cie_offset;
438  uint32_t len = m_cfi_data.GetU32(&offset);
439  bool is_64bit = (len == UINT32_MAX);
440  if (is_64bit) {
441  len = m_cfi_data.GetU64(&offset);
442  cie_id = m_cfi_data.GetU64(&offset);
443  next_entry = current_entry + len + 12;
444  cie_offset = current_entry + 12 - cie_id;
445  } else {
446  cie_id = m_cfi_data.GetU32(&offset);
447  next_entry = current_entry + len + 4;
448  cie_offset = current_entry + 4 - cie_id;
449  }
450 
451  if (next_entry > m_cfi_data.GetByteSize() + 1) {
452  Host::SystemLog(Host::eSystemLogError, "error: Invalid fde/cie next "
453  "entry offset of 0x%x found in "
454  "cie/fde at 0x%x\n",
455  next_entry, current_entry);
456  // Don't trust anything in this eh_frame section if we find blatantly
457  // invalid data.
458  m_fde_index.Clear();
460  return;
461  }
462 
463  // An FDE entry contains CIE_pointer in debug_frame in same place as cie_id
464  // in eh_frame. CIE_pointer is an offset into the .debug_frame section. So,
465  // variable cie_offset should be equal to cie_id for debug_frame.
466  // FDE entries with cie_id == 0 shouldn't be ignored for it.
467  if ((cie_id == 0 && m_type == EH) || cie_id == UINT32_MAX || len == 0) {
468  auto cie_sp = ParseCIE(current_entry);
469  if (!cie_sp) {
470  // Cannot parse, the reason is already logged
471  m_fde_index.Clear();
473  return;
474  }
475 
476  m_cie_map[current_entry] = std::move(cie_sp);
477  offset = next_entry;
478  continue;
479  }
480 
481  if (m_type == DWARF)
482  cie_offset = cie_id;
483 
484  if (cie_offset > m_cfi_data.GetByteSize()) {
486  "error: Invalid cie offset of 0x%x "
487  "found in cie/fde at 0x%x\n",
488  cie_offset, current_entry);
489  // Don't trust anything in this eh_frame section if we find blatantly
490  // invalid data.
491  m_fde_index.Clear();
493  return;
494  }
495 
496  const CIE *cie = GetCIE(cie_offset);
497  if (cie) {
498  const lldb::addr_t pc_rel_addr = m_section_sp->GetFileAddress();
499  const lldb::addr_t text_addr = LLDB_INVALID_ADDRESS;
500  const lldb::addr_t data_addr = LLDB_INVALID_ADDRESS;
501 
502  lldb::addr_t addr =
503  GetGNUEHPointer(m_cfi_data, &offset, cie->ptr_encoding, pc_rel_addr,
504  text_addr, data_addr);
505  if (clear_address_zeroth_bit)
506  addr &= ~1ull;
507 
508  lldb::addr_t length = GetGNUEHPointer(
510  pc_rel_addr, text_addr, data_addr);
511  FDEEntryMap::Entry fde(addr, length, current_entry);
512  m_fde_index.Append(fde);
513  } else {
514  Host::SystemLog(Host::eSystemLogError, "error: unable to find CIE at "
515  "0x%8.8x for cie_id = 0x%8.8x for "
516  "entry at 0x%8.8x.\n",
517  cie_offset, cie_id, current_entry);
518  }
519  offset = next_entry;
520  }
521  m_fde_index.Sort();
523 }
524 
526  Address startaddr,
527  UnwindPlan &unwind_plan) {
529  lldb::offset_t offset = dwarf_offset;
530  lldb::offset_t current_entry = offset;
531 
532  if (m_section_sp.get() == nullptr || m_section_sp->IsEncrypted())
533  return false;
534 
536  GetCFIData();
537 
538  uint32_t length = m_cfi_data.GetU32(&offset);
539  dw_offset_t cie_offset;
540  bool is_64bit = (length == UINT32_MAX);
541  if (is_64bit) {
542  length = m_cfi_data.GetU64(&offset);
543  cie_offset = m_cfi_data.GetU64(&offset);
544  } else {
545  cie_offset = m_cfi_data.GetU32(&offset);
546  }
547 
548  // FDE entries with zeroth cie_offset may occur for debug_frame.
549  assert(!(m_type == EH && 0 == cie_offset) && cie_offset != UINT32_MAX);
550 
551  // Translate the CIE_id from the eh_frame format, which is relative to the
552  // FDE offset, into a __eh_frame section offset
553  if (m_type == EH) {
554  unwind_plan.SetSourceName("eh_frame CFI");
555  cie_offset = current_entry + (is_64bit ? 12 : 4) - cie_offset;
557  } else {
558  unwind_plan.SetSourceName("DWARF CFI");
559  // In theory the debug_frame info should be valid at all call sites
560  // ("asynchronous unwind info" as it is sometimes called) but in practice
561  // gcc et al all emit call frame info for the prologue and call sites, but
562  // not for the epilogue or all the other locations during the function
563  // reliably.
565  }
567 
568  const CIE *cie = GetCIE(cie_offset);
569  assert(cie != nullptr);
570 
571  const dw_offset_t end_offset = current_entry + length + (is_64bit ? 12 : 4);
572 
573  const lldb::addr_t pc_rel_addr = m_section_sp->GetFileAddress();
574  const lldb::addr_t text_addr = LLDB_INVALID_ADDRESS;
575  const lldb::addr_t data_addr = LLDB_INVALID_ADDRESS;
576  lldb::addr_t range_base =
577  GetGNUEHPointer(m_cfi_data, &offset, cie->ptr_encoding, pc_rel_addr,
578  text_addr, data_addr);
579  lldb::addr_t range_len = GetGNUEHPointer(
581  pc_rel_addr, text_addr, data_addr);
582  AddressRange range(range_base, m_objfile.GetAddressByteSize(),
584  range.SetByteSize(range_len);
585 
586  addr_t lsda_data_file_address = LLDB_INVALID_ADDRESS;
587 
588  if (cie->augmentation[0] == 'z') {
589  uint32_t aug_data_len = (uint32_t)m_cfi_data.GetULEB128(&offset);
590  if (aug_data_len != 0 && cie->lsda_addr_encoding != DW_EH_PE_omit) {
591  offset_t saved_offset = offset;
592  lsda_data_file_address =
594  pc_rel_addr, text_addr, data_addr);
595  if (offset - saved_offset != aug_data_len) {
596  // There is more in the augmentation region than we know how to process;
597  // don't read anything.
598  lsda_data_file_address = LLDB_INVALID_ADDRESS;
599  }
600  offset = saved_offset;
601  }
602  offset += aug_data_len;
603  }
604  unwind_plan.SetUnwindPlanForSignalTrap(
605  strchr(cie->augmentation, 'S') ? eLazyBoolYes : eLazyBoolNo);
606 
607  Address lsda_data;
608  Address personality_function_ptr;
609 
610  if (lsda_data_file_address != LLDB_INVALID_ADDRESS &&
612  m_objfile.GetModule()->ResolveFileAddress(lsda_data_file_address,
613  lsda_data);
614  m_objfile.GetModule()->ResolveFileAddress(cie->personality_loc,
615  personality_function_ptr);
616  }
617 
618  if (lsda_data.IsValid() && personality_function_ptr.IsValid()) {
619  unwind_plan.SetLSDAAddress(lsda_data);
620  unwind_plan.SetPersonalityFunctionPtr(personality_function_ptr);
621  }
622 
623  uint32_t code_align = cie->code_align;
624  int32_t data_align = cie->data_align;
625 
626  unwind_plan.SetPlanValidAddressRange(range);
627  UnwindPlan::Row *cie_initial_row = new UnwindPlan::Row;
628  *cie_initial_row = cie->initial_row;
629  UnwindPlan::RowSP row(cie_initial_row);
630 
631  unwind_plan.SetRegisterKind(GetRegisterKind());
633 
634  std::vector<UnwindPlan::RowSP> stack;
635 
637  while (m_cfi_data.ValidOffset(offset) && offset < end_offset) {
638  uint8_t inst = m_cfi_data.GetU8(&offset);
639  uint8_t primary_opcode = inst & 0xC0;
640  uint8_t extended_opcode = inst & 0x3F;
641 
642  if (!HandleCommonDwarfOpcode(primary_opcode, extended_opcode, data_align,
643  offset, *row)) {
644  if (primary_opcode) {
645  switch (primary_opcode) {
646  case DW_CFA_advance_loc: // (Row Creation Instruction)
647  { // 0x40 - high 2 bits are 0x1, lower 6 bits are delta
648  // takes a single argument that represents a constant delta. The
649  // required action is to create a new table row with a location value
650  // that is computed by taking the current entry's location value and
651  // adding (delta * code_align). All other values in the new row are
652  // initially identical to the current row.
653  unwind_plan.AppendRow(row);
654  UnwindPlan::Row *newrow = new UnwindPlan::Row;
655  *newrow = *row.get();
656  row.reset(newrow);
657  row->SlideOffset(extended_opcode * code_align);
658  break;
659  }
660 
661  case DW_CFA_restore: { // 0xC0 - high 2 bits are 0x3, lower 6 bits are
662  // register
663  // takes a single argument that represents a register number. The
664  // required action is to change the rule for the indicated register
665  // to the rule assigned it by the initial_instructions in the CIE.
666  uint32_t reg_num = extended_opcode;
667  // We only keep enough register locations around to unwind what is in
668  // our thread, and these are organized by the register index in that
669  // state, so we need to convert our eh_frame register number from the
670  // EH frame info, to a register index
671 
672  if (unwind_plan.IsValidRowIndex(0) &&
673  unwind_plan.GetRowAtIndex(0)->GetRegisterInfo(reg_num,
674  reg_location))
675  row->SetRegisterInfo(reg_num, reg_location);
676  break;
677  }
678  }
679  } else {
680  switch (extended_opcode) {
681  case DW_CFA_set_loc: // 0x1 (Row Creation Instruction)
682  {
683  // DW_CFA_set_loc takes a single argument that represents an address.
684  // The required action is to create a new table row using the
685  // specified address as the location. All other values in the new row
686  // are initially identical to the current row. The new location value
687  // should always be greater than the current one.
688  unwind_plan.AppendRow(row);
689  UnwindPlan::Row *newrow = new UnwindPlan::Row;
690  *newrow = *row.get();
691  row.reset(newrow);
692  row->SetOffset(m_cfi_data.GetAddress(&offset) -
693  startaddr.GetFileAddress());
694  break;
695  }
696 
697  case DW_CFA_advance_loc1: // 0x2 (Row Creation Instruction)
698  {
699  // takes a single uword argument that represents a constant delta.
700  // This instruction is identical to DW_CFA_advance_loc except for the
701  // encoding and size of the delta argument.
702  unwind_plan.AppendRow(row);
703  UnwindPlan::Row *newrow = new UnwindPlan::Row;
704  *newrow = *row.get();
705  row.reset(newrow);
706  row->SlideOffset(m_cfi_data.GetU8(&offset) * code_align);
707  break;
708  }
709 
710  case DW_CFA_advance_loc2: // 0x3 (Row Creation Instruction)
711  {
712  // takes a single uword argument that represents a constant delta.
713  // This instruction is identical to DW_CFA_advance_loc except for the
714  // encoding and size of the delta argument.
715  unwind_plan.AppendRow(row);
716  UnwindPlan::Row *newrow = new UnwindPlan::Row;
717  *newrow = *row.get();
718  row.reset(newrow);
719  row->SlideOffset(m_cfi_data.GetU16(&offset) * code_align);
720  break;
721  }
722 
723  case DW_CFA_advance_loc4: // 0x4 (Row Creation Instruction)
724  {
725  // takes a single uword argument that represents a constant delta.
726  // This instruction is identical to DW_CFA_advance_loc except for the
727  // encoding and size of the delta argument.
728  unwind_plan.AppendRow(row);
729  UnwindPlan::Row *newrow = new UnwindPlan::Row;
730  *newrow = *row.get();
731  row.reset(newrow);
732  row->SlideOffset(m_cfi_data.GetU32(&offset) * code_align);
733  break;
734  }
735 
736  case DW_CFA_restore_extended: // 0x6
737  {
738  // takes a single unsigned LEB128 argument that represents a register
739  // number. This instruction is identical to DW_CFA_restore except for
740  // the encoding and size of the register argument.
741  uint32_t reg_num = (uint32_t)m_cfi_data.GetULEB128(&offset);
742  if (unwind_plan.IsValidRowIndex(0) &&
743  unwind_plan.GetRowAtIndex(0)->GetRegisterInfo(reg_num,
744  reg_location))
745  row->SetRegisterInfo(reg_num, reg_location);
746  break;
747  }
748 
749  case DW_CFA_remember_state: // 0xA
750  {
751  // These instructions define a stack of information. Encountering the
752  // DW_CFA_remember_state instruction means to save the rules for
753  // every register on the current row on the stack. Encountering the
754  // DW_CFA_restore_state instruction means to pop the set of rules off
755  // the stack and place them in the current row. (This operation is
756  // useful for compilers that move epilogue code into the body of a
757  // function.)
758  stack.push_back(row);
759  UnwindPlan::Row *newrow = new UnwindPlan::Row;
760  *newrow = *row.get();
761  row.reset(newrow);
762  break;
763  }
764 
765  case DW_CFA_restore_state: // 0xB
766  {
767  // These instructions define a stack of information. Encountering the
768  // DW_CFA_remember_state instruction means to save the rules for
769  // every register on the current row on the stack. Encountering the
770  // DW_CFA_restore_state instruction means to pop the set of rules off
771  // the stack and place them in the current row. (This operation is
772  // useful for compilers that move epilogue code into the body of a
773  // function.)
774  if (stack.empty()) {
775  LLDB_LOGF(log,
776  "DWARFCallFrameInfo::%s(dwarf_offset: %" PRIx32
777  ", startaddr: %" PRIx64
778  " encountered DW_CFA_restore_state but state stack "
779  "is empty. Corrupt unwind info?",
780  __FUNCTION__, dwarf_offset, startaddr.GetFileAddress());
781  break;
782  }
783  lldb::addr_t offset = row->GetOffset();
784  row = stack.back();
785  stack.pop_back();
786  row->SetOffset(offset);
787  break;
788  }
789 
790  case DW_CFA_GNU_args_size: // 0x2e
791  {
792  // The DW_CFA_GNU_args_size instruction takes an unsigned LEB128
793  // operand representing an argument size. This instruction specifies
794  // the total of the size of the arguments which have been pushed onto
795  // the stack.
796 
797  // TODO: Figure out how we should handle this.
798  m_cfi_data.GetULEB128(&offset);
799  break;
800  }
801 
802  case DW_CFA_val_offset: // 0x14
803  case DW_CFA_val_offset_sf: // 0x15
804  default:
805  break;
806  }
807  }
808  }
809  }
810  unwind_plan.AppendRow(row);
811 
812  return true;
813 }
814 
816  uint8_t extended_opcode,
817  int32_t data_align,
818  lldb::offset_t &offset,
819  UnwindPlan::Row &row) {
821 
822  if (primary_opcode) {
823  switch (primary_opcode) {
824  case DW_CFA_offset: { // 0x80 - high 2 bits are 0x2, lower 6 bits are
825  // register
826  // takes two arguments: an unsigned LEB128 constant representing a
827  // factored offset and a register number. The required action is to
828  // change the rule for the register indicated by the register number to
829  // be an offset(N) rule with a value of (N = factored offset *
830  // data_align).
831  uint8_t reg_num = extended_opcode;
832  int32_t op_offset = (int32_t)m_cfi_data.GetULEB128(&offset) * data_align;
833  reg_location.SetAtCFAPlusOffset(op_offset);
834  row.SetRegisterInfo(reg_num, reg_location);
835  return true;
836  }
837  }
838  } else {
839  switch (extended_opcode) {
840  case DW_CFA_nop: // 0x0
841  return true;
842 
843  case DW_CFA_offset_extended: // 0x5
844  {
845  // takes two unsigned LEB128 arguments representing a register number and
846  // a factored offset. This instruction is identical to DW_CFA_offset
847  // except for the encoding and size of the register argument.
848  uint32_t reg_num = (uint32_t)m_cfi_data.GetULEB128(&offset);
849  int32_t op_offset = (int32_t)m_cfi_data.GetULEB128(&offset) * data_align;
851  reg_location.SetAtCFAPlusOffset(op_offset);
852  row.SetRegisterInfo(reg_num, reg_location);
853  return true;
854  }
855 
856  case DW_CFA_undefined: // 0x7
857  {
858  // takes a single unsigned LEB128 argument that represents a register
859  // number. The required action is to set the rule for the specified
860  // register to undefined.
861  uint32_t reg_num = (uint32_t)m_cfi_data.GetULEB128(&offset);
863  reg_location.SetUndefined();
864  row.SetRegisterInfo(reg_num, reg_location);
865  return true;
866  }
867 
868  case DW_CFA_same_value: // 0x8
869  {
870  // takes a single unsigned LEB128 argument that represents a register
871  // number. The required action is to set the rule for the specified
872  // register to same value.
873  uint32_t reg_num = (uint32_t)m_cfi_data.GetULEB128(&offset);
875  reg_location.SetSame();
876  row.SetRegisterInfo(reg_num, reg_location);
877  return true;
878  }
879 
880  case DW_CFA_register: // 0x9
881  {
882  // takes two unsigned LEB128 arguments representing register numbers. The
883  // required action is to set the rule for the first register to be the
884  // second register.
885  uint32_t reg_num = (uint32_t)m_cfi_data.GetULEB128(&offset);
886  uint32_t other_reg_num = (uint32_t)m_cfi_data.GetULEB128(&offset);
888  reg_location.SetInRegister(other_reg_num);
889  row.SetRegisterInfo(reg_num, reg_location);
890  return true;
891  }
892 
893  case DW_CFA_def_cfa: // 0xC (CFA Definition Instruction)
894  {
895  // Takes two unsigned LEB128 operands representing a register number and
896  // a (non-factored) offset. The required action is to define the current
897  // CFA rule to use the provided register and offset.
898  uint32_t reg_num = (uint32_t)m_cfi_data.GetULEB128(&offset);
899  int32_t op_offset = (int32_t)m_cfi_data.GetULEB128(&offset);
900  row.GetCFAValue().SetIsRegisterPlusOffset(reg_num, op_offset);
901  return true;
902  }
903 
904  case DW_CFA_def_cfa_register: // 0xD (CFA Definition Instruction)
905  {
906  // takes a single unsigned LEB128 argument representing a register
907  // number. The required action is to define the current CFA rule to use
908  // the provided register (but to keep the old offset).
909  uint32_t reg_num = (uint32_t)m_cfi_data.GetULEB128(&offset);
910  row.GetCFAValue().SetIsRegisterPlusOffset(reg_num,
911  row.GetCFAValue().GetOffset());
912  return true;
913  }
914 
915  case DW_CFA_def_cfa_offset: // 0xE (CFA Definition Instruction)
916  {
917  // Takes a single unsigned LEB128 operand representing a (non-factored)
918  // offset. The required action is to define the current CFA rule to use
919  // the provided offset (but to keep the old register).
920  int32_t op_offset = (int32_t)m_cfi_data.GetULEB128(&offset);
922  row.GetCFAValue().GetRegisterNumber(), op_offset);
923  return true;
924  }
925 
926  case DW_CFA_def_cfa_expression: // 0xF (CFA Definition Instruction)
927  {
928  size_t block_len = (size_t)m_cfi_data.GetULEB128(&offset);
929  const uint8_t *block_data =
930  static_cast<const uint8_t *>(m_cfi_data.GetData(&offset, block_len));
931  row.GetCFAValue().SetIsDWARFExpression(block_data, block_len);
932  return true;
933  }
934 
935  case DW_CFA_expression: // 0x10
936  {
937  // Takes two operands: an unsigned LEB128 value representing a register
938  // number, and a DW_FORM_block value representing a DWARF expression. The
939  // required action is to change the rule for the register indicated by
940  // the register number to be an expression(E) rule where E is the DWARF
941  // expression. That is, the DWARF expression computes the address. The
942  // value of the CFA is pushed on the DWARF evaluation stack prior to
943  // execution of the DWARF expression.
944  uint32_t reg_num = (uint32_t)m_cfi_data.GetULEB128(&offset);
945  uint32_t block_len = (uint32_t)m_cfi_data.GetULEB128(&offset);
946  const uint8_t *block_data =
947  static_cast<const uint8_t *>(m_cfi_data.GetData(&offset, block_len));
949  reg_location.SetAtDWARFExpression(block_data, block_len);
950  row.SetRegisterInfo(reg_num, reg_location);
951  return true;
952  }
953 
954  case DW_CFA_offset_extended_sf: // 0x11
955  {
956  // takes two operands: an unsigned LEB128 value representing a register
957  // number and a signed LEB128 factored offset. This instruction is
958  // identical to DW_CFA_offset_extended except that the second operand is
959  // signed and factored.
960  uint32_t reg_num = (uint32_t)m_cfi_data.GetULEB128(&offset);
961  int32_t op_offset = (int32_t)m_cfi_data.GetSLEB128(&offset) * data_align;
963  reg_location.SetAtCFAPlusOffset(op_offset);
964  row.SetRegisterInfo(reg_num, reg_location);
965  return true;
966  }
967 
968  case DW_CFA_def_cfa_sf: // 0x12 (CFA Definition Instruction)
969  {
970  // Takes two operands: an unsigned LEB128 value representing a register
971  // number and a signed LEB128 factored offset. This instruction is
972  // identical to DW_CFA_def_cfa except that the second operand is signed
973  // and factored.
974  uint32_t reg_num = (uint32_t)m_cfi_data.GetULEB128(&offset);
975  int32_t op_offset = (int32_t)m_cfi_data.GetSLEB128(&offset) * data_align;
976  row.GetCFAValue().SetIsRegisterPlusOffset(reg_num, op_offset);
977  return true;
978  }
979 
980  case DW_CFA_def_cfa_offset_sf: // 0x13 (CFA Definition Instruction)
981  {
982  // takes a signed LEB128 operand representing a factored offset. This
983  // instruction is identical to DW_CFA_def_cfa_offset except that the
984  // operand is signed and factored.
985  int32_t op_offset = (int32_t)m_cfi_data.GetSLEB128(&offset) * data_align;
986  uint32_t cfa_regnum = row.GetCFAValue().GetRegisterNumber();
987  row.GetCFAValue().SetIsRegisterPlusOffset(cfa_regnum, op_offset);
988  return true;
989  }
990 
991  case DW_CFA_val_expression: // 0x16
992  {
993  // takes two operands: an unsigned LEB128 value representing a register
994  // number, and a DW_FORM_block value representing a DWARF expression. The
995  // required action is to change the rule for the register indicated by
996  // the register number to be a val_expression(E) rule where E is the
997  // DWARF expression. That is, the DWARF expression computes the value of
998  // the given register. The value of the CFA is pushed on the DWARF
999  // evaluation stack prior to execution of the DWARF expression.
1000  uint32_t reg_num = (uint32_t)m_cfi_data.GetULEB128(&offset);
1001  uint32_t block_len = (uint32_t)m_cfi_data.GetULEB128(&offset);
1002  const uint8_t *block_data =
1003  (const uint8_t *)m_cfi_data.GetData(&offset, block_len);
1004  reg_location.SetIsDWARFExpression(block_data, block_len);
1005  row.SetRegisterInfo(reg_num, reg_location);
1006  return true;
1007  }
1008  }
1009  }
1010  return false;
1011 }
1012 
1014  const std::function<bool(lldb::addr_t, uint32_t, dw_offset_t)> &callback) {
1015  GetFDEIndex();
1016 
1017  for (size_t i = 0, c = m_fde_index.GetSize(); i < c; ++i) {
1018  const FDEEntryMap::Entry &entry = m_fde_index.GetEntryRef(i);
1019  if (!callback(entry.base, entry.size, entry.data))
1020  break;
1021  }
1022 }
lldb_private::AddressRange::GetBaseAddress
Address & GetBaseAddress()
Get accessor for the base address of the range.
Definition: AddressRange.h:209
lldb_private::DWARFCallFrameInfo::m_fde_index_mutex
std::mutex m_fde_index_mutex
Definition: DWARFCallFrameInfo.h:155
lldb_private::ObjectFile::GetArchitecture
virtual ArchSpec GetArchitecture()=0
Get the ArchSpec for this object file.
lldb_private::DataExtractor::GetULEB128
uint64_t GetULEB128(lldb::offset_t *offset_ptr) const
Extract a unsigned LEB128 value from *offset_ptr.
Definition: DataExtractor.cpp:844
LLDB_SCOPED_TIMERF
#define LLDB_SCOPED_TIMERF(...)
Definition: Timer.h:86
lldb_private::UnwindPlan::AppendRow
void AppendRow(const RowSP &row_sp)
Definition: UnwindPlan.cpp:360
lldb_private::ArchSpec
Definition: ArchSpec.h:33
lldb_private::DWARFCallFrameInfo::CIE::data_align
int32_t data_align
Definition: DWARFCallFrameInfo.h:95
lldb_private::ObjectFile::GetFileSpec
virtual FileSpec & GetFileSpec()
Get accessor to the object file specification.
Definition: ObjectFile.h:291
lldb_private::DataExtractor::GetAddress
uint64_t GetAddress(lldb::offset_t *offset_ptr) const
Extract an address from *offset_ptr.
Definition: DataExtractor.cpp:651
lldb_private::Range::DoesIntersect
bool DoesIntersect(const Range &rhs) const
Definition: RangeMap.h:101
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:336
lldb_private::DWARFCallFrameInfo::m_fde_index
FDEEntryMap m_fde_index
Definition: DWARFCallFrameInfo.h:153
lldb_private::RangeDataVector::GetEntryRef
Entry & GetEntryRef(size_t i)
Definition: RangeMap.h:489
lldb_private::UnwindPlan::SetRegisterKind
void SetRegisterKind(lldb::RegisterKind kind)
Definition: UnwindPlan.h:439
lldb_private::DataExtractor::ValidOffset
bool ValidOffset(lldb::offset_t offset) const
Test the validity of offset.
Definition: DataExtractor.h:956
lldb_private::UnwindPlan::Row::SetRegisterInfo
void SetRegisterInfo(uint32_t reg_num, const RegisterLocation register_location)
Definition: UnwindPlan.cpp:271
Host.h
lldb_private::DWARFCallFrameInfo::GetFDEIndex
void GetFDEIndex()
Definition: DWARFCallFrameInfo.cpp:410
lldb_private::UnwindPlan::SetUnwindPlanValidAtAllInstructions
void SetUnwindPlanValidAtAllInstructions(lldb_private::LazyBool valid_at_all_insn)
Definition: UnwindPlan.h:492
lldb_private::UnwindPlan::Row::RegisterLocation::SetSame
void SetSame()
Definition: UnwindPlan.h:86
lldb_private::eLazyBoolYes
@ eLazyBoolYes
Definition: lldb-private-enumerations.h:115
LLDB_LOGF
#define LLDB_LOGF(log,...)
Definition: Log.h:249
lldb_private::AddressRange::GetByteSize
lldb::addr_t GetByteSize() const
Get accessor for the byte size of this range.
Definition: AddressRange.h:221
lldb_private::UnwindPlan::Row::RegisterLocation::SetAtDWARFExpression
void SetAtDWARFExpression(const uint8_t *opcodes, uint32_t len)
Definition: UnwindPlan.cpp:53
Module.h
lldb_private::DWARFCallFrameInfo::GetRegisterKind
lldb::RegisterKind GetRegisterKind() const
Definition: DWARFCallFrameInfo.h:162
lldb_private::DWARFCallFrameInfo::CFI_AUG_MAX_SIZE
@ CFI_AUG_MAX_SIZE
Definition: DWARFCallFrameInfo.h:79
lldb_private::RangeDataVector::Sort
void Sort()
Definition: RangeMap.h:411
lldb_private::ObjectFile::ReadSectionData
virtual size_t ReadSectionData(Section *section, lldb::offset_t section_offset, void *dst, size_t dst_len)
Definition: ObjectFile.cpp:471
lldb_private::UnwindPlan::Row::RegisterLocation::SetUndefined
void SetUndefined()
Definition: UnwindPlan.h:84
lldb_private::DWARFCallFrameInfo::GetCFIData
void GetCFIData()
Definition: DWARFCallFrameInfo.cpp:397
lldb_private::ConstString::AsCString
const char * AsCString(const char *value_if_empty=nullptr) const
Get the string value as a C string.
Definition: ConstString.h:193
lldb_private::UnwindPlan::SetUnwindPlanForSignalTrap
void SetUnwindPlanForSignalTrap(lldb_private::LazyBool is_for_signal_trap)
Definition: UnwindPlan.h:504
lldb::offset_t
uint64_t offset_t
Definition: lldb-types.h:87
lldb_private::DWARFCallFrameInfo::CFI_VERSION4
@ CFI_VERSION4
Definition: DWARFCallFrameInfo.h:83
lldb_private::RangeDataVector::Clear
void Clear()
Definition: RangeMap.h:473
lldb_private::RangeDataVector::GetEntryAtIndex
const Entry * GetEntryAtIndex(size_t i) const
Definition: RangeMap.h:479
lldb_private::DWARFCallFrameInfo::CIE::return_addr_reg_num
uint32_t return_addr_reg_num
Definition: DWARFCallFrameInfo.h:96
lldb_private::Range::size
SizeType size
Definition: RangeMap.h:34
lldb_private::RangeData
Definition: RangeMap.h:373
lldb::addr_t
uint64_t addr_t
Definition: lldb-types.h:83
lldb_private::RangeVector::Clear
void Clear()
Definition: RangeMap.h:246
lldb_private::RangeVector::Reserve
void Reserve(typename Collection::size_type size)
Definition: RangeMap.h:248
lldb_private::DWARFCallFrameInfo::GetFirstFDEEntryInRange
llvm::Optional< FDEEntryMap::Entry > GetFirstFDEEntryInRange(const AddressRange &range)
Definition: DWARFCallFrameInfo.cpp:195
lldb_private::UnwindPlan::SetSourceName
void SetSourceName(const char *)
Definition: UnwindPlan.cpp:562
Section.h
lldb_private::DataExtractor::GetU64
uint64_t GetU64(lldb::offset_t *offset_ptr) const
Extract a uint64_t value from *offset_ptr.
Definition: DataExtractor.cpp:476
lldb_private::RangeVector::Append
void Append(const Entry &entry)
Definition: RangeMap.h:136
lldb_private::DWARFCallFrameInfo::m_type
Type m_type
Definition: DWARFCallFrameInfo.h:157
lldb_private::DWARFCallFrameInfo::GetAddressRange
bool GetAddressRange(Address addr, AddressRange &range)
Definition: DWARFCallFrameInfo.cpp:172
lldb_private::DWARFCallFrameInfo::CIE
Definition: DWARFCallFrameInfo.h:86
lldb_private::DWARFCallFrameInfo::CIE::lsda_addr_encoding
uint8_t lsda_addr_encoding
Definition: DWARFCallFrameInfo.h:100
lldb_private::RangeDataVector::FindEntryThatContains
Entry * FindEntryThatContains(B addr)
Definition: RangeMap.h:514
lldb_private::ObjectFile::GetSectionList
virtual SectionList * GetSectionList(bool update_module_section_list=true)
Gets the section list for the currently selected architecture (and object for archives).
Definition: ObjectFile.cpp:585
lldb_private::DataExtractor::GetSLEB128
int64_t GetSLEB128(lldb::offset_t *offset_ptr) const
Extract a signed LEB128 value from *offset_ptr.
Definition: DataExtractor.cpp:861
lldb_private::UnwindPlan::SetPlanValidAddressRange
void SetPlanValidAddressRange(const AddressRange &range)
Definition: UnwindPlan.cpp:429
lldb_private::RangeDataVector::Append
void Append(const Entry &entry)
Definition: RangeMap.h:409
lldb_private::UnwindPlan::Row::FAValue::GetRegisterNumber
uint32_t GetRegisterNumber() const
Definition: UnwindPlan.h:250
lldb_private::DWARFCallFrameInfo::m_cfi_data
DataExtractor m_cfi_data
Definition: DWARFCallFrameInfo.h:150
lldb_private::DWARFCallFrameInfo::EH
@ EH
Definition: DWARFCallFrameInfo.h:35
lldb_private::DataExtractor::GetAddressByteSize
uint32_t GetAddressByteSize() const
Get the current address size.
Definition: DataExtractor.h:264
lldb_private::DataExtractor
Definition: DataExtractor.h:48
Log.h
lldb_private::UnwindPlan::SetReturnAddressRegister
void SetReturnAddressRegister(uint32_t regnum)
Definition: UnwindPlan.h:441
lldb_private::UnwindPlan::Row::GetCFAValue
FAValue & GetCFAValue()
Definition: UnwindPlan.h:341
lldb_private::DWARFCallFrameInfo::HandleCommonDwarfOpcode
bool HandleCommonDwarfOpcode(uint8_t primary_opcode, uint8_t extended_opcode, int32_t data_align, lldb::offset_t &offset, UnwindPlan::Row &row)
Definition: DWARFCallFrameInfo.cpp:815
DW_EH_PE_MASK_ENCODING
#define DW_EH_PE_MASK_ENCODING
Definition: dwarf.h:39
lldb_private::Address::GetFileAddress
lldb::addr_t GetFileAddress() const
Get the file address.
Definition: Address.cpp:290
lldb_private::UnwindPlan::Row::SlideOffset
void SlideOffset(lldb::addr_t offset)
Definition: UnwindPlan.h:339
lldb_private::UnwindPlan::SetSourcedFromCompiler
void SetSourcedFromCompiler(lldb_private::LazyBool from_compiler)
Definition: UnwindPlan.h:480
DWARFCallFrameInfo.h
GetGNUEHPointer
static uint64_t GetGNUEHPointer(const DataExtractor &DE, offset_t *offset_ptr, uint32_t eh_ptr_enc, addr_t pc_rel_addr, addr_t text_addr, addr_t data_addr)
Definition: DWARFCallFrameInfo.cpp:32
lldb_private::DataExtractor::GetU8
uint8_t GetU8(lldb::offset_t *offset_ptr) const
Extract a uint8_t value from *offset_ptr.
Definition: DataExtractor.cpp:318
lldb_private::AddressRange
Definition: AddressRange.h:25
Timer.h
lldb_private::Host::SystemLog
static void SystemLog(SystemLogType type, const char *format,...) __attribute__((format(printf
Definition: common/Host.cpp:296
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::DWARFCallFrameInfo::CIE::initial_row
lldb_private::UnwindPlan::Row initial_row
Definition: DWARFCallFrameInfo.h:104
lldb_private::GetLogIfAllCategoriesSet
Log * GetLogIfAllCategoriesSet(uint32_t mask)
Definition: Logging.cpp:58
lldb_private::DWARFCallFrameInfo::DWARF
@ DWARF
Definition: DWARFCallFrameInfo.h:35
lldb_private::Range< lldb::addr_t, uint32_t >
lldb_private::UnwindPlan::Row::RegisterLocation::SetInRegister
void SetInRegister(uint32_t reg_num)
Definition: UnwindPlan.h:128
lldb_private::DWARFCallFrameInfo::CIE::ptr_encoding
uint8_t ptr_encoding
Definition: DWARFCallFrameInfo.h:99
lldb_private::UnwindPlan::SetLSDAAddress
void SetLSDAAddress(Address lsda_addr)
Definition: UnwindPlan.h:526
Thread.h
lldb_private::RangeVector< lldb::addr_t, uint32_t >
UnwindPlan.h
lldb_private::DWARFCallFrameInfo::Type
Type
Definition: DWARFCallFrameInfo.h:35
ObjectFile.h
lldb_private::UnwindPlan::Row::RegisterLocation
Definition: UnwindPlan.h:57
lldb_private::UnwindPlan::RowSP
std::shared_ptr< Row > RowSP
Definition: UnwindPlan.h:395
lldb_private::DWARFCallFrameInfo::CIESP
std::shared_ptr< CIE > CIESP
Definition: DWARFCallFrameInfo.h:113
lldb_private::DWARFCallFrameInfo::CIE::code_align
uint32_t code_align
Definition: DWARFCallFrameInfo.h:94
lldb_private::DWARFCallFrameInfo::CFI_VERSION3
@ CFI_VERSION3
Definition: DWARFCallFrameInfo.h:82
lldb_private::UnwindPlan::SetPersonalityFunctionPtr
void SetPersonalityFunctionPtr(Address presonality_func_ptr)
Definition: UnwindPlan.h:530
dwarf.h
lldb_private::UnwindPlan::GetRowAtIndex
const UnwindPlan::RowSP GetRowAtIndex(uint32_t idx) const
Definition: UnwindPlan.cpp:405
lldb_private::UnwindPlan::Row
Definition: UnwindPlan.h:55
uint32_t
lldb_private::DWARFCallFrameInfo::CIE::augmentation
char augmentation[CFI_AUG_MAX_SIZE]
Definition: DWARFCallFrameInfo.h:89
lldb_private::eLazyBoolNo
@ eLazyBoolNo
Definition: lldb-private-enumerations.h:115
lldb_private::UnwindPlan::IsValidRowIndex
bool IsValidRowIndex(uint32_t idx) const
Definition: UnwindPlan.cpp:401
lldb_private::RangeDataVector::GetSize
size_t GetSize() const
Definition: RangeMap.h:477
lldb_private::Address
Definition: Address.h:59
lldb_private::DWARFCallFrameInfo::m_cie_map
cie_map_t m_cie_map
Definition: DWARFCallFrameInfo.h:148
lldb_private::UnwindPlan::Row::RegisterLocation::SetIsDWARFExpression
void SetIsDWARFExpression(const uint8_t *opcodes, uint32_t len)
Definition: UnwindPlan.cpp:62
lldb_private::DWARFCallFrameInfo::m_section_sp
lldb::SectionSP m_section_sp
Definition: DWARFCallFrameInfo.h:146
lldb_private::UnwindPlan::Row::FAValue::SetIsRegisterPlusOffset
void SetIsRegisterPlusOffset(uint32_t reg_num, int32_t offset)
Definition: UnwindPlan.h:227
ArchSpec.h
UINT32_MAX
#define UINT32_MAX
Definition: lldb-defines.h:31
lldb_private::DWARFCallFrameInfo::m_objfile
ObjectFile & m_objfile
Definition: DWARFCallFrameInfo.h:145
lldb_private::ModuleChild::GetModule
lldb::ModuleSP GetModule() const
Get const accessor for the module pointer.
Definition: ModuleChild.cpp:24
lldb_private::UnwindPlan::Row::RegisterLocation::SetAtCFAPlusOffset
void SetAtCFAPlusOffset(int32_t offset)
Definition: UnwindPlan.h:108
lldb_private::DataExtractor::GetU32
uint32_t GetU32(lldb::offset_t *offset_ptr) const
Extract a uint32_t value from *offset_ptr.
Definition: DataExtractor.cpp:427
lldb_private::DWARFCallFrameInfo::ForEachFDEEntries
void ForEachFDEEntries(const std::function< bool(lldb::addr_t, uint32_t, dw_offset_t)> &callback)
Definition: DWARFCallFrameInfo.cpp:1013
lldb_private::UnwindPlan::Row::SetOffset
void SetOffset(lldb::addr_t offset)
Definition: UnwindPlan.h:337
lldb_private::AddressRange::SetByteSize
void SetByteSize(lldb::addr_t byte_size)
Set accessor for the byte size of this range.
Definition: AddressRange.h:237
LLDB_INVALID_ADDRESS
#define LLDB_INVALID_ADDRESS
Definition: lldb-defines.h:86
lldb_private::UnwindPlan::Row::FAValue::SetIsDWARFExpression
void SetIsDWARFExpression(const uint8_t *opcodes, uint32_t len)
Definition: UnwindPlan.h:244
lldb_private
A class that represents a running process on the host machine.
Definition: SBCommandInterpreterRunOptions.h:16
lldb_private::DataExtractor::GetU16
uint16_t GetU16(lldb::offset_t *offset_ptr) const
Extract a uint16_t value from *offset_ptr.
Definition: DataExtractor.cpp:349
lldb_private::ObjectFile::GetAddressByteSize
virtual uint32_t GetAddressByteSize() const =0
Gets the address size in bytes for the current object file.
lldb_private::DWARFCallFrameInfo::ParseCIE
CIESP ParseCIE(const uint32_t cie_offset)
Definition: DWARFCallFrameInfo.cpp:244
lldb_private::DataExtractor::GetData
const void * GetData(lldb::offset_t *offset_ptr, lldb::offset_t length) const
Extract length bytes from *offset_ptr.
Definition: DataExtractor.h:337
lldb_private::Host::eSystemLogError
@ eSystemLogError
Definition: Host.h:106
lldb_private::DWARFCallFrameInfo::GetCIE
const CIE * GetCIE(dw_offset_t cie_offset)
Definition: DWARFCallFrameInfo.cpp:230
lldb_private::Address::GetModule
lldb::ModuleSP GetModule() const
Get accessor for the module for this address.
Definition: Address.cpp:282
lldb_private::Log
Definition: Log.h:49
lldb_private::RangeDataVector::FindEntryThatContainsOrFollows
const Entry * FindEntryThatContainsOrFollows(B addr) const
Definition: RangeMap.h:565
lldb_private::RangeData::data
DataType data
Definition: RangeMap.h:376
lldb_private::DWARFCallFrameInfo::FDEToUnwindPlan
bool FDEToUnwindPlan(uint32_t offset, Address startaddr, UnwindPlan &unwind_plan)
Definition: DWARFCallFrameInfo.cpp:525
lldb_private::DataExtractor::GetByteSize
uint64_t GetByteSize() const
Get the number of bytes contained in this object.
Definition: DataExtractor.h:270
lldb_private::Range::base
BaseType base
Definition: RangeMap.h:33
lldb_private::UnwindPlan
Definition: UnwindPlan.h:53
lldb_private::DataExtractor::ValidOffsetForDataOfSize
bool ValidOffsetForDataOfSize(lldb::offset_t offset, lldb::offset_t length) const
Test the availability of length bytes of data from offset.
Definition: DataExtractor.h:965
lldb
Definition: SBAddress.h:15
RegisterContext.h
lldb_private::FileSpec::GetFilename
ConstString & GetFilename()
Filename string get accessor.
Definition: FileSpec.cpp:339
LIBLLDB_LOG_UNWIND
#define LIBLLDB_LOG_UNWIND
Definition: Logging.h:29
lldb_private::ObjectFile
Definition: ObjectFile.h:59
lldb_private::DWARFCallFrameInfo::CIE::personality_loc
lldb::addr_t personality_loc
Definition: DWARFCallFrameInfo.h:102
lldb_private::DWARFCallFrameInfo::GetFunctionAddressAndSizeVector
void GetFunctionAddressAndSizeVector(FunctionAddressAndSizeVector &function_info)
Definition: DWARFCallFrameInfo.cpp:211
lldb_private::DWARFCallFrameInfo::m_cfi_data_initialized
bool m_cfi_data_initialized
Definition: DWARFCallFrameInfo.h:151
lldb_private::DWARFCallFrameInfo::m_fde_index_initialized
bool m_fde_index_initialized
Definition: DWARFCallFrameInfo.h:154