48 VEC(
int) *syscalls_to_be_caught;
59 VEC_free (
int, c->syscalls_to_be_caught);
66 struct catch_syscall_inferior_data
76 VEC(
int) *syscalls_counts;
80 int total_syscalls_count;
83 static struct catch_syscall_inferior_data*
86 struct catch_syscall_inferior_data *inf_data;
88 inf_data = inferior_data (inf, catch_syscall_inferior_data);
91 inf_data = XCNEW (
struct catch_syscall_inferior_data);
92 set_inferior_data (inf, catch_syscall_inferior_data, inf_data);
113 struct catch_syscall_inferior_data *inf_data
116 ++inf_data->total_syscalls_count;
117 if (!c->syscalls_to_be_caught)
124 VEC_iterate (
int, c->syscalls_to_be_caught, i, iter);
129 if (iter >=
VEC_length (
int, inf_data->syscalls_counts))
131 int old_size =
VEC_length (
int, inf_data->syscalls_counts);
132 uintptr_t vec_addr_offset
133 = old_size * ((uintptr_t)
sizeof (
int));
137 inf_data->syscalls_counts)
139 memset ((
void *) vec_addr, 0,
140 (iter + 1 - old_size) *
sizeof (
int));
142 elem =
VEC_index (
int, inf_data->syscalls_counts, iter);
143 VEC_replace (
int, inf_data->syscalls_counts, iter, ++elem);
148 inf_data->total_syscalls_count != 0,
151 inf_data->syscalls_counts),
153 inf_data->syscalls_counts));
164 struct catch_syscall_inferior_data *inf_data
167 --inf_data->total_syscalls_count;
168 if (!c->syscalls_to_be_caught)
175 VEC_iterate (
int, c->syscalls_to_be_caught, i, iter);
179 if (iter >=
VEC_length (
int, inf_data->syscalls_counts))
182 elem =
VEC_index (
int, inf_data->syscalls_counts, iter);
183 VEC_replace (
int, inf_data->syscalls_counts, iter, --elem);
188 inf_data->total_syscalls_count != 0,
191 inf_data->syscalls_counts),
193 inf_data->syscalls_counts));
207 int syscall_number = 0;
218 if (c->syscalls_to_be_caught)
223 VEC_iterate (
int, c->syscalls_to_be_caught, i, iter);
225 if (syscall_number == iter)
306 if (c->syscalls_to_be_caught
307 &&
VEC_length (
int, c->syscalls_to_be_caught) > 1)
312 if (c->syscalls_to_be_caught)
318 VEC_iterate (
int, c->syscalls_to_be_caught, i, iter);
336 text[strlen (text) - 2] =
'\0';
356 if (c->syscalls_to_be_caught)
360 if (
VEC_length (
int, c->syscalls_to_be_caught) > 1)
366 VEC_iterate (
int, c->syscalls_to_be_caught, i, iter);
395 if (c->syscalls_to_be_caught)
400 VEC_iterate (
int, c->syscalls_to_be_caught, i, iter);
436 c->syscalls_to_be_caught = filter;
444 catch_syscall_split_args (
char *arg)
446 VEC(
int) *result = NULL;
452 int i, syscall_number;
460 for (i = 0; i < 127 && arg[i] && !isspace (arg[i]); ++i)
461 cur_name[i] = arg[i];
466 syscall_number = (
int) strtol (cur_name, &endptr, 0);
479 error (
_(
"Unknown syscall name '%s'."), cur_name);
503 error (
_(
"The feature 'catch syscall' is not supported on \
504 this architecture yet."));
523 filter = catch_syscall_split_args (arg);
548 struct catch_syscall_inferior_data *inf_data
551 return inf_data->total_syscalls_count != 0;
562 int syscall_number = (
int) (uintptr_t) data;
568 if (c->syscalls_to_be_caught)
572 VEC_iterate (
int, c->syscalls_to_be_caught, i, iter);
574 if (syscall_number == iter)
588 (
void *) (uintptr_t) syscall_number);
596 const char *text,
const char *
word)
600 = (list == NULL) ? NULL : complete_on_enum (list, word, word);
609 struct catch_syscall_inferior_data *inf_data
612 inf_data->total_syscalls_count = 0;
614 VEC_free (
int, inf_data->syscalls_counts);
645 catch_syscall_inferior_data
646 = register_inferior_data_with_cleanup (NULL,
650 Catch system calls by their names and/or numbers.\n\
651 Arguments say which system calls to catch. If no arguments\n\
652 are given, every system call will be caught.\n\
653 Arguments, if given, should be one or more system call names\n\
654 (if your system supports that), or system call numbers."),
656 catch_syscall_completer,
void get_last_target_status(ptid_t *ptidp, struct target_waitstatus *status)
struct gdbarch * target_gdbarch(void)
void(* print_recreate)(struct breakpoint *, struct ui_file *fp)
int catch_syscall_enabled(void)
static struct breakpoint_ops catch_syscall_breakpoint_ops
void * get_cmd_context(struct cmd_list_element *cmd)
#define VEC_replace(T, V, I, O)
void ui_out_field_int(struct ui_out *uiout, const char *fldname, int value)
int gdbarch_get_syscall_number_p(struct gdbarch *gdbarch)
static void print_recreate_catch_syscall(struct breakpoint *b, struct ui_file *fp)
enum print_stop_action(* print_it)(struct bpstats *bs)
void annotate_field(int num)
static int remove_catch_syscall(struct bp_location *bl)
static int is_syscall_catchpoint_enabled(struct breakpoint *bp)
int ui_out_is_mi_like_p(struct ui_out *uiout)
void(* print_mention)(struct breakpoint *)
static void catch_syscall_command_1(char *arg, int from_tty, struct cmd_list_element *command)
int(* breakpoint_hit)(const struct bp_location *bl, struct address_space *aspace, CORE_ADDR bp_addr, const struct target_waitstatus *ws)
struct observer * observer_attach_inferior_exit(observer_inferior_exit_ftype *f)
#define VEC_safe_push(T, V, O)
void get_syscall_by_name(struct gdbarch *gdbarch, const char *syscall_name, struct syscall *s)
char * skip_spaces(char *chp)
#define VEC_safe_grow(T, V, I)
void add_catch_command(char *name, char *docstring, cmd_sfunc_ftype *sfunc, completer_ftype *completer, void *user_data_catch, void *user_data_tcatch)
void ui_out_text(struct ui_out *uiout, const char *string)
void printf_filtered(const char *format,...)
static void print_one_catch_syscall(struct breakpoint *b, struct bp_location **last_loc)
void get_syscall_by_number(struct gdbarch *gdbarch, int syscall_number, struct syscall *s)
static void initialize_syscall_catchpoint_ops(void)
int(* insert_location)(struct bp_location *)
static void dtor_catch_syscall(struct breakpoint *b)
static int insert_catch_syscall(struct bp_location *bl)
#define VEC_iterate(T, V, I, P)
static void create_syscall_event_catchpoint(int tempflag, VEC(int)*filter, const struct breakpoint_ops *ops)
static int breakpoint_hit_catch_syscall(const struct bp_location *bl, struct address_space *aspace, CORE_ADDR bp_addr, const struct target_waitstatus *ws)
void ui_out_field_skip(struct ui_out *uiout, const char *fldname)
void initialize_file_ftype(void)
struct bp_location * bp_location_at
void init_catchpoint(struct breakpoint *b, struct gdbarch *gdbarch, int tempflag, char *cond_string, const struct breakpoint_ops *ops)
void fprintf_unfiltered(struct ui_file *stream, const char *format,...)
struct cleanup * make_cleanup(make_cleanup_ftype *function, void *arg)
int catching_syscall_number(int syscall_number)
union target_waitstatus::@161 value
struct breakpoint * breakpoint_find_if(int(*func)(struct breakpoint *b, void *d), void *user_data)
#define VEC_index(T, V, I)
struct gdbarch * get_current_arch(void)
static int syscall_catchpoint_p(struct breakpoint *b)
static struct catch_syscall_inferior_data * get_catch_syscall_inferior_data(struct inferior *inf)
char * xstrprintf(const char *format,...)
static void print_mention_catch_syscall(struct breakpoint *b)
initialize_file_ftype _initialize_break_catch_syscall
int ptid_get_pid(ptid_t ptid)
void print_recreate_thread(struct breakpoint *b, struct ui_file *fp)
struct breakpoint * breakpoint_at
const char ** get_syscall_names(struct gdbarch *gdbarch)
const char const char int
void discard_cleanups(struct cleanup *old_chain)
static int catching_syscall_number_1(struct breakpoint *b, void *data)
void install_breakpoint(int internal, struct breakpoint *b, int update_gll)
static void clear_syscall_counts(struct inferior *inf)
const char * async_reason_lookup(enum async_reply_reason reason)
enum target_waitkind kind
void get_user_print_options(struct value_print_options *opts)
int(* remove_location)(struct bp_location *)
static void catch_syscall_inferior_data_cleanup(struct inferior *inf, void *arg)
#define VEC_address(T, V)
struct breakpoint_ops base_breakpoint_ops
struct inferior * current_inferior(void)
#define target_set_syscall_catchpoint(pid, needed, any_count, table_size, table)
void initialize_breakpoint_ops(void)
static enum print_stop_action print_it_catch_syscall(bpstat bs)
void(* dtor)(struct breakpoint *self)
void ui_out_field_string(struct ui_out *uiout, const char *fldname, const char *string)
void annotate_catchpoint(int num)
struct ui_out * current_uiout
enum enable_state enable_state
struct breakpoint * owner
void(* print_one)(struct breakpoint *, struct bp_location **)
void error(const char *fmt,...)
const char * bpdisp_text(enum bpdisp disp)
const struct breakpoint_ops * ops