- int i, iter;
- char *text = xstrprintf ("%s", "");
-
- for (i = 0;
- VEC_iterate (int, c->syscalls_to_be_caught, i, iter);
- i++)
- {
- char *x = text;
- struct syscall s;
- get_syscall_by_number (iter, &s);
-
- if (s.name != NULL)
- text = xstrprintf ("%s%s, ", text, s.name);
- else
- text = xstrprintf ("%s%d, ", text, iter);
-
- /* We have to xfree the last 'text' (now stored at 'x')
- because xstrprintf dynamically allocates new space for it
- on every call. */
- xfree (x);
- }
- /* Remove the last comma. */
- text[strlen (text) - 2] = '\0';
- ui_out_field_string (uiout, "what", text);
- }
- else
- ui_out_field_string (uiout, "what", "<any syscall>");
- ui_out_text (uiout, "\" ");
-
- if (ui_out_is_mi_like_p (uiout))
- ui_out_field_string (uiout, "catch-type", "syscall");
-}
-
-/* Implement the "print_mention" breakpoint_ops method for syscall
- catchpoints. */
-
-static void
-print_mention_catch_syscall (struct breakpoint *b)
-{
- struct syscall_catchpoint *c = (struct syscall_catchpoint *) b;
-
- if (c->syscalls_to_be_caught)
- {
- int i, iter;
-
- if (VEC_length (int, c->syscalls_to_be_caught) > 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++)
- {
- struct syscall s;
- get_syscall_by_number (iter, &s);
-
- if (s.name)
- printf_filtered (" '%s' [%d]", s.name, s.number);
- else
- printf_filtered (" %d", s.number);
- }
- printf_filtered (")");
- }
- else
- printf_filtered (_("Catchpoint %d (any syscall)"),
- b->number);
-}
-
-/* Implement the "print_recreate" breakpoint_ops method for syscall
- catchpoints. */
-
-static void
-print_recreate_catch_syscall (struct breakpoint *b, struct ui_file *fp)
-{
- struct syscall_catchpoint *c = (struct syscall_catchpoint *) b;
-
- fprintf_unfiltered (fp, "catch syscall");
-
- if (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;
-
- get_syscall_by_number (iter, &s);
- if (s.name)
- fprintf_unfiltered (fp, " %s", s.name);
- else
- fprintf_unfiltered (fp, " %d", s.number);
- }
- }
- print_recreate_thread (b, fp);
-}
-
-/* The breakpoint_ops structure to be used in syscall catchpoints. */
-
-static struct breakpoint_ops catch_syscall_breakpoint_ops;
-
-/* Returns non-zero if 'b' is a syscall catchpoint. */
-
-static int
-syscall_catchpoint_p (struct breakpoint *b)
-{
- return (b->ops == &catch_syscall_breakpoint_ops);
-}
-
-/* Initialize a new breakpoint of the bp_catchpoint kind. If TEMPFLAG
- is non-zero, then make the breakpoint temporary. If COND_STRING is
- not NULL, then store it in the breakpoint. OPS, if not NULL, is
- the breakpoint_ops structure associated to the catchpoint. */
-
-void
-init_catchpoint (struct breakpoint *b,
- struct gdbarch *gdbarch, int tempflag,
- char *cond_string,
- const struct breakpoint_ops *ops)
-{
- struct symtab_and_line sal;
-
- init_sal (&sal);
- sal.pspace = current_program_space;
-
- init_raw_breakpoint (b, gdbarch, sal, bp_catchpoint, ops);
-
- b->cond_string = (cond_string == NULL) ? NULL : xstrdup (cond_string);
- b->disposition = tempflag ? disp_del : disp_donttouch;
-}
-
-void
-install_breakpoint (int internal, struct breakpoint *b, int update_gll)
-{
- add_to_breakpoint_chain (b);
- set_breakpoint_number (internal, b);
- if (is_tracepoint (b))
- set_tracepoint_count (breakpoint_count);
- if (!internal)
- mention (b);
- observer_notify_breakpoint_created (b);
-
- if (update_gll)
- update_global_location_list (UGLL_MAY_INSERT);
-}
-
-static void
-create_fork_vfork_event_catchpoint (struct gdbarch *gdbarch,
- int tempflag, char *cond_string,
- const struct breakpoint_ops *ops)
-{
- struct fork_catchpoint *c = XNEW (struct fork_catchpoint);
-
- init_catchpoint (&c->base, gdbarch, tempflag, cond_string, ops);
-
- c->forked_inferior_pid = null_ptid;
-
- install_breakpoint (0, &c->base, 1);
-}
-
-/* Exec catchpoints. */
-
-/* An instance of this type is used to represent an exec catchpoint.
- It includes a "struct breakpoint" as a kind of base class; users
- downcast to "struct breakpoint *" when needed. A breakpoint is
- really of this type iff its ops pointer points to
- CATCH_EXEC_BREAKPOINT_OPS. */
-
-struct exec_catchpoint
-{
- /* The base class. */
- struct breakpoint base;
-
- /* Filename of a program whose exec triggered this catchpoint.
- This field is only valid immediately after this catchpoint has
- triggered. */
- char *exec_pathname;
-};
-
-/* Implement the "dtor" breakpoint_ops method for exec
- catchpoints. */
-
-static void
-dtor_catch_exec (struct breakpoint *b)
-{
- struct exec_catchpoint *c = (struct exec_catchpoint *) b;
-
- xfree (c->exec_pathname);
-
- base_breakpoint_ops.dtor (b);
-}
-
-static int
-insert_catch_exec (struct bp_location *bl)
-{
- return target_insert_exec_catchpoint (ptid_get_pid (inferior_ptid));
-}
-
-static int
-remove_catch_exec (struct bp_location *bl)
-{
- return target_remove_exec_catchpoint (ptid_get_pid (inferior_ptid));
-}
-
-static int
-breakpoint_hit_catch_exec (const struct bp_location *bl,
- struct address_space *aspace, CORE_ADDR bp_addr,
- const struct target_waitstatus *ws)
-{
- struct exec_catchpoint *c = (struct exec_catchpoint *) bl->owner;
-
- if (ws->kind != TARGET_WAITKIND_EXECD)
- return 0;
-
- c->exec_pathname = xstrdup (ws->value.execd_pathname);
- return 1;
-}
-
-static enum print_stop_action
-print_it_catch_exec (bpstat bs)
-{
- struct ui_out *uiout = current_uiout;
- struct breakpoint *b = bs->breakpoint_at;
- struct exec_catchpoint *c = (struct exec_catchpoint *) b;
-
- annotate_catchpoint (b->number);
- if (b->disposition == disp_del)
- ui_out_text (uiout, "\nTemporary catchpoint ");
- else
- ui_out_text (uiout, "\nCatchpoint ");
- if (ui_out_is_mi_like_p (uiout))
- {
- ui_out_field_string (uiout, "reason",
- async_reason_lookup (EXEC_ASYNC_EXEC));
- ui_out_field_string (uiout, "disp", bpdisp_text (b->disposition));
- }
- ui_out_field_int (uiout, "bkptno", b->number);
- ui_out_text (uiout, " (exec'd ");
- ui_out_field_string (uiout, "new-exec", c->exec_pathname);
- ui_out_text (uiout, "), ");
-
- return PRINT_SRC_AND_LOC;
-}
-
-static void
-print_one_catch_exec (struct breakpoint *b, struct bp_location **last_loc)
-{
- struct exec_catchpoint *c = (struct exec_catchpoint *) b;
- struct value_print_options opts;
- struct ui_out *uiout = current_uiout;
-
- get_user_print_options (&opts);
-
- /* Field 4, the address, is omitted (which makes the columns
- not line up too nicely with the headers, but the effect
- is relatively readable). */
- if (opts.addressprint)
- ui_out_field_skip (uiout, "addr");
- annotate_field (5);
- ui_out_text (uiout, "exec");
- if (c->exec_pathname != NULL)
- {
- ui_out_text (uiout, ", program \"");
- ui_out_field_string (uiout, "what", c->exec_pathname);
- ui_out_text (uiout, "\" ");