diff options
author | Tom Tromey <tom@tromey.com> | 2018-08-28 16:14:52 -0600 |
---|---|---|
committer | Tom Tromey <tom@tromey.com> | 2018-10-03 15:19:06 -0600 |
commit | 780942fc2422d80a49b748e484890f11db31f49e (patch) | |
tree | f2204a52bac7da0d2eda824cc0ea2d5088ab2f4d /gdb/dwarf2-frame.c | |
parent | 10657c047e4e0257440c80fda5f4e23a3452616c (diff) | |
download | gdb-780942fc2422d80a49b748e484890f11db31f49e.zip gdb-780942fc2422d80a49b748e484890f11db31f49e.tar.gz gdb-780942fc2422d80a49b748e484890f11db31f49e.tar.bz2 |
Change dwarf2_frame_state_reg_info::reg to be std::vector
This changes dwarf2_frame_state_reg_info::reg to be a std::vector.
This avoids passing NULL to memcpy in the copy constructor when the
original object does not have any registers.
gdb/ChangeLog
2018-10-03 Tom Tromey <tom@tromey.com>
* dwarf2-frame.h (dwarf2_frame_state_reg_info)
<~dwarf2_frame_state_reg_info>: Update.
<dwarf2_frame_state_reg_info>: Update.
<alloc_regs>: Add assertion. Update.
<reg>: Now a std::vector.
<num_regs>: Remove.
<swap>: Update.
* dwarf2-frame.c (dwarf2_restore_rule, execute_cfa_program)
(execute_cfa_program_test, dwarf2_frame_cache): Update.
Diffstat (limited to 'gdb/dwarf2-frame.c')
-rw-r--r-- | gdb/dwarf2-frame.c | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/gdb/dwarf2-frame.c b/gdb/dwarf2-frame.c index f7dc820..118bc11 100644 --- a/gdb/dwarf2-frame.c +++ b/gdb/dwarf2-frame.c @@ -204,14 +204,13 @@ dwarf2_restore_rule (struct gdbarch *gdbarch, ULONGEST reg_num, { ULONGEST reg; - gdb_assert (fs->initial.reg); reg = dwarf2_frame_adjust_regnum (gdbarch, reg_num, eh_frame_p); fs->regs.alloc_regs (reg + 1); /* Check if this register was explicitly initialized in the CIE initial instructions. If not, default the rule to UNSPECIFIED. */ - if (reg < fs->initial.num_regs) + if (reg < fs->initial.reg.size ()) fs->regs.reg[reg] = fs->initial.reg[reg]; else fs->regs.reg[reg].how = DWARF2_FRAME_REG_UNSPECIFIED; @@ -602,7 +601,7 @@ bad CFI data; mismatched DW_CFA_restore_state at %s"), } } - if (fs->initial.reg == NULL) + if (fs->initial.reg.empty ()) { /* Don't allow remember/restore between CIE and FDE programs. */ delete fs->regs.prev; @@ -653,12 +652,12 @@ execute_cfa_program_test (struct gdbarch *gdbarch) auto r1 = dwarf2_frame_adjust_regnum (gdbarch, 1, fde.eh_frame_p); auto r2 = dwarf2_frame_adjust_regnum (gdbarch, 2, fde.eh_frame_p); - SELF_CHECK (fs.regs.num_regs == (std::max (r1, r2) + 1)); + SELF_CHECK (fs.regs.reg.size () == (std::max (r1, r2) + 1)); SELF_CHECK (fs.regs.reg[r2].how == DWARF2_FRAME_REG_SAVED_OFFSET); SELF_CHECK (fs.regs.reg[r2].loc.offset == -4); - for (auto i = 0; i < fs.regs.num_regs; i++) + for (auto i = 0; i < fs.regs.reg.size (); i++) if (i != r2) SELF_CHECK (fs.regs.reg[i].how == DWARF2_FRAME_REG_UNSPECIFIED); @@ -1097,7 +1096,7 @@ dwarf2_frame_cache (struct frame_info *this_frame, void **this_cache) { int column; /* CFI speak for "register number". */ - for (column = 0; column < fs.regs.num_regs; column++) + for (column = 0; column < fs.regs.reg.size (); column++) { /* Use the GDB register number as the destination index. */ int regnum = dwarf_reg_to_regnum (gdbarch, column); @@ -1140,8 +1139,9 @@ incomplete CFI data; unspecified registers (e.g., %s) at %s"), if (cache->reg[regnum].how == DWARF2_FRAME_REG_RA || cache->reg[regnum].how == DWARF2_FRAME_REG_RA_OFFSET) { - struct dwarf2_frame_state_reg *retaddr_reg = - &fs.regs.reg[fs.retaddr_column]; + const std::vector<struct dwarf2_frame_state_reg> ®s + = fs.regs.reg; + ULONGEST retaddr_column = fs.retaddr_column; /* It seems rather bizarre to specify an "empty" column as the return adress column. However, this is exactly @@ -1150,14 +1150,14 @@ incomplete CFI data; unspecified registers (e.g., %s) at %s"), register corresponding to the return address column. Incidentally, that's how we should treat a return address column specifying "same value" too. */ - if (fs.retaddr_column < fs.regs.num_regs - && retaddr_reg->how != DWARF2_FRAME_REG_UNSPECIFIED - && retaddr_reg->how != DWARF2_FRAME_REG_SAME_VALUE) + if (fs.retaddr_column < fs.regs.reg.size () + && regs[retaddr_column].how != DWARF2_FRAME_REG_UNSPECIFIED + && regs[retaddr_column].how != DWARF2_FRAME_REG_SAME_VALUE) { if (cache->reg[regnum].how == DWARF2_FRAME_REG_RA) - cache->reg[regnum] = *retaddr_reg; + cache->reg[regnum] = regs[retaddr_column]; else - cache->retaddr_reg = *retaddr_reg; + cache->retaddr_reg = regs[retaddr_column]; } else { @@ -1176,7 +1176,7 @@ incomplete CFI data; unspecified registers (e.g., %s) at %s"), } } - if (fs.retaddr_column < fs.regs.num_regs + if (fs.retaddr_column < fs.regs.reg.size () && fs.regs.reg[fs.retaddr_column].how == DWARF2_FRAME_REG_UNDEFINED) cache->undefined_retaddr = 1; |