aboutsummaryrefslogtreecommitdiff
path: root/gdb
diff options
context:
space:
mode:
authorPedro Alves <palves@redhat.com>2017-10-30 11:41:34 +0000
committerPedro Alves <palves@redhat.com>2017-10-30 11:41:34 +0000
commit1b81856f5b00e7ba860e4de2f3a426f342327165 (patch)
tree966829f77a9aff1f1aa980f4e8652e2fcfec01a8 /gdb
parent31b833b3eab69d91df67edc3e9a21792abc3f93e (diff)
downloadgdb-1b81856f5b00e7ba860e4de2f3a426f342327165.zip
gdb-1b81856f5b00e7ba860e4de2f3a426f342327165.tar.gz
gdb-1b81856f5b00e7ba860e4de2f3a426f342327165.tar.bz2
remote.c, QCatchSyscalls: Build std::string instead of unique_xmalloc_ptr
Simplify the code a little bit using std::string + string_appendf. gdb/ChangeLog: 2017-10-30 Pedro Alves <palves@redhat.com> Simon Marchi <simon.marchi@ericsson.com> * remote.c (remote_set_syscall_catchpoint): Build a std::string instead of a gdb::unique_xmalloc_ptr, using string_appendf.
Diffstat (limited to 'gdb')
-rw-r--r--gdb/ChangeLog6
-rw-r--r--gdb/remote.c22
2 files changed, 13 insertions, 15 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index f3abf16..2855f4d 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,4 +1,10 @@
2017-10-30 Pedro Alves <palves@redhat.com>
+ Simon Marchi <simon.marchi@ericsson.com>
+
+ * remote.c (remote_set_syscall_catchpoint): Build a std::string
+ instead of a gdb::unique_xmalloc_ptr, using string_appendf.
+
+2017-10-30 Pedro Alves <palves@redhat.com>
* common/common-utils.c (string_appendf, string_vappendf): New
functions.
diff --git a/gdb/remote.c b/gdb/remote.c
index ed2a9ec..57dbd1e 100644
--- a/gdb/remote.c
+++ b/gdb/remote.c
@@ -2081,40 +2081,32 @@ remote_set_syscall_catchpoint (struct target_ops *self,
pid, needed, any_count, n_sysno);
}
- gdb::unique_xmalloc_ptr<char> built_packet;
+ std::string built_packet;
if (needed)
{
/* Prepare a packet with the sysno list, assuming max 8+1
characters for a sysno. If the resulting packet size is too
big, fallback on the non-selective packet. */
const int maxpktsz = strlen ("QCatchSyscalls:1") + n_sysno * 9 + 1;
-
- built_packet.reset ((char *) xmalloc (maxpktsz));
- strcpy (built_packet.get (), "QCatchSyscalls:1");
+ built_packet.reserve (maxpktsz);
+ built_packet = "QCatchSyscalls:1";
if (!any_count)
{
- int i;
- char *p;
-
- p = built_packet.get ();
- p += strlen (p);
-
/* Add in catch_packet each syscall to be caught (table[i] != 0). */
- for (i = 0; i < table_size; i++)
+ for (int i = 0; i < table_size; i++)
{
if (table[i] != 0)
- p += xsnprintf (p, built_packet.get () + maxpktsz - p,
- ";%x", i);
+ string_appendf (built_packet, ";%x", i);
}
}
- if (strlen (built_packet.get ()) > get_remote_packet_size ())
+ if (built_packet.size () > get_remote_packet_size ())
{
/* catch_packet too big. Fallback to less efficient
non selective mode, with GDB doing the filtering. */
catch_packet = "QCatchSyscalls:1";
}
else
- catch_packet = built_packet.get ();
+ catch_packet = built_packet.c_str ();
}
else
catch_packet = "QCatchSyscalls:0";