/* Tracepoint code for remote server for GDB.
- Copyright (C) 2009-2021 Free Software Foundation, Inc.
+ Copyright (C) 2009-2022 Free Software Foundation, Inc.
This file is part of GDB.
va_end (ap);
}
-#define trace_debug_1(level, fmt, args...) \
+#define trace_debug(fmt, args...) \
do { \
- if (level <= debug_threads) \
+ if (debug_threads) \
trace_vdebug ((fmt), ##args); \
} while (0)
#else
-#define trace_debug_1(level, fmt, args...) \
+#define trace_debug(fmt, args...) \
do { \
- if (level <= debug_threads) \
- { \
- debug_printf ((fmt), ##args); \
- debug_printf ("\n"); \
- } \
+ threads_debug_printf ((fmt), ##args); \
} while (0)
#endif
-#define trace_debug(FMT, args...) \
- trace_debug_1 (1, FMT, ##args)
-
/* Prefix exported symbols, for good citizenship. All the symbols
that need exporting are defined in this module. Note that all
these symbols must be tagged with IP_AGENT_EXPORT_*. */
if (look_up_one_symbol (symbol_list[i].name, addrp, 1) == 0)
{
- if (debug_threads)
- debug_printf ("symbol `%s' not found\n", symbol_list[i].name);
+ threads_debug_printf ("symbol `%s' not found", symbol_list[i].name);
return;
}
}
if (tp->type == fast_tracepoint || tp->type == static_tracepoint)
{
- int ret;
int offset = offsetof (struct tracepoint, enabled);
CORE_ADDR obj_addr = tp->obj_addr_on_target + offset;
- ret = prepare_to_access_memory ();
- if (ret)
- {
- trace_debug ("Failed to temporarily stop inferior threads");
- write_enn (own_buf);
- return;
- }
-
- ret = write_inferior_int8 (obj_addr, enable);
- done_accessing_memory ();
-
+ int ret = write_inferior_int8 (obj_addr, enable);
if (ret)
{
trace_debug ("Cannot write enabled flag into "
if (!maybe_write_ipa_not_loaded (buf))
{
- struct thread_info *saved_thread;
-
- saved_thread = current_thread;
+ scoped_restore_current_thread restore_thread;
/* Find any thread which belongs to process PID. */
- current_thread = find_any_thread_of_pid (pid);
+ switch_to_thread (find_any_thread_of_pid (pid));
strcpy (buf, "close");
run_inferior_command (buf, strlen (buf) + 1);
-
- current_thread = saved_thread;
}
}
ipa_expr_eval_result,
paddress (ipa_error_tracepoint));
- if (debug_threads)
- {
- if (ipa_trace_buffer_is_full)
- trace_debug ("lib stopped due to full buffer.");
- if (ipa_stopping_tracepoint)
- trace_debug ("lib stopped due to tpoint");
- if (ipa_error_tracepoint)
- trace_debug ("lib stopped due to error");
- }
+ if (ipa_trace_buffer_is_full)
+ trace_debug ("lib stopped due to full buffer.");
+
+ if (ipa_stopping_tracepoint)
+ trace_debug ("lib stopped due to tpoint");
+
+ if (ipa_error_tracepoint)
+ trace_debug ("lib stopped due to error");
if (ipa_stopping_tracepoint != 0)
{
addr.sun_family = AF_UNIX;
- strncpy (addr.sun_path, name, UNIX_PATH_MAX);
- addr.sun_path[UNIX_PATH_MAX - 1] = '\0';
+ if (strlen (name) >= ARRAY_SIZE (addr.sun_path))
+ {
+ warning ("socket name too long for sockaddr_un::sun_path field: %s", name);
+ return -1;
+ }
+
+ strcpy (addr.sun_path, name);
result = access (name, F_OK);
if (result == 0)
{
int result, fd;
- result = xsnprintf (agent_socket_name, UNIX_PATH_MAX, "%s/gdb_ust%d",
- SOCK_DIR, getpid ());
+ result = snprintf (agent_socket_name, UNIX_PATH_MAX, "%s/gdb_ust%d",
+ SOCK_DIR, getpid ());
if (result >= UNIX_PATH_MAX)
{
trace_debug ("string overflow allocating socket name");