Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Guinevere Larsen <guinevere@redhat.com>
To: gdb-patches@sourceware.org
Cc: Guinevere Larsen <guinevere@redhat.com>,
	Thiago Jung Bauermann <thiago.bauermann@linaro.org>,
	Christina Schimpe <christina.schimpe@intel.com>
Subject: [PATCH v5 3/8] gdb/record: remove record_full_insn_num
Date: Mon, 15 Jun 2026 13:14:55 -0300	[thread overview]
Message-ID: <20260615161500.34181-4-guinevere@redhat.com> (raw)
In-Reply-To: <20260615161500.34181-1-guinevere@redhat.com>

Now that record_full_list uses a deque, we don't need a variable to
track the amount of items recorded, so it is just dropped.

Reviewed-by: Thiago Jung Bauermann <thiago.bauermann@linaro.org>
Reviewed-By: Christina Schimpe <christina.schimpe@intel.com>
---
 gdb/record-full.c | 41 ++++++++++++-----------------------------
 1 file changed, 12 insertions(+), 29 deletions(-)

diff --git a/gdb/record-full.c b/gdb/record-full.c
index c2f18e85ca4..0f885f2315a 100644
--- a/gdb/record-full.c
+++ b/gdb/record-full.c
@@ -193,8 +193,6 @@ static bool record_full_stop_at_limit = true;
 /* Maximum allowed number of insns in execution log.  */
 static unsigned int record_full_insn_max_num
 	= DEFAULT_RECORD_FULL_INSN_MAX_NUM;
-/* Actual count of insns presently in execution log.  */
-static unsigned int record_full_insn_num = 0;
 /* Count of insns logged so far (may be larger
    than count of insns presently in execution log).  */
 static ULONGEST record_full_insn_count;
@@ -464,7 +462,6 @@ record_full_entry_cleanup (record_full_entry rec)
 static void
 record_full_reset_history ()
 {
-  record_full_insn_num = 0;
   record_full_insn_count = 0;
   record_full_next_insn = 0;
 
@@ -511,9 +508,7 @@ record_full_save_instruction ()
 }
 
 /* Delete the first instruction from the beginning of the log, to make
-   room for adding a new instruction at the end of the log.
-
-   Note -- this function does not modify record_full_insn_num.  */
+   room for adding a new instruction at the end of the log.  */
 
 static void
 record_full_list_release_first (void)
@@ -613,7 +608,7 @@ record_full_arch_list_add_mem (CORE_ADDR addr, int len)
 static void
 record_full_check_insn_num (void)
 {
-  if (record_full_insn_num == record_full_insn_max_num)
+  if (record_full_list.size () == record_full_insn_max_num)
     {
       /* Ask user what to do.  */
       if (record_full_stop_at_limit)
@@ -695,10 +690,8 @@ record_full_message (struct regcache *regcache, enum gdb_signal signal)
 
   record_full_save_instruction ();
 
-  if (record_full_insn_num == record_full_insn_max_num)
+  if (record_full_list.size () == record_full_insn_max_num)
     record_full_list_release_first ();
-  else
-    record_full_insn_num++;
 }
 
 static bool
@@ -1478,10 +1471,8 @@ record_full_registers_change (struct regcache *regcache, int regnum)
     }
   record_full_save_instruction ();
 
-  if (record_full_insn_num == record_full_insn_max_num)
+  if (record_full_list.size () == record_full_insn_max_num)
     record_full_list_release_first ();
-  else
-    record_full_insn_num++;
 }
 
 /* "store_registers" method for process record target.  */
@@ -1582,10 +1573,8 @@ record_full_target::xfer_partial (enum target_object object,
 	}
       record_full_save_instruction ();
 
-      if (record_full_insn_num == record_full_insn_max_num)
+      if (record_full_list.size () == record_full_insn_max_num)
 	record_full_list_release_first ();
-      else
-	record_full_insn_num++;
     }
 
   return this->beneath ()->xfer_partial (object, annex, readbuf, writebuf,
@@ -1823,8 +1812,8 @@ record_full_base_target::info_record ()
 		  pulongest (record_full_insn_count));
 
       /* Display log count.  */
-      gdb_printf (_("Log contains %u instructions.\n"),
-		  record_full_insn_num);
+      gdb_printf (_("Log contains %lu instructions.\n"),
+		  (unsigned long int) record_full_list.size ());
     }
   else
     gdb_printf (_("No instructions have been logged.\n"));
@@ -2305,8 +2294,6 @@ record_full_restore (struct bfd &cbfd)
 		"RECORD_FULL_FILE_MAGIC (0x%s)\n",
 		phex_nz (netorder32 (magic), 4));
 
-  record_full_insn_num = 0;
-
   try
     {
       while (bfd_offset < osec_size)
@@ -2346,9 +2333,9 @@ record_full_restore (struct bfd &cbfd)
     }
 
   /* Update record_full_insn_max_num.  */
-  if (record_full_insn_num > record_full_insn_max_num)
+  if (record_full_list.size () > record_full_insn_max_num)
     {
-      record_full_insn_max_num = record_full_insn_num;
+      record_full_insn_max_num = record_full_list.size ();
       warning (_("Auto increase record/replay buffer limit to %u."),
 	       record_full_insn_max_num);
     }
@@ -2607,14 +2594,10 @@ static void
 set_record_full_insn_max_num (const char *args, int from_tty,
 			      struct cmd_list_element *c)
 {
-  if (record_full_insn_num > record_full_insn_max_num)
+  if (record_full_list.size () > record_full_insn_max_num)
     {
-      /* Count down record_full_insn_num while releasing records from list.  */
-      while (record_full_insn_num > record_full_insn_max_num)
-       {
-	 record_full_list_release_first ();
-	 record_full_insn_num--;
-       }
+      while (record_full_list.size () > record_full_insn_max_num)
+	record_full_list_release_first ();
     }
 }
 
-- 
2.54.0


  parent reply	other threads:[~2026-06-15 16:16 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-15 16:14 [PATCH v5 0/8] refactor the internals of record-full Guinevere Larsen
2026-06-15 16:14 ` [PATCH v5 1/8] gdb/record: Refactor record history Guinevere Larsen
2026-06-15 16:14 ` [PATCH v5 2/8] gdb/record: factor out reading and writing the execution log to corefile Guinevere Larsen
2026-06-15 16:14 ` Guinevere Larsen [this message]
2026-06-15 16:14 ` [PATCH v5 4/8] gdb/record: c++ify internal structures of record-full.c Guinevere Larsen
2026-06-15 16:14 ` [PATCH v5 5/8] gdb/record: make record_full_history more c++-like Guinevere Larsen
2026-06-15 16:14 ` [PATCH v5 6/8] gdb/record: extract the PC to record_full_instruction Guinevere Larsen
2026-06-15 16:14 ` [PATCH v5 7/8] gdb/record: Define new version of the record-save section Guinevere Larsen
2026-06-15 16:15 ` [PATCH v5 8/8] gdb/record: rename record_full_list to record_full_log Guinevere Larsen
2026-07-03 13:37 ` [PATCH v5 0/8] refactor the internals of record-full Guinevere Larsen

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=20260615161500.34181-4-guinevere@redhat.com \
    --to=guinevere@redhat.com \
    --cc=christina.schimpe@intel.com \
    --cc=gdb-patches@sourceware.org \
    --cc=thiago.bauermann@linaro.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