struct syscall_catchpoint : public breakpoint
{
- ~syscall_catchpoint () override;
-
/* Syscall numbers used for the 'catch syscall' feature. If no
- syscall has been specified for filtering, its value is NULL.
- Otherwise, it holds a list of all syscalls to be caught. The
- list elements are allocated with xmalloc. */
- VEC(int) *syscalls_to_be_caught;
+ syscall has been specified for filtering, it is empty.
+ Otherwise, it holds a list of all syscalls to be caught. */
+ std::vector<int> syscalls_to_be_caught;
};
-/* catch_syscall destructor. */
-
-syscall_catchpoint::~syscall_catchpoint ()
-{
- VEC_free (int, this->syscalls_to_be_caught);
-}
-
static const struct inferior_data *catch_syscall_inferior_data = NULL;
struct catch_syscall_inferior_data
= get_catch_syscall_inferior_data (inf);
++inf_data->total_syscalls_count;
- if (!c->syscalls_to_be_caught)
+ if (c->syscalls_to_be_caught.empty ())
++inf_data->any_syscall_count;
else
{
- int i, iter;
-
- for (i = 0;
- VEC_iterate (int, c->syscalls_to_be_caught, i, iter);
- i++)
+ for (int iter : c->syscalls_to_be_caught)
{
int elem;
= get_catch_syscall_inferior_data (inf);
--inf_data->total_syscalls_count;
- if (!c->syscalls_to_be_caught)
+ if (c->syscalls_to_be_caught.empty ())
--inf_data->any_syscall_count;
else
{
- int i, iter;
-
- for (i = 0;
- VEC_iterate (int, c->syscalls_to_be_caught, i, iter);
- i++)
+ for (int iter : c->syscalls_to_be_caught)
{
int elem;
if (iter >= VEC_length (int, inf_data->syscalls_counts))
syscall_number = ws->value.syscall_number;
/* Now, checking if the syscall is the same. */
- if (c->syscalls_to_be_caught)
+ if (!c->syscalls_to_be_caught.empty ())
{
- int i, iter;
-
- for (i = 0;
- VEC_iterate (int, c->syscalls_to_be_caught, i, iter);
- i++)
+ for (int iter : c->syscalls_to_be_caught)
if (syscall_number == iter)
return 1;
uiout->field_skip ("addr");
annotate_field (5);
- if (c->syscalls_to_be_caught
- && VEC_length (int, c->syscalls_to_be_caught) > 1)
+ if (c->syscalls_to_be_caught.size () > 1)
uiout->text ("syscalls \"");
else
uiout->text ("syscall \"");
- if (c->syscalls_to_be_caught)
+ if (!c->syscalls_to_be_caught.empty ())
{
- int i, iter;
char *text = xstrprintf ("%s", "");
- for (i = 0;
- VEC_iterate (int, c->syscalls_to_be_caught, i, iter);
- i++)
+ for (int iter : c->syscalls_to_be_caught)
{
char *x = text;
struct syscall s;
struct syscall_catchpoint *c = (struct syscall_catchpoint *) b;
struct gdbarch *gdbarch = b->loc->gdbarch;
- if (c->syscalls_to_be_caught)
+ if (!c->syscalls_to_be_caught.empty ())
{
- int i, iter;
-
- if (VEC_length (int, c->syscalls_to_be_caught) > 1)
+ if (c->syscalls_to_be_caught.size () > 1)
printf_filtered (_("Catchpoint %d (syscalls"), b->number);
else
printf_filtered (_("Catchpoint %d (syscall"), b->number);
- for (i = 0;
- VEC_iterate (int, c->syscalls_to_be_caught, i, iter);
- i++)
+ for (int iter : c->syscalls_to_be_caught)
{
struct syscall s;
get_syscall_by_number (gdbarch, iter, &s);
- if (s.name)
+ if (s.name != NULL)
printf_filtered (" '%s' [%d]", s.name, s.number);
else
printf_filtered (" %d", s.number);
fprintf_unfiltered (fp, "catch syscall");
- if (c->syscalls_to_be_caught)
+ for (int iter : c->syscalls_to_be_caught)
{
- int i, iter;
-
- for (i = 0;
- VEC_iterate (int, c->syscalls_to_be_caught, i, iter);
- i++)
- {
- struct syscall s;
+ struct syscall s;
- get_syscall_by_number (gdbarch, iter, &s);
- if (s.name)
- fprintf_unfiltered (fp, " %s", s.name);
- else
- fprintf_unfiltered (fp, " %d", s.number);
- }
+ get_syscall_by_number (gdbarch, iter, &s);
+ if (s.name != NULL)
+ fprintf_unfiltered (fp, " %s", s.name);
+ else
+ fprintf_unfiltered (fp, " %d", s.number);
}
+
print_recreate_thread (b, fp);
}
}
static void
-create_syscall_event_catchpoint (int tempflag, VEC(int) *filter,
+create_syscall_event_catchpoint (int tempflag, std::vector<int> &&filter,
const struct breakpoint_ops *ops)
{
struct syscall_catchpoint *c;
install_breakpoint (0, c, 1);
}
-/* Splits the argument using space as delimiter. Returns an xmalloc'd
- filter list, or NULL if no filtering is required. */
-static VEC(int) *
+/* Splits the argument using space as delimiter. */
+
+static std::vector<int>
catch_syscall_split_args (char *arg)
{
- VEC(int) *result = NULL;
- struct cleanup *cleanup = make_cleanup (VEC_cleanup (int), &result);
+ std::vector<int> result;
struct gdbarch *gdbarch = target_gdbarch ();
while (*arg != '\0')
if (*endptr == '\0')
{
get_syscall_by_number (gdbarch, syscall_number, &s);
- VEC_safe_push (int, result, s.number);
+ result.push_back (s.number);
}
else if (startswith (cur_name, "g:")
|| startswith (cur_name, "group:"))
{
/* Insert each syscall that are part of the group. No
need to check if it is valid. */
- VEC_safe_push (int, result, syscall_list[i].number);
+ result.push_back (syscall_list[i].number);
}
xfree (syscall_list);
error (_("Unknown syscall name '%s'."), cur_name);
/* Ok, it's valid. */
- VEC_safe_push (int, result, s.number);
+ result.push_back (s.number);
}
}
- discard_cleanups (cleanup);
return result;
}
struct cmd_list_element *command)
{
int tempflag;
- VEC(int) *filter;
+ std::vector<int> filter;
struct syscall s;
struct gdbarch *gdbarch = get_current_arch ();
if (arg != NULL)
filter = catch_syscall_split_args (arg);
- else
- filter = NULL;
- create_syscall_event_catchpoint (tempflag, filter,
+ create_syscall_event_catchpoint (tempflag, std::move (filter),
&catch_syscall_breakpoint_ops);
}
{
struct syscall_catchpoint *c = (struct syscall_catchpoint *) b;
- if (c->syscalls_to_be_caught)
+ if (!c->syscalls_to_be_caught.empty ())
{
- int i, iter;
- for (i = 0;
- VEC_iterate (int, c->syscalls_to_be_caught, i, iter);
- i++)
+ for (int iter : c->syscalls_to_be_caught)
if (syscall_number == iter)
return 1;
}