aboutsummaryrefslogtreecommitdiff
path: root/gdb/nat/linux-waitpid.c
diff options
context:
space:
mode:
authorSimon Marchi <simon.marchi@polymtl.ca>2021-05-08 21:06:41 -0400
committerSimon Marchi <simon.marchi@polymtl.ca>2021-05-08 21:07:20 -0400
commit8d06918ff58452cb17d1bdfbde7187f45933f42e (patch)
treeb265047ba289878cb96ae446b8451a87b16a1c1f /gdb/nat/linux-waitpid.c
parent550e9289ab4f7ec1092a9c0ee202bbe0ba7fb9f5 (diff)
downloadgdb-8d06918ff58452cb17d1bdfbde7187f45933f42e.zip
gdb-8d06918ff58452cb17d1bdfbde7187f45933f42e.tar.gz
gdb-8d06918ff58452cb17d1bdfbde7187f45933f42e.tar.bz2
gdb, gdbserver: make status_to_str return std::string
Instead of using a static buffer. This is safer, and we don't really mind about any extra dynamic allocation here, since it's only used for debug purposes. gdb/ChangeLog: * 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. gdbserver/ChangeLog: * linux-low.cc (linux_process_target::wait_for_event_filtered): Adjust to status_to_str returning std::string. Change-Id: Ia8aead70270438a5690f243e6faafff6c38ff757
Diffstat (limited to 'gdb/nat/linux-waitpid.c')
-rw-r--r--gdb/nat/linux-waitpid.c23
1 files changed, 9 insertions, 14 deletions
diff --git a/gdb/nat/linux-waitpid.c b/gdb/nat/linux-waitpid.c
index 2d4c8eb..f205df7 100644
--- a/gdb/nat/linux-waitpid.c
+++ b/gdb/nat/linux-waitpid.c
@@ -24,30 +24,25 @@
#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. */