aboutsummaryrefslogtreecommitdiff
path: root/gdb/break-catch-syscall.c
diff options
context:
space:
mode:
authorTom Tromey <tom@tromey.com>2021-10-03 08:16:50 -0600
committerTom Tromey <tom@tromey.com>2021-10-20 11:00:32 -0600
commit570bc7936f5aa9299eee20ba3e170b44efd6c98f (patch)
treec28e8b76f3eec0f0b2984d9a286b1df9d9f1e823 /gdb/break-catch-syscall.c
parent6f781ee30062c822cf6475cfa070c6e7cf770de4 (diff)
downloadgdb-570bc7936f5aa9299eee20ba3e170b44efd6c98f.zip
gdb-570bc7936f5aa9299eee20ba3e170b44efd6c98f.tar.gz
gdb-570bc7936f5aa9299eee20ba3e170b44efd6c98f.tar.bz2
Use std::string in print_one_catch_syscall
This changes print_one_catch_syscall to use std::string, removing a bit of manual memory management.
Diffstat (limited to 'gdb/break-catch-syscall.c')
-rw-r--r--gdb/break-catch-syscall.c22
1 files changed, 9 insertions, 13 deletions
diff --git a/gdb/break-catch-syscall.c b/gdb/break-catch-syscall.c
index 32736f0..3d3b275 100644
--- a/gdb/break-catch-syscall.c
+++ b/gdb/break-catch-syscall.c
@@ -250,28 +250,24 @@ print_one_catch_syscall (struct breakpoint *b,
if (!c->syscalls_to_be_caught.empty ())
{
- char *text = xstrprintf ("%s", "");
+ std::string text;
+ bool first = true;
for (int iter : c->syscalls_to_be_caught)
{
- char *previous_text = text;
struct syscall s;
get_syscall_by_number (gdbarch, iter, &s);
+ if (!first)
+ text += ", ";
+ first = false;
+
if (s.name != NULL)
- text = xstrprintf ("%s%s, ", text, s.name);
+ text += s.name;
else
- text = xstrprintf ("%s%d, ", text, iter);
-
- /* We have to xfree previous_text because xstrprintf dynamically
- allocates new space for text on every call. */
- xfree (previous_text);
+ text += std::to_string (iter);
}
- /* Remove the last comma. */
- text[strlen (text) - 2] = '\0';
- uiout->field_string ("what", text);
- /* xfree last text. */
- xfree (text);
+ uiout->field_string ("what", text.c_str ());
}
else
uiout->field_string ("what", "<any syscall>", metadata_style.style ());