Remove a VEC from record-full.c
This replaces a VEC in record-full.c with a std::vector. This version of the patch also catches a memory leak in the original code noticed by Simon. Tested by the buildbot. gdb/ChangeLog 2018-06-10 Tom Tromey <tom@tromey.com> * record-full.c (record_full_breakpoint_p): Remove typedef. Don't declare VEC. Add constructor. <in_target_beneath>: Now bool. (record_full_breakpoints): Now a std::vector, static. (record_full_sync_record_breakpoints) (record_full_init_record_breakpoints) (record_full_target::insert_breakpoint) (record_full_target::remove_breakpoint): Update. Don't use XNEW.
This commit is contained in:
parent
71b7376497
commit
219605fd6a
|
@ -1,3 +1,14 @@
|
||||||
|
2018-06-10 Tom Tromey <tom@tromey.com>
|
||||||
|
|
||||||
|
* record-full.c (record_full_breakpoint_p): Remove typedef. Don't
|
||||||
|
declare VEC. Add constructor.
|
||||||
|
<in_target_beneath>: Now bool.
|
||||||
|
(record_full_breakpoints): Now a std::vector, static.
|
||||||
|
(record_full_sync_record_breakpoints)
|
||||||
|
(record_full_init_record_breakpoints)
|
||||||
|
(record_full_target::insert_breakpoint)
|
||||||
|
(record_full_target::remove_breakpoint): Update. Don't use XNEW.
|
||||||
|
|
||||||
2018-06-10 Simon Marchi <simon.marchi@polymtl.ca>
|
2018-06-10 Simon Marchi <simon.marchi@polymtl.ca>
|
||||||
|
|
||||||
* dwarf2read.c (process_cu_includes): Remove struct keyword.
|
* dwarf2read.c (process_cu_includes): Remove struct keyword.
|
||||||
|
|
|
@ -1700,6 +1700,15 @@ record_full_target::xfer_partial (enum target_object object,
|
||||||
|
|
||||||
struct record_full_breakpoint
|
struct record_full_breakpoint
|
||||||
{
|
{
|
||||||
|
record_full_breakpoint (struct address_space *address_space_,
|
||||||
|
CORE_ADDR addr_,
|
||||||
|
bool in_target_beneath_)
|
||||||
|
: address_space (address_space_),
|
||||||
|
addr (addr_),
|
||||||
|
in_target_beneath (in_target_beneath_)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
/* The address and address space the breakpoint was set at. */
|
/* The address and address space the breakpoint was set at. */
|
||||||
struct address_space *address_space;
|
struct address_space *address_space;
|
||||||
CORE_ADDR addr;
|
CORE_ADDR addr;
|
||||||
|
@ -1707,15 +1716,12 @@ struct record_full_breakpoint
|
||||||
/* True when the breakpoint has been also installed in the target
|
/* True when the breakpoint has been also installed in the target
|
||||||
beneath. This will be false for breakpoints set during replay or
|
beneath. This will be false for breakpoints set during replay or
|
||||||
when recording. */
|
when recording. */
|
||||||
int in_target_beneath;
|
bool in_target_beneath;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct record_full_breakpoint *record_full_breakpoint_p;
|
|
||||||
DEF_VEC_P(record_full_breakpoint_p);
|
|
||||||
|
|
||||||
/* The list of breakpoints inserted while the record target is
|
/* The list of breakpoints inserted while the record target is
|
||||||
active. */
|
active. */
|
||||||
VEC(record_full_breakpoint_p) *record_full_breakpoints = NULL;
|
static std::vector<record_full_breakpoint> record_full_breakpoints;
|
||||||
|
|
||||||
static void
|
static void
|
||||||
record_full_sync_record_breakpoints (struct bp_location *loc, void *data)
|
record_full_sync_record_breakpoints (struct bp_location *loc, void *data)
|
||||||
|
@ -1725,14 +1731,10 @@ record_full_sync_record_breakpoints (struct bp_location *loc, void *data)
|
||||||
|
|
||||||
if (loc->inserted)
|
if (loc->inserted)
|
||||||
{
|
{
|
||||||
struct record_full_breakpoint *bp = XNEW (struct record_full_breakpoint);
|
record_full_breakpoints.emplace_back
|
||||||
|
(loc->target_info.placed_address_space,
|
||||||
bp->addr = loc->target_info.placed_address;
|
loc->target_info.placed_address,
|
||||||
bp->address_space = loc->target_info.placed_address_space;
|
1);
|
||||||
|
|
||||||
bp->in_target_beneath = 1;
|
|
||||||
|
|
||||||
VEC_safe_push (record_full_breakpoint_p, record_full_breakpoints, bp);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1741,7 +1743,7 @@ record_full_sync_record_breakpoints (struct bp_location *loc, void *data)
|
||||||
static void
|
static void
|
||||||
record_full_init_record_breakpoints (void)
|
record_full_init_record_breakpoints (void)
|
||||||
{
|
{
|
||||||
VEC_free (record_full_breakpoint_p, record_full_breakpoints);
|
record_full_breakpoints.clear ();
|
||||||
|
|
||||||
iterate_over_bp_locations (record_full_sync_record_breakpoints);
|
iterate_over_bp_locations (record_full_sync_record_breakpoints);
|
||||||
}
|
}
|
||||||
|
@ -1754,9 +1756,7 @@ int
|
||||||
record_full_target::insert_breakpoint (struct gdbarch *gdbarch,
|
record_full_target::insert_breakpoint (struct gdbarch *gdbarch,
|
||||||
struct bp_target_info *bp_tgt)
|
struct bp_target_info *bp_tgt)
|
||||||
{
|
{
|
||||||
struct record_full_breakpoint *bp;
|
bool in_target_beneath = false;
|
||||||
int in_target_beneath = 0;
|
|
||||||
int ix;
|
|
||||||
|
|
||||||
if (!RECORD_FULL_IS_REPLAY)
|
if (!RECORD_FULL_IS_REPLAY)
|
||||||
{
|
{
|
||||||
|
@ -1773,30 +1773,25 @@ record_full_target::insert_breakpoint (struct gdbarch *gdbarch,
|
||||||
if (ret != 0)
|
if (ret != 0)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
in_target_beneath = 1;
|
in_target_beneath = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Use the existing entries if found in order to avoid duplication
|
/* Use the existing entries if found in order to avoid duplication
|
||||||
in record_full_breakpoints. */
|
in record_full_breakpoints. */
|
||||||
|
|
||||||
for (ix = 0;
|
for (struct record_full_breakpoint &bp : record_full_breakpoints)
|
||||||
VEC_iterate (record_full_breakpoint_p,
|
|
||||||
record_full_breakpoints, ix, bp);
|
|
||||||
++ix)
|
|
||||||
{
|
{
|
||||||
if (bp->addr == bp_tgt->placed_address
|
if (bp.addr == bp_tgt->placed_address
|
||||||
&& bp->address_space == bp_tgt->placed_address_space)
|
&& bp.address_space == bp_tgt->placed_address_space)
|
||||||
{
|
{
|
||||||
gdb_assert (bp->in_target_beneath == in_target_beneath);
|
gdb_assert (bp.in_target_beneath == in_target_beneath);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bp = XNEW (struct record_full_breakpoint);
|
record_full_breakpoints.emplace_back (bp_tgt->placed_address_space,
|
||||||
bp->addr = bp_tgt->placed_address;
|
bp_tgt->placed_address,
|
||||||
bp->address_space = bp_tgt->placed_address_space;
|
in_target_beneath);
|
||||||
bp->in_target_beneath = in_target_beneath;
|
|
||||||
VEC_safe_push (record_full_breakpoint_p, record_full_breakpoints, bp);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1807,18 +1802,16 @@ record_full_target::remove_breakpoint (struct gdbarch *gdbarch,
|
||||||
struct bp_target_info *bp_tgt,
|
struct bp_target_info *bp_tgt,
|
||||||
enum remove_bp_reason reason)
|
enum remove_bp_reason reason)
|
||||||
{
|
{
|
||||||
struct record_full_breakpoint *bp;
|
for (auto iter = record_full_breakpoints.begin ();
|
||||||
int ix;
|
iter != record_full_breakpoints.end ();
|
||||||
|
++iter)
|
||||||
for (ix = 0;
|
|
||||||
VEC_iterate (record_full_breakpoint_p,
|
|
||||||
record_full_breakpoints, ix, bp);
|
|
||||||
++ix)
|
|
||||||
{
|
{
|
||||||
if (bp->addr == bp_tgt->placed_address
|
struct record_full_breakpoint &bp = *iter;
|
||||||
&& bp->address_space == bp_tgt->placed_address_space)
|
|
||||||
|
if (bp.addr == bp_tgt->placed_address
|
||||||
|
&& bp.address_space == bp_tgt->placed_address_space)
|
||||||
{
|
{
|
||||||
if (bp->in_target_beneath)
|
if (bp.in_target_beneath)
|
||||||
{
|
{
|
||||||
scoped_restore restore_operation_disable
|
scoped_restore restore_operation_disable
|
||||||
= record_full_gdb_operation_disable_set ();
|
= record_full_gdb_operation_disable_set ();
|
||||||
|
@ -1830,10 +1823,7 @@ record_full_target::remove_breakpoint (struct gdbarch *gdbarch,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (reason == REMOVE_BREAKPOINT)
|
if (reason == REMOVE_BREAKPOINT)
|
||||||
{
|
unordered_remove (record_full_breakpoints, iter);
|
||||||
VEC_unordered_remove (record_full_breakpoint_p,
|
|
||||||
record_full_breakpoints, ix);
|
|
||||||
}
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue