Don't memset non-POD types: struct bp_location

struct bp_location is not a POD, so we shouldn't be using memset to
initialize it.

Caught like this:

  src/gdb/breakpoint.c: In function ‘bp_location** get_first_locp_gte_addr(CORE_ADDR)’:
  src/gdb/breakpoint.c:950:53: error: use of deleted function ‘void* memset(T*, int, size_t) [with T = bp_location; <template-parameter-1-2> = void; size_t = long unsigned int]’
     memset (&dummy_loc, 0, sizeof (struct bp_location));
						       ^
  In file included from src/gdb/defs.h:28:0,
		   from src/gdb/breakpoint.c:20:
  src/gdb/common/common-defs.h:126:7: note: declared here
   void *memset (T *s, int c, size_t n) = delete;
	 ^

gdb/ChangeLog:
2017-04-25  Pedro Alves  <palves@redhat.com>

	* ada-lang.c (ada_catchpoint_location): Now a "class".  Remove
	"base" field and inherit from "bp_location" instead.  Add
	non-default ctor.
	(allocate_location_exception): Use new non-default ctor.
	* breakpoint.c (get_first_locp_gte_addr): Remove memset call.
	(init_bp_location): Convert to ...
	(bp_location::bp_location): ... this new ctor, and remove memset
	call.
	(base_breakpoint_allocate_location): Use the new non-default ctor.
	* breakpoint.h (bp_location): Now a class.  Declare default and
	non-default ctors.  In-class initialize all members.
	(init_bp_location): Remove declaration.
This commit is contained in:
Pedro Alves
2017-04-25 01:27:42 +01:00
parent 23bcc18f47
commit 5625a28641
4 changed files with 58 additions and 54 deletions

View File

@@ -947,7 +947,6 @@ get_first_locp_gte_addr (CORE_ADDR address)
struct bp_location **locp_found = NULL;
/* Initialize the dummy location's address field. */
memset (&dummy_loc, 0, sizeof (struct bp_location));
dummy_loc.address = address;
/* Find a close match to the first location at ADDRESS. */
@@ -7300,11 +7299,9 @@ adjust_breakpoint_address (struct gdbarch *gdbarch,
}
}
void
init_bp_location (struct bp_location *loc, const struct bp_location_ops *ops,
struct breakpoint *owner)
bp_location::bp_location (const bp_location_ops *ops, breakpoint *owner)
{
memset (loc, 0, sizeof (*loc));
bp_location *loc = this;
gdb_assert (ops != NULL);
@@ -12824,11 +12821,7 @@ base_breakpoint_dtor (struct breakpoint *self)
static struct bp_location *
base_breakpoint_allocate_location (struct breakpoint *self)
{
struct bp_location *loc;
loc = new struct bp_location ();
init_bp_location (loc, &bp_location_ops, self);
return loc;
return new bp_location (&bp_location_ops, self);
}
static void