aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Marchi <simon.marchi@ericsson.com>2017-10-27 22:01:21 -0400
committerSimon Marchi <simon.marchi@ericsson.com>2017-10-27 22:01:21 -0400
commit43dce4394513d15ba8122c3bf442ec1028d93feb (patch)
treea4f57eff55e8f754f8a937eb1b886ef58b2f53f3
parent6a1b9516d824a4d364040887455ba910f955f065 (diff)
downloadfsf-binutils-gdb-43dce4394513d15ba8122c3bf442ec1028d93feb.zip
fsf-binutils-gdb-43dce4394513d15ba8122c3bf442ec1028d93feb.tar.gz
fsf-binutils-gdb-43dce4394513d15ba8122c3bf442ec1028d93feb.tar.bz2
Allocate breakpoint_objfile_data with new
Allocate with new and free with delete. This allows using an std::vector in the following patch. I renamed free_breakpoint_probes to free_breakpoint_objfile_data, because it now doesn't only free the probes vector, but also the breakpoint_objfile_data structure itself. gdb/ChangeLog: * breakpoint.c (breakpoint_objfile_data): Initialize fields. (get_breakpoint_objfile_data): Allocate breakpoint_objfile_data with new. (free_breakpoint_probes): Rename to ... (free_breakpoint_objfile_data): ... this, and call delete on bp_objfile_data..
-rw-r--r--gdb/ChangeLog9
-rw-r--r--gdb/breakpoint.c27
2 files changed, 22 insertions, 14 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index c1a3dee..9b91214 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,12 @@
+2017-10-27 Simon Marchi <simon.marchi@ericsson.com>
+
+ * breakpoint.c (breakpoint_objfile_data): Initialize fields.
+ (get_breakpoint_objfile_data): Allocate breakpoint_objfile_data
+ with new.
+ (free_breakpoint_probes): Rename to ...
+ (free_breakpoint_objfile_data): ... this, and call delete on
+ bp_objfile_data..
+
2017-10-27 Simon Marchi <simon.marchi@polymtl.ca>
* auto-load.c: Don't include gdb_vecs.h, include algorithm.
diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c
index 10fccb8..3601e7d 100644
--- a/gdb/breakpoint.c
+++ b/gdb/breakpoint.c
@@ -3183,28 +3183,28 @@ static const char *const longjmp_names[] =
struct breakpoint_objfile_data
{
/* Minimal symbol for "_ovly_debug_event" (if any). */
- struct bound_minimal_symbol overlay_msym;
+ struct bound_minimal_symbol overlay_msym {};
/* Minimal symbol(s) for "longjmp", "siglongjmp", etc. (if any). */
- struct bound_minimal_symbol longjmp_msym[NUM_LONGJMP_NAMES];
+ struct bound_minimal_symbol longjmp_msym[NUM_LONGJMP_NAMES] {};
/* True if we have looked for longjmp probes. */
- int longjmp_searched;
+ int longjmp_searched = 0;
/* SystemTap probe points for longjmp (if any). */
- VEC (probe_p) *longjmp_probes;
+ VEC (probe_p) *longjmp_probes = NULL;
/* Minimal symbol for "std::terminate()" (if any). */
- struct bound_minimal_symbol terminate_msym;
+ struct bound_minimal_symbol terminate_msym {};
/* Minimal symbol for "_Unwind_DebugHook" (if any). */
- struct bound_minimal_symbol exception_msym;
+ struct bound_minimal_symbol exception_msym {};
/* True if we have looked for exception probes. */
- int exception_searched;
+ int exception_searched = 0;
/* SystemTap probe points for unwinding (if any). */
- VEC (probe_p) *exception_probes;
+ VEC (probe_p) *exception_probes = NULL;
};
static const struct objfile_data *breakpoint_objfile_key;
@@ -3232,23 +3232,22 @@ get_breakpoint_objfile_data (struct objfile *objfile)
objfile_data (objfile, breakpoint_objfile_key));
if (bp_objfile_data == NULL)
{
- bp_objfile_data =
- XOBNEW (&objfile->objfile_obstack, struct breakpoint_objfile_data);
-
- memset (bp_objfile_data, 0, sizeof (*bp_objfile_data));
+ bp_objfile_data = new breakpoint_objfile_data ();
set_objfile_data (objfile, breakpoint_objfile_key, bp_objfile_data);
}
return bp_objfile_data;
}
static void
-free_breakpoint_probes (struct objfile *obj, void *data)
+free_breakpoint_objfile_data (struct objfile *obj, void *data)
{
struct breakpoint_objfile_data *bp_objfile_data
= (struct breakpoint_objfile_data *) data;
VEC_free (probe_p, bp_objfile_data->longjmp_probes);
VEC_free (probe_p, bp_objfile_data->exception_probes);
+
+ delete bp_objfile_data;
}
static void
@@ -15544,7 +15543,7 @@ _initialize_breakpoint (void)
observer_attach_memory_changed (invalidate_bp_value_on_memory_change);
breakpoint_objfile_key
- = register_objfile_data_with_cleanup (NULL, free_breakpoint_probes);
+ = register_objfile_data_with_cleanup (NULL, free_breakpoint_objfile_data);
breakpoint_chain = 0;
/* Don't bother to call set_breakpoint_count. $bpnum isn't useful