+2021-05-08 Simon Marchi <simon.marchi@polymtl.ca>
+
+ * nat/linux-waitpid.c (status_to_str): Return std::string.
+ * nat/linux-waitpid.h (status_to_str): Likewise.
+ * linux-nat.c (linux_nat_post_attach_wait): Adjust.
+ (linux_nat_target::attach): Adjust.
+ (linux_handle_extended_wait): Adjust.
+ (wait_lwp): Adjust.
+ (stop_wait_callback): Adjust.
+ (linux_nat_filter_event): Adjust.
+ (linux_nat_wait_1): Adjust.
+ * nat/linux-waitpid.c (status_to_str): Adjust.
+ * nat/linux-waitpid.h (status_to_str): Adjust.
+
2021-05-08 Simon Marchi <simon.marchi@polymtl.ca>
* infrun.h (infrun_debug_printf): Add missing space.
{
/* The pid we tried to attach has apparently just exited. */
linux_nat_debug_printf ("Failed to stop %d: %s", pid,
- status_to_str (status));
+ status_to_str (status).c_str ());
return status;
}
{
*signalled = 1;
linux_nat_debug_printf ("Received %s after attaching",
- status_to_str (status));
+ status_to_str (status).c_str ());
}
return status;
/* Save the wait status to report later. */
lp->resumed = 1;
linux_nat_debug_printf ("waitpid %ld, saving status %s",
- (long) lp->ptid.pid (), status_to_str (status));
+ (long) lp->ptid.pid (),
+ status_to_str (status).c_str ());
lp->status = status;
/* Save the wait status to report later. */
linux_nat_debug_printf
("waitpid of new LWP %ld, saving status %s",
- (long) new_lp->ptid.lwp (), status_to_str (status));
+ (long) new_lp->ptid.lwp (), status_to_str (status).c_str ());
new_lp->status = status;
}
else if (report_thread_events)
linux_nat_debug_printf ("waitpid %s received %s",
target_pid_to_str (lp->ptid).c_str (),
- status_to_str (status));
+ status_to_str (status).c_str ());
/* Check if the thread has exited. */
if (WIFEXITED (status) || WIFSIGNALED (status))
/* The thread was stopped with a signal other than SIGSTOP. */
linux_nat_debug_printf ("Pending event %s in %s",
- status_to_str ((int) status),
+ status_to_str ((int) status).c_str (),
target_pid_to_str (lp->ptid).c_str ());
/* Save the sigtrap event. */
if (WIFSTOPPED (status) && !lp)
{
linux_nat_debug_printf ("saving LWP %ld status %s in stopped_pids list",
- (long) lwpid, status_to_str (status));
+ (long) lwpid, status_to_str (status).c_str ());
add_to_pid_list (&stopped_pids, lwpid, status);
return;
}
if (lp != NULL)
{
linux_nat_debug_printf ("Using pending wait status %s for %s.",
- status_to_str (lp->status),
+ status_to_str (lp->status).c_str (),
target_pid_to_str (lp->ptid).c_str ());
}
if (lwpid > 0)
{
linux_nat_debug_printf ("waitpid %ld received %s",
- (long) lwpid, status_to_str (status));
+ (long) lwpid,
+ status_to_str (status).c_str ());
linux_nat_filter_event (lwpid, status);
/* Retry until nothing comes out of waitpid. A single
#include "gdbsupport/gdb_wait.h"
#include "gdbsupport/eintr.h"
-/* Convert wait status STATUS to a string. Used for printing debug
- messages only. */
+/* See linux-waitpid.h. */
-char *
+std::string
status_to_str (int status)
{
- static char buf[64];
-
if (WIFSTOPPED (status))
{
if (WSTOPSIG (status) == SYSCALL_SIGTRAP)
- snprintf (buf, sizeof (buf), "%s (stopped at syscall)",
- strsignal (SIGTRAP));
+ return string_printf ("%s (stopped at syscall)",
+ strsignal (SIGTRAP));
else
- snprintf (buf, sizeof (buf), "%s (stopped)",
- strsignal (WSTOPSIG (status)));
+ return string_printf ("%s (stopped)",
+ strsignal (WSTOPSIG (status)));
}
else if (WIFSIGNALED (status))
- snprintf (buf, sizeof (buf), "%s (terminated)",
- strsignal (WTERMSIG (status)));
+ return string_printf ("%s (terminated)",
+ strsignal (WTERMSIG (status)));
else
- snprintf (buf, sizeof (buf), "%d (exited)", WEXITSTATUS (status));
-
- return buf;
+ return string_printf ("%d (exited)", WEXITSTATUS (status));
}
/* See linux-waitpid.h. */