aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gdb/ChangeLog16
-rw-r--r--gdb/breakpoint.c64
-rw-r--r--gdb/probe.c8
-rw-r--r--gdb/probe.h16
-rw-r--r--gdb/solib-svr4.c29
5 files changed, 56 insertions, 77 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 9b91214..9c4e409 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,21 @@
2017-10-27 Simon Marchi <simon.marchi@ericsson.com>
+ * probe.h: Don't include gdb_vecs.h.
+ (DEF_VEC_P (probe_p)): Remove.
+ (find_probes_in_objfile): Return an std::vector.
+ * probe.c (find_probes_in_objfile): Likewise.
+ * breakpoint.c (breakpoint_objfile_data)
+ <longjmp_probes>: Change type to std::vector.
+ <exception_probes>: Likewise.
+ (free_breakpoint_probes): Don't manually free vectors.
+ (create_longjmp_master_breakpoint): Adjust.
+ (create_exception_master_breakpoint): Adjust.
+ * solib-svr4.c (svr4_create_probe_breakpoints): Change
+ parameter type, adjust.
+ (svr4_create_solib_event_breakpoints): Adjust.
+
+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.
diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c
index 3601e7d..aadd6ca 100644
--- a/gdb/breakpoint.c
+++ b/gdb/breakpoint.c
@@ -3191,8 +3191,9 @@ struct breakpoint_objfile_data
/* True if we have looked for longjmp probes. */
int longjmp_searched = 0;
- /* SystemTap probe points for longjmp (if any). */
- VEC (probe_p) *longjmp_probes = NULL;
+ /* SystemTap probe points for longjmp (if any). These are non-owning
+ references. */
+ std::vector<probe *> longjmp_probes;
/* Minimal symbol for "std::terminate()" (if any). */
struct bound_minimal_symbol terminate_msym {};
@@ -3203,8 +3204,9 @@ struct breakpoint_objfile_data
/* True if we have looked for exception probes. */
int exception_searched = 0;
- /* SystemTap probe points for unwinding (if any). */
- VEC (probe_p) *exception_probes = NULL;
+ /* SystemTap probe points for unwinding (if any). These are non-owning
+ references. */
+ std::vector<probe *> exception_probes;
};
static const struct objfile_data *breakpoint_objfile_key;
@@ -3244,9 +3246,6 @@ 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;
}
@@ -3328,43 +3327,35 @@ create_longjmp_master_breakpoint (void)
if (!bp_objfile_data->longjmp_searched)
{
- VEC (probe_p) *ret;
+ std::vector<probe *> ret
+ = find_probes_in_objfile (objfile, "libc", "longjmp");
- ret = find_probes_in_objfile (objfile, "libc", "longjmp");
- if (ret != NULL)
+ if (!ret.empty ())
{
/* We are only interested in checking one element. */
- struct probe *p = VEC_index (probe_p, ret, 0);
+ probe *p = ret[0];
if (!can_evaluate_probe_arguments (p))
{
/* We cannot use the probe interface here, because it does
not know how to evaluate arguments. */
- VEC_free (probe_p, ret);
- ret = NULL;
+ ret.clear ();
}
}
bp_objfile_data->longjmp_probes = ret;
bp_objfile_data->longjmp_searched = 1;
}
- if (bp_objfile_data->longjmp_probes != NULL)
+ if (!bp_objfile_data->longjmp_probes.empty ())
{
- int i;
- struct probe *probe;
struct gdbarch *gdbarch = get_objfile_arch (objfile);
- for (i = 0;
- VEC_iterate (probe_p,
- bp_objfile_data->longjmp_probes,
- i, probe);
- ++i)
+ for (probe *p : bp_objfile_data->longjmp_probes)
{
struct breakpoint *b;
b = create_internal_breakpoint (gdbarch,
- get_probe_address (probe,
- objfile),
+ get_probe_address (p, objfile),
bp_longjmp_master,
&internal_breakpoint_ops);
b->location = new_probe_location ("-probe-stap libc:longjmp");
@@ -3489,44 +3480,35 @@ create_exception_master_breakpoint (void)
/* We prefer the SystemTap probe point if it exists. */
if (!bp_objfile_data->exception_searched)
{
- VEC (probe_p) *ret;
-
- ret = find_probes_in_objfile (objfile, "libgcc", "unwind");
+ std::vector<probe *> ret
+ = find_probes_in_objfile (objfile, "libgcc", "unwind");
- if (ret != NULL)
+ if (!ret.empty ())
{
/* We are only interested in checking one element. */
- struct probe *p = VEC_index (probe_p, ret, 0);
+ probe *p = ret[0];
if (!can_evaluate_probe_arguments (p))
{
/* We cannot use the probe interface here, because it does
not know how to evaluate arguments. */
- VEC_free (probe_p, ret);
- ret = NULL;
+ ret.clear ();
}
}
bp_objfile_data->exception_probes = ret;
bp_objfile_data->exception_searched = 1;
}
- if (bp_objfile_data->exception_probes != NULL)
+ if (!bp_objfile_data->exception_probes.empty ())
{
struct gdbarch *gdbarch = get_objfile_arch (objfile);
- int i;
- struct probe *probe;
-
- for (i = 0;
- VEC_iterate (probe_p,
- bp_objfile_data->exception_probes,
- i, probe);
- ++i)
+
+ for (probe *p : bp_objfile_data->exception_probes)
{
struct breakpoint *b;
b = create_internal_breakpoint (gdbarch,
- get_probe_address (probe,
- objfile),
+ get_probe_address (p, objfile),
bp_exception_master,
&internal_breakpoint_ops);
b->location = new_probe_location ("-probe-stap libgcc:unwind");
diff --git a/gdb/probe.c b/gdb/probe.c
index ba40959..829f6d1 100644
--- a/gdb/probe.c
+++ b/gdb/probe.c
@@ -193,14 +193,14 @@ parse_probes (const struct event_location *location,
/* See definition in probe.h. */
-VEC (probe_p) *
+std::vector<probe *>
find_probes_in_objfile (struct objfile *objfile, const char *provider,
const char *name)
{
- VEC (probe_p) *result = NULL;
+ std::vector<probe *> result;
if (!objfile->sf || !objfile->sf->sym_probe_fns)
- return NULL;
+ return result;
const std::vector<probe *> &probes
= objfile->sf->sym_probe_fns->sym_get_probes (objfile);
@@ -212,7 +212,7 @@ find_probes_in_objfile (struct objfile *objfile, const char *provider,
if (strcmp (p->name, name) != 0)
continue;
- VEC_safe_push (probe_p, result, p);
+ result.push_back (p);
}
return result;
diff --git a/gdb/probe.h b/gdb/probe.h
index 1b39166..822e5c8 100644
--- a/gdb/probe.h
+++ b/gdb/probe.h
@@ -21,14 +21,6 @@
#define PROBE_H 1
struct event_location;
-
-#include "gdb_vecs.h"
-
-/* Definition of a vector of probes. */
-
-typedef struct probe *probe_p;
-DEF_VEC_P (probe_p);
-
struct linespec_result;
/* Structure useful for passing the header names in the method
@@ -255,11 +247,11 @@ extern struct bound_probe find_probe_by_pc (CORE_ADDR pc);
/* Search OBJFILE for a probe with the given PROVIDER, NAME. Return a
VEC of all probes that were found. If no matching probe is found,
- return NULL. The caller must free the VEC. */
+ return an empty vector. */
-extern VEC (probe_p) *find_probes_in_objfile (struct objfile *objfile,
- const char *provider,
- const char *name);
+extern std::vector<probe *> find_probes_in_objfile (struct objfile *objfile,
+ const char *provider,
+ const char *name);
/* Generate a `info probes' command output for probe_ops represented by
POPS. If POPS is NULL it considers any probes types. It is a helper
diff --git a/gdb/solib-svr4.c b/gdb/solib-svr4.c
index bf2577a..5ec606d 100644
--- a/gdb/solib-svr4.c
+++ b/gdb/solib-svr4.c
@@ -2075,25 +2075,19 @@ svr4_update_solib_event_breakpoints (void)
static void
svr4_create_probe_breakpoints (struct gdbarch *gdbarch,
- VEC (probe_p) **probes,
+ const std::vector<probe *> *probes,
struct objfile *objfile)
{
- int i;
-
- for (i = 0; i < NUM_PROBES; i++)
+ for (int i = 0; i < NUM_PROBES; i++)
{
enum probe_action action = probe_info[i].action;
- struct probe *probe;
- int ix;
- for (ix = 0;
- VEC_iterate (probe_p, probes[i], ix, probe);
- ++ix)
+ for (probe *p : probes[i])
{
- CORE_ADDR address = get_probe_address (probe, objfile);
+ CORE_ADDR address = get_probe_address (p, objfile);
create_solib_event_breakpoint (gdbarch, address);
- register_solib_event_probe (probe, address, action);
+ register_solib_event_probe (p, address, action);
}
}
@@ -2125,13 +2119,11 @@ svr4_create_solib_event_breakpoints (struct gdbarch *gdbarch,
for (with_prefix = 0; with_prefix <= 1; with_prefix++)
{
- VEC (probe_p) *probes[NUM_PROBES];
+ std::vector<probe *> probes[NUM_PROBES];
int all_probes_found = 1;
int checked_can_use_probe_arguments = 0;
- int i;
- memset (probes, 0, sizeof (probes));
- for (i = 0; i < NUM_PROBES; i++)
+ for (int i = 0; i < NUM_PROBES; i++)
{
const char *name = probe_info[i].name;
struct probe *p;
@@ -2158,7 +2150,7 @@ svr4_create_solib_event_breakpoints (struct gdbarch *gdbarch,
if (strcmp (name, "rtld_map_failed") == 0)
continue;
- if (VEC_empty (probe_p, probes[i]))
+ if (probes[i].empty ())
{
all_probes_found = 0;
break;
@@ -2167,7 +2159,7 @@ svr4_create_solib_event_breakpoints (struct gdbarch *gdbarch,
/* Ensure probe arguments can be evaluated. */
if (!checked_can_use_probe_arguments)
{
- p = VEC_index (probe_p, probes[i], 0);
+ p = probes[i][0];
if (!can_evaluate_probe_arguments (p))
{
all_probes_found = 0;
@@ -2180,9 +2172,6 @@ svr4_create_solib_event_breakpoints (struct gdbarch *gdbarch,
if (all_probes_found)
svr4_create_probe_breakpoints (gdbarch, probes, os->objfile);
- for (i = 0; i < NUM_PROBES; i++)
- VEC_free (probe_p, probes[i]);
-
if (all_probes_found)
return;
}