public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Tom Tromey <tom@tromey.com>
To: gdb-patches@sourceware.org
Cc: Tom Tromey <tom@tromey.com>
Subject: [PATCH 1/7] Remove struct buffer from tracefile-tfile.c
Date: Fri, 16 Dec 2022 16:50:11 -0700	[thread overview]
Message-ID: <20221216235017.3722833-2-tom@tromey.com> (raw)
In-Reply-To: <20221216235017.3722833-1-tom@tromey.com>

This changes tracefile-tfile.c to use std::string rather than struct
buffer.
---
 gdb/tracefile-tfile.c | 21 ++++++++++-----------
 1 file changed, 10 insertions(+), 11 deletions(-)

diff --git a/gdb/tracefile-tfile.c b/gdb/tracefile-tfile.c
index 3266f357a27..831c510648c 100644
--- a/gdb/tracefile-tfile.c
+++ b/gdb/tracefile-tfile.c
@@ -31,7 +31,6 @@
 #include "remote.h"
 #include "xml-tdesc.h"
 #include "target-descriptions.h"
-#include "gdbsupport/buffer.h"
 #include "gdbsupport/pathstuff.h"
 #include <algorithm>
 
@@ -425,7 +424,7 @@ static off_t trace_frames_offset;
 static off_t cur_offset;
 static int cur_data_size;
 int trace_regblock_size;
-static struct buffer trace_tdesc;
+static std::string trace_tdesc;
 
 static void tfile_append_tdesc_line (const char *line);
 static void tfile_interp_line (char *line,
@@ -487,7 +486,7 @@ tfile_target_open (const char *arg, int from_tty)
   trace_fd = scratch_chan;
 
   /* Make sure this is clear.  */
-  buffer_free (&trace_tdesc);
+  trace_tdesc.clear ();
 
   bytes = 0;
   /* Read the file header and test for validity.  */
@@ -626,7 +625,7 @@ tfile_target::close ()
   trace_fd = -1;
   xfree (trace_filename);
   trace_filename = NULL;
-  buffer_free (&trace_tdesc);
+  trace_tdesc.clear ();
 
   trace_reset_local_state ();
 }
@@ -922,16 +921,16 @@ tfile_xfer_partial_features (const char *annex,
   if (readbuf == NULL)
     error (_("tfile_xfer_partial: tdesc is read-only"));
 
-  if (trace_tdesc.used_size == 0)
+  if (trace_tdesc.empty ())
     return TARGET_XFER_E_IO;
 
-  if (offset >= trace_tdesc.used_size)
+  if (offset >= trace_tdesc.length ())
     return TARGET_XFER_EOF;
 
-  if (len > trace_tdesc.used_size - offset)
-    len = trace_tdesc.used_size - offset;
+  if (len > trace_tdesc.length () - offset)
+    len = trace_tdesc.length () - offset;
 
-  memcpy (readbuf, trace_tdesc.buffer + offset, len);
+  memcpy (readbuf, trace_tdesc.c_str () + offset, len);
   *xfered_len = len;
 
   return TARGET_XFER_OK;
@@ -1128,8 +1127,8 @@ tfile_target::traceframe_info ()
 static void
 tfile_append_tdesc_line (const char *line)
 {
-  buffer_grow_str (&trace_tdesc, line);
-  buffer_grow_str (&trace_tdesc, "\n");
+  trace_tdesc += line;
+  trace_tdesc += "\n";
 }
 
 void _initialize_tracefile_tfile ();
-- 
2.38.1


  reply	other threads:[~2022-12-16 23:50 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-16 23:50 [PATCH 0/7] Remove struct buffer Tom Tromey
2022-12-16 23:50 ` Tom Tromey [this message]
2022-12-16 23:50 ` [PATCH 2/7] Don't use struct buffer in handle_qxfer_traceframe_info Tom Tromey
2022-12-16 23:50 ` [PATCH 3/7] Don't use struct buffer in handle_qxfer_btrace Tom Tromey
2022-12-16 23:50 ` [PATCH 4/7] Don't use struct buffer in handle_qxfer_threads Tom Tromey
2022-12-16 23:50 ` [PATCH 5/7] Don't use struct buffer in event-top.c Tom Tromey
2022-12-16 23:50 ` [PATCH 6/7] Don't use struct buffer in top.c Tom Tromey
2022-12-16 23:50 ` [PATCH 7/7] Remove struct buffer Tom Tromey
2023-02-24 19:04 ` [PATCH 0/7] " Tom Tromey

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20221216235017.3722833-2-tom@tromey.com \
    --to=tom@tromey.com \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).