168 unsigned int *bytes_read_ptr,
174 #define cfa_exp_len cfa_reg 177 : pc (pc_), data_align (
cie->data_alignment_factor),
178 code_align (
cie->code_alignment_factor),
179 retaddr_column (
cie->return_address_register)
220 incomplete CFI data; DW_CFA_restore unspecified\n\ 221 register %s (#%d) at %s"),
258 int deref_size) OVERRIDE
265 invalid (
"DW_OP_push_object_address");
270 invalid (
"DW_OP_call_frame_cfa");
275 invalid (
"DW_OP_form_tls_address");
285 invalid (
"DW_OP_GNU_addr_index");
290 void invalid (
const char *op) ATTRIBUTE_NORETURN
292 error (
_(
"%s is invalid in this context"), op);
299 CORE_ADDR initial,
int initial_in_stack_memory)
325 Not implemented: computing unwound register using explicit value operator"));
342 unsigned int bytes_read;
345 while (insn_ptr < insn_end && fs->pc <= pc)
351 if ((insn & 0xc0) == DW_CFA_advance_loc)
353 else if ((insn & 0xc0) == DW_CFA_offset)
363 else if ((insn & 0xc0) == DW_CFA_restore)
379 insn_ptr += bytes_read;
382 case DW_CFA_advance_loc1:
387 case DW_CFA_advance_loc2:
392 case DW_CFA_advance_loc4:
398 case DW_CFA_offset_extended:
408 case DW_CFA_restore_extended:
413 case DW_CFA_undefined:
420 case DW_CFA_same_value:
427 case DW_CFA_register:
434 fs->
regs.reg[
reg].loc.reg = utmp;
437 case DW_CFA_remember_state:
442 fs->
regs.prev = new_rs;
446 case DW_CFA_restore_state:
453 bad CFI data; mismatched DW_CFA_restore_state at %s"),
457 fs->
regs = std::move (*old_rs);
469 fs->
regs.cfa_offset = utmp;
473 case DW_CFA_def_cfa_register:
480 case DW_CFA_def_cfa_offset:
486 fs->
regs.cfa_offset = utmp;
493 case DW_CFA_def_cfa_expression:
495 fs->
regs.cfa_exp_len = utmp;
496 fs->
regs.cfa_exp = insn_ptr;
498 insn_ptr += fs->
regs.cfa_exp_len;
501 case DW_CFA_expression:
506 fs->
regs.reg[
reg].loc.exp.start = insn_ptr;
507 fs->
regs.reg[
reg].loc.exp.len = utmp;
512 case DW_CFA_offset_extended_sf:
522 case DW_CFA_val_offset:
531 case DW_CFA_val_offset_sf:
540 case DW_CFA_val_expression:
544 fs->
regs.reg[
reg].loc.exp.start = insn_ptr;
545 fs->
regs.reg[
reg].loc.exp.len = utmp;
550 case DW_CFA_def_cfa_sf:
559 case DW_CFA_def_cfa_offset_sf:
565 case DW_CFA_GNU_args_size:
570 case DW_CFA_GNU_negative_offset_extended:
581 if (insn >= DW_CFA_lo_user && insn <= DW_CFA_hi_user)
585 error (
_(
"Call Frame Instruction op %d in vendor extension " 586 "space is not handled on this architecture."),
591 _(
"Unknown CFI encountered."));
599 delete fs->
regs.prev;
600 fs->
regs.prev = NULL;
618 memset (&fde, 0,
sizeof fde);
619 memset (&cie, 0,
sizeof cie);
621 cie.data_alignment_factor = -4;
622 cie.code_alignment_factor = 2;
629 DW_CFA_def_cfa, 1, 4,
630 DW_CFA_offset | 0x2, 1,
631 DW_CFA_remember_state,
632 DW_CFA_restore_state,
635 const gdb_byte *insn_end = insns +
sizeof (insns);
647 SELF_CHECK (fs.regs.num_regs == (std::max (r1, r2) + 1));
650 SELF_CHECK (fs.regs.reg[r2].loc.offset == -4);
652 for (
auto i = 0; i < fs.regs.num_regs; i++)
815 int regnum,
int eh_frame_p)
864 int *regnum_out,
LONGEST *offset_out,
876 error (
_(
"Could not compute CFA; needed to translate this expression"));
894 switch (fs.
regs.cfa_how)
902 *offset_out = -fs.
regs.cfa_offset;
904 *offset_out = fs.
regs.cfa_offset;
909 *text_offset_out = text_offset;
910 *cfa_start_out = fs.
regs.cfa_exp;
911 *cfa_end_out = fs.
regs.cfa_exp + fs.
regs.cfa_exp_len;
1034 instr = fde->instructions;
1043 switch (fs.
regs.cfa_how)
1048 cache->
cfa -= fs.
regs.cfa_offset;
1050 cache->
cfa += fs.
regs.cfa_offset;
1091 for (column = 0; column < fs.
regs.num_regs; column++)
1097 if (regnum < 0 || regnum >= num_regs)
1115 incomplete CFI data; unspecified registers (e.g., %s) at %s"),
1185 return UNWIND_UNAVAILABLE;
1188 return UNWIND_OUTERMOST;
1190 return UNWIND_NO_REASON;
1208 static struct value *
1264 this_frame, cache->
cfa, 1);
1275 this_frame, cache->
cfa, 1);
1327 struct frame_info *this_frame,
void **this_cache)
1439 _(
"cfa not available for record btrace target"));
1445 _(
"can't compute CFA for this frame: " 1446 "required registers or memory are unavailable"));
1450 _(
"can't compute CFA for this frame: " 1451 "frame base not available"));
1461 return bfd_get_8 (abfd, buf);
1467 return bfd_get_32 (abfd, buf);
1473 return bfd_get_64 (abfd, buf);
1478 unsigned int *bytes_read_ptr)
1482 result = bfd_get_32 (abfd, buf);
1483 if (result == 0xffffffff)
1485 result = bfd_get_64 (abfd, buf + 4);
1486 *bytes_read_ptr = 12;
1489 *bytes_read_ptr = 4;
1517 return DW_EH_PE_udata2;
1519 return DW_EH_PE_udata4;
1521 return DW_EH_PE_udata8;
1530 unsigned int *bytes_read_ptr,
1538 if (encoding & DW_EH_PE_indirect)
1540 _(
"Unsupported encoding: DW_EH_PE_indirect"));
1542 *bytes_read_ptr = 0;
1544 switch (encoding & 0x70)
1546 case DW_EH_PE_absptr:
1549 case DW_EH_PE_pcrel:
1553 case DW_EH_PE_datarel:
1556 case DW_EH_PE_textrel:
1559 case DW_EH_PE_funcrel:
1562 case DW_EH_PE_aligned:
1565 if ((
offset % ptr_len) != 0)
1567 *bytes_read_ptr = ptr_len - (
offset % ptr_len);
1568 buf += *bytes_read_ptr;
1573 _(
"Invalid or unsupported encoding"));
1576 if ((encoding & 0x07) == 0x00)
1579 if (bfd_get_sign_extend_vma (unit->
abfd))
1580 encoding |= DW_EH_PE_signed;
1583 switch (encoding & 0x0f)
1585 case DW_EH_PE_uleb128:
1588 const gdb_byte *end_buf = buf + (
sizeof (
value) + 1) * 8 / 7;
1591 return base +
value;
1593 case DW_EH_PE_udata2:
1594 *bytes_read_ptr += 2;
1595 return (base + bfd_get_16 (unit->
abfd, (bfd_byte *) buf));
1596 case DW_EH_PE_udata4:
1597 *bytes_read_ptr += 4;
1598 return (base + bfd_get_32 (unit->
abfd, (bfd_byte *) buf));
1599 case DW_EH_PE_udata8:
1600 *bytes_read_ptr += 8;
1601 return (base + bfd_get_64 (unit->
abfd, (bfd_byte *) buf));
1602 case DW_EH_PE_sleb128:
1605 const gdb_byte *end_buf = buf + (
sizeof (
value) + 1) * 8 / 7;
1608 return base +
value;
1610 case DW_EH_PE_sdata2:
1611 *bytes_read_ptr += 2;
1612 return (base + bfd_get_signed_16 (unit->
abfd, (bfd_byte *) buf));
1613 case DW_EH_PE_sdata4:
1614 *bytes_read_ptr += 4;
1615 return (base + bfd_get_signed_32 (unit->
abfd, (bfd_byte *) buf));
1616 case DW_EH_PE_sdata8:
1617 *bytes_read_ptr += 8;
1618 return (base + bfd_get_signed_64 (unit->
abfd, (bfd_byte *) buf));
1621 _(
"Invalid or unsupported encoding"));
1646 if (cie_table->
entries == NULL)
1705 if (fde_table == NULL)
1720 if (*pc < offset + fde_table->
entries[0]->initial_location)
1752 #define DW64_CIE_ID 0xffffffffffffffffULL 1784 unsigned int bytes_read;
1804 dwarf64_p = (bytes_read == 12);
1825 if (cie_pointer == cie_id)
1830 unsigned int cie_version;
1834 error (
_(
"Found a CIE when not expecting it."));
1857 if (cie_version != 1 && cie_version != 3 && cie_version != 4)
1913 if (cie_version == 1)
1966 buf, &bytes_read, 0);
2006 error (
_(
"Found an FDE when not expecting it."));
2015 cie_pointer -= (dwarf64_p ? 8 : 4);
2024 if (fde->
cie == NULL)
2035 buf, &bytes_read, 0);
2083 enum { NONE, ALIGN4, ALIGN8, FAIL } workaround = NONE;
2085 ptrdiff_t start_offset;
2090 cie_table, fde_table, entry_type);
2120 if (workaround < ALIGN4 && (start_offset & 3) != 0)
2122 start += 4 - (start_offset & 3);
2123 workaround = ALIGN4;
2126 if (workaround < ALIGN8 && (start_offset & 7) != 0)
2128 start += 8 - (start_offset & 7);
2129 workaround = ALIGN8;
2148 Corrupt data in %s:%s; align 4 workaround apparently succeeded"),
2155 Corrupt data in %s:%s; align 8 workaround apparently succeeded"),
2162 _(
"Corrupt data in %s:%s"),
2183 return (a < b) ? -1 : 1;
2225 asection *got, *txt;
2231 got = bfd_get_section_by_name (unit->
abfd,
".got");
2233 unit->
dbase = got->vma;
2237 txt = bfd_get_section_by_name (unit->
abfd,
".text");
2239 unit->
tbase = txt->vma;
2246 &cie_table, &fde_table,
2252 warning (
_(
"skipping .eh_frame info of %s: %s"),
2288 &cie_table, &fde_table,
2293 warning (
_(
"skipping .debug_frame info of %s: %s"),
2299 if (num_old_fde_entries == 0)
2336 struct dwarf2_fde *first_non_zero_fde = NULL;
2361 first_non_zero_fde = fde;
2375 && first_non_zero_fde != NULL
2380 if (fde_prev != NULL
2385 sizeof (fde_table.
entries[0]));
2407 selftests::execute_cfa_program_test);
dwarf2_frame_state(CORE_ADDR pc, struct dwarf2_cie *cie)
const struct frame_unwind record_btrace_tailcall_frame_unwind
void dwarf_call(cu_offset die_offset) OVERRIDE
struct frame_id frame_id_build(CORE_ADDR stack_addr, CORE_ADDR code_addr)
static gdb_byte encoding_for_size(unsigned int size)
CORE_ADDR get_frame_address_in_block(struct frame_info *this_frame)
static const struct frame_unwind dwarf2_frame_unwind
#define SECT_OFF_TEXT(objfile)
void dwarf2_build_frame_info(struct objfile *objfile)
int dwarf2_fetch_cfa_info(struct gdbarch *gdbarch, CORE_ADDR pc, struct dwarf2_per_cu_data *data, int *regnum_out, LONGEST *offset_out, CORE_ADDR *text_offset_out, const gdb_byte **cfa_start_out, const gdb_byte **cfa_end_out)
static void dwarf2_frame_this_id(struct frame_info *this_frame, void **this_cache, struct frame_id *this_id)
static int dwarf2_frame_adjust_regnum(struct gdbarch *gdbarch, int regnum, int eh_frame_p)
struct objfile * separate_debug_objfile_backlink
static void add_fde(struct dwarf2_fde_table *fde_table, struct dwarf2_fde *fde)
static CORE_ADDR read_encoded_value(struct comp_unit *unit, gdb_byte encoding, int ptr_len, const gdb_byte *buf, unsigned int *bytes_read_ptr, CORE_ADDR func_base)
int checked_tailcall_bottom
struct frame_info * get_prev_frame(struct frame_info *this_frame)
LONGEST value_as_long(struct value *val)
void dwarf2_frame_set_adjust_regnum(struct gdbarch *gdbarch, int(*adjust_regnum)(struct gdbarch *, int, int))
struct value * frame_unwind_got_memory(struct frame_info *frame, int regnum, CORE_ADDR addr)
unsigned char segment_size
void warning(const char *fmt,...)
static void dwarf2_frame_init_reg(struct gdbarch *gdbarch, int regnum, struct dwarf2_frame_state_reg *reg, struct frame_info *this_frame)
static const gdb_byte * decode_frame_entry_1(struct comp_unit *unit, const gdb_byte *start, int eh_frame_p, struct dwarf2_cie_table *cie_table, struct dwarf2_fde_table *fde_table, enum eh_frame_type entry_type)
const ULONGEST retaddr_column
CORE_ADDR dwarf2_frame_cfa(struct frame_info *this_frame)
int gdbarch_ptr_bit(struct gdbarch *gdbarch)
struct value * fetch(int n)
struct frame_id frame_id_build_unavailable_stack(CORE_ADDR code_addr)
CORE_ADDR get_tls_address(CORE_ADDR offset) OVERRIDE
void * memset(T *s, int c, size_t n)=delete
void internal_error(const char *file, int line, const char *fmt,...)
union dwarf2_frame_state_reg::@36 loc
CORE_ADDR initial_location
static int bsearch_fde_cmp(const void *key, const void *element)
static enum unwind_stop_reason dwarf2_frame_unwind_stop_reason(struct frame_info *this_frame, void **this_cache)
frame_dealloc_cache_ftype * dealloc_cache
void dwarf2_frame_set_signal_frame_p(struct gdbarch *gdbarch, int(*signal_frame_p)(struct gdbarch *, struct frame_info *))
const gdb_byte * safe_read_uleb128(const gdb_byte *buf, const gdb_byte *buf_end, uint64_t *r)
struct gdbarch_data * gdbarch_data_register_pre_init(gdbarch_data_pre_init_ftype *pre_init)
int gdbarch_num_regs(struct gdbarch *gdbarch)
void register_test_foreach_arch(const std::string &name, self_test_foreach_arch_function *function)
const struct objfile_data * dwarf2_frame_objfile_data
int producer_is_realview(const char *producer)
struct dwarf2_cie ** entries
const ULONGEST code_align
void frame_unwind_append_unwinder(struct gdbarch *gdbarch, const struct frame_unwind *unwinder)
bool gdbarch_execute_dwarf_cfa_vendor_op(struct gdbarch *gdbarch, gdb_byte op, struct dwarf2_frame_state *fs)
#define FRAME_OBSTACK_ZALLOC(TYPE)
const struct frame_unwind record_btrace_frame_unwind
const char * paddress(struct gdbarch *gdbarch, CORE_ADDR addr)
struct value * frame_unwind_got_constant(struct frame_info *frame, int regnum, ULONGEST val)
static CORE_ADDR read_addr_from_reg(struct frame_info *this_frame, int reg)
struct compunit_symtab * find_pc_compunit_symtab(CORE_ADDR pc)
static struct dwarf2_frame_cache * dwarf2_frame_cache(struct frame_info *this_frame, void **this_cache)
int gdbarch_num_pseudo_regs(struct gdbarch *gdbarch)
unsigned char signal_frame
struct value * value_from_register(struct type *type, int regnum, struct frame_info *frame)
enum frame_type get_frame_type(struct frame_info *frame)
struct frame_id get_frame_id(struct frame_info *fi)
const struct frame_base * dwarf2_frame_base_sniffer(struct frame_info *this_frame)
int dwarf_reg_to_regnum_or_error(struct gdbarch *arch, ULONGEST dwarf_reg)
bfd_size_type dwarf_frame_size
#define CATCH(EXCEPTION, MASK)
asection * dwarf_frame_section
CORE_ADDR get_object_address()
struct dwarf2_fde ** entries
int gdbarch_sp_regnum(struct gdbarch *gdbarch)
objfile(bfd *, const char *, objfile_flags)
enum unwind_stop_reason get_frame_unwind_stop_reason(struct frame_info *frame)
struct dwarf2_frame_state_reg * reg
static int dwarf2_frame_signal_frame_p(struct gdbarch *gdbarch, struct frame_info *this_frame)
static ULONGEST extract_unsigned_integer(const gdb_byte *addr, int len, enum bfd_endian byte_order)
static void dwarf2_frame_dealloc_cache(struct frame_info *self, void *this_cache)
struct dwarf2_frame_state_reg::@36::@37 exp
int gdbarch_dwarf2_addr_size(struct gdbarch *gdbarch)
void invalid(const char *op) ATTRIBUTE_NORETURN
void push_address(CORE_ADDR value, bool in_stack_memory)
void dwarf2_get_section_info(struct objfile *objfile, enum dwarf2_section_enum sect, asection **sectp, const gdb_byte **bufp, bfd_size_type *sizep)
enum bfd_endian gdbarch_byte_order(struct gdbarch *gdbarch)
void eval(const gdb_byte *addr, size_t len)
#define ANOFFSET(secoff, whichone)
struct gdbarch * get_objfile_arch(const struct objfile *objfile)
int entry_cfa_sp_offset_p
dwarf2_frame_state_reg_info()=default
static const gdb_byte * execute_cfa_program(struct dwarf2_fde *fde, const gdb_byte *insn_ptr, const gdb_byte *insn_end, struct gdbarch *gdbarch, CORE_ADDR pc, struct dwarf2_frame_state *fs)
const gdb_byte * instructions
static unsigned int read_1_byte(bfd *abfd, const gdb_byte *buf)
static const gdb_byte * gdb_read_uleb128(const gdb_byte *buf, const gdb_byte *buf_end, uint64_t *r)
#define COMPUNIT_PRODUCER(cust)
void dwarf2_tailcall_sniffer_first(struct frame_info *this_frame, void **tailcall_cachep, const LONGEST *entry_cfa_sp_offsetp)
void _initialize_dwarf2_frame(void)
CORE_ADDR gdbarch_adjust_dwarf2_addr(struct gdbarch *gdbarch, CORE_ADDR pc)
#define complaint(COMPLAINTS, FMT,...)
const char * gdbarch_register_name(struct gdbarch *gdbarch, int regnr)
static const gdb_byte * decode_frame_entry(struct comp_unit *unit, const gdb_byte *start, int eh_frame_p, struct dwarf2_cie_table *cie_table, struct dwarf2_fde_table *fde_table, enum eh_frame_type entry_type)
static int startswith(const char *string, const char *pattern)
void read_mem(gdb_byte *buf, CORE_ADDR addr, size_t len) OVERRIDE
void(* init_reg)(struct gdbarch *, int, struct dwarf2_frame_state_reg *, struct frame_info *)
int dwarf_reg_to_regnum(struct gdbarch *arch, int dwarf_reg)
ULONGEST return_address_register
bool armcc_cfa_offsets_sf
void read_memory(CORE_ADDR memaddr, gdb_byte *myaddr, ssize_t len)
const char * objfile_name(const struct objfile *objfile)
ULONGEST get_frame_register_unsigned(struct frame_info *frame, int regnum)
#define XRESIZEVEC(T, P, N)
LONGEST entry_cfa_sp_offset
static ULONGEST read_8_bytes(bfd *abfd, const gdb_byte *buf)
CORE_ADDR address_from_register(int regnum, struct frame_info *frame)
const gdb_byte * safe_read_sleb128(const gdb_byte *buf, const gdb_byte *buf_end, int64_t *r)
static void * dwarf2_frame_init(struct obstack *obstack)
static int dwarf2_frame_sniffer(const struct frame_unwind *self, struct frame_info *this_frame, void **this_cache)
const gdb_byte * initial_instructions
ULONGEST code_alignment_factor
struct value * frame_unwind_got_optimized(struct frame_info *frame, int regnum)
void throw_exception(struct gdb_exception exception)
const struct frame_unwind dwarf2_tailcall_frame_unwind
int get_frame_func_if_available(struct frame_info *this_frame, CORE_ADDR *pc)
static CORE_ADDR execute_stack_op(const gdb_byte *exp, ULONGEST len, int addr_size, CORE_ADDR offset, struct frame_info *this_frame, CORE_ADDR initial, int initial_in_stack_memory)
const gdb_byte * dwarf_frame_buffer
CORE_ADDR get_frame_base(struct frame_info *fi)
struct value * frame_unwind_got_register(struct frame_info *frame, int regnum, int new_regnum)
static const struct frame_unwind dwarf2_signal_frame_unwind
static unsigned int read_4_bytes(bfd *abfd, const gdb_byte *buf)
struct complaints * symfile_complaints
CORE_ADDR fetch_address(int n)
struct frame_info * this_frame
unsigned char saw_z_augmentation
bool armcc_cfa_offsets_reversed
void dwarf2_append_unwinders(struct gdbarch *gdbarch)
static void dwarf2_restore_rule(struct gdbarch *gdbarch, ULONGEST reg_num, struct dwarf2_frame_state *fs, int eh_frame_p)
static struct dwarf2_fde * dwarf2_frame_find_fde(CORE_ADDR *pc, CORE_ADDR *out_offset)
CORE_ADDR read_addr_from_reg(int reg) OVERRIDE
static const struct frame_base dwarf2_frame_base
struct value * dwarf2_tailcall_prev_register_first(struct frame_info *this_frame, void **tailcall_cachep, int regnum)
enum dwarf_value_location location
static struct gdbarch_data * dwarf2_frame_data
static void dwarf2_frame_default_init_reg(struct gdbarch *gdbarch, int regnum, struct dwarf2_frame_state_reg *reg, struct frame_info *this_frame)
unsigned long long ULONGEST
static CORE_ADDR dwarf2_frame_base_address(struct frame_info *this_frame, void **this_cache)
struct value * frame_unwind_got_address(struct frame_info *frame, int regnum, CORE_ADDR addr)
static const gdb_byte * gdb_read_sleb128(const gdb_byte *buf, const gdb_byte *buf_end, int64_t *r)
CORE_ADDR get_addr_index(unsigned int index)
static ULONGEST read_initial_length(bfd *abfd, const gdb_byte *buf, unsigned int *bytes_read_ptr)
static struct value * dwarf2_frame_prev_register(struct frame_info *this_frame, void **this_cache, int regnum)
void dwarf2_frame_set_init_reg(struct gdbarch *gdbarch, void(*init_reg)(struct gdbarch *, int, struct dwarf2_frame_state_reg *, struct frame_info *))
int gdbarch_pc_regnum(struct gdbarch *gdbarch)
struct dwarf2_frame_state_reg retaddr_reg
CORE_ADDR get_frame_cfa()
struct dwarf2_frame_state_reg * reg
#define OBSTACK_ZALLOC(OBSTACK, TYPE)
struct value * get_reg_value(struct type *type, int reg) OVERRIDE
LONGEST data_alignment_factor
struct section_offsets * section_offsets
void push_dwarf_reg_entry_value(enum call_site_parameter_kind kind, union call_site_parameter_u kind_u, int deref_size) OVERRIDE
#define ALL_OBJFILES(obj)
static int qsort_fde_cmp(const void *a, const void *b)
static void add_cie(struct dwarf2_cie_table *cie_table, struct dwarf2_cie *cie)
enum bfd_endian byte_order
CORE_ADDR get_frame_func(struct frame_info *this_frame)
static struct dwarf2_cie * find_cie(struct dwarf2_cie_table *cie_table, ULONGEST cie_pointer)
enum dwarf2_frame_reg_rule how
void error(const char *fmt,...)
int(* signal_frame_p)(struct gdbarch *, struct frame_info *)
void get_frame_base(const gdb_byte **start, size_t *length) OVERRIDE
struct gdbarch * get_frame_arch(struct frame_info *this_frame)
#define FRAME_OBSTACK_CALLOC(NUMBER, TYPE)
void throw_error(enum errors error, const char *fmt,...)
static int bsearch_cie_cmp(const void *key, const void *element)
static void dwarf2_frame_find_quirks(struct dwarf2_frame_state *fs, struct dwarf2_fde *fde)
#define SELF_CHECK(VALUE)
int frame_unwinder_is(struct frame_info *fi, const struct frame_unwind *unwinder)
struct value *(* fn)(struct frame_info *this_frame, void **this_cache, int regnum)
int(* adjust_regnum)(struct gdbarch *, int, int)