Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Michael Snyder <msnyder@vmware.com>
To: Pedro Alves <pedro@codesourcery.com>
Cc: "gdb-patches@sourceware.org" <gdb-patches@sourceware.org>,
	  Hui Zhu <teawater@gmail.com>
Subject: Re: [RFA] Expand "info record"
Date: Tue, 20 Oct 2009 22:31:00 -0000	[thread overview]
Message-ID: <4ADE38DA.8040803@vmware.com> (raw)
In-Reply-To: <200910202154.04566.pedro@codesourcery.com>

[-- Attachment #1: Type: text/plain, Size: 1095 bytes --]

Pedro Alves wrote:
> On Tuesday 20 October 2009 20:44:16, Michael Snyder wrote:
>> +  unsigned long long insn_num;
> 
> ULONGEST
> 
>> +       (p != NULL) && (p->type != record_end);
> 
> Superfluous parens.
> 
>> +      printf_filtered (_("Lowest recorded instruction number is %llu.\n"),
>> +                      p->u.end.insn_num);
> 
> pulongest

OK to all.


>> +      /* Display instruction number for last instruction in the log.  */
>> +      printf_filtered (_("Highest recorded instruction number is %llu.\n"), 
>> +                      record_insn_count ? record_insn_count - 1 : 0);
> 
> Why the conditional subtraction?

Because I don't want it to say "-1".

> Given this post inc:
>> +  rec->u.end.insn_num = record_insn_count++;

No, the post inc implies that the count is actually one greater
than the last insn that used it.  Yes?

> The subtraction looks suspicious.
> 
> Could you add a comment to record_insn_num and
> record_insn_count's definitions explaining what they are and
> how they're different, if it doesn't become obvious?

Yep, done, see attached.

Thanks!




[-- Attachment #2: info2.txt --]
[-- Type: text/plain, Size: 4877 bytes --]

Index: record.c
===================================================================
RCS file: /cvs/src/src/gdb/record.c,v
retrieving revision 1.25
diff -u -p -b -w -r1.25 record.c
--- record.c	19 Oct 2009 09:51:41 -0000	1.25
+++ record.c	20 Oct 2009 22:19:19 -0000
@@ -71,6 +71,7 @@ struct record_reg_entry
 struct record_end_entry
 {
   enum target_signal sigval;
+  ULONGEST insn_num;
 };
 
 enum record_type
@@ -107,8 +108,13 @@ static struct record_entry *record_arch_
 
 /* 1 ask user. 0 auto delete the last struct record_entry.  */
 static int record_stop_at_limit = 1;
+/* Maximum allowed number of insns in execution log.  */
 static unsigned int record_insn_max_num = DEFAULT_RECORD_INSN_MAX_NUM;
+/* Actual count of insns presently in execution log.  */
 static int record_insn_num = 0;
+/* Count of insns logged so far (may be larger
+   than count of insns presently in execution log).  */
+static ULONGEST record_insn_count;
 
 /* The target_ops of process record.  */
 static struct target_ops record_ops;
@@ -279,7 +285,10 @@ record_list_release_following (struct re
     {
       rec = tmp->next;
       if (record_entry_release (tmp) == record_end)
+	{
 	record_insn_num--;
+	  record_insn_count--;
+	}
       tmp = rec;
     }
 }
@@ -308,7 +317,6 @@ record_list_release_first (void)
       /* tmp is now isolated, and can be deleted.  */
       if (record_entry_release (tmp) == record_end)
 	{
-	  record_insn_num--;
 	  break;	/* End loop at first record_end.  */
 	}
 
@@ -435,6 +443,7 @@ record_arch_list_add_end (void)
 
   rec = record_end_alloc ();
   rec->u.end.sigval = TARGET_SIGNAL_0;
+  rec->u.end.insn_num = record_insn_count++;
 
   record_arch_list_add (rec);
 
@@ -665,6 +674,7 @@ record_open (char *name, int from_tty)
 
   /* Reset */
   record_insn_num = 0;
+  record_insn_count = 0;
   record_list = &record_first;
   record_list->next = NULL;
 }
@@ -1362,8 +1372,8 @@ cmd_record_stop (char *args, int from_tt
   if (current_target.to_stratum == record_stratum)
     {
       unpush_target (&record_ops);
-      printf_unfiltered (_("Process record is stoped and all execution "
-                           "log is deleted.\n"));
+      printf_unfiltered (_("Process record is stopped and all execution "
+                           "logs are deleted.\n"));
     }
   else
     printf_unfiltered (_("Process record is not started.\n"));
@@ -1385,16 +1395,6 @@ set_record_insn_max_num (char *args, int
     }
 }
 
-/* Print the current index into the record log (number of insns recorded
-   so far).  */
-
-static void
-show_record_insn_number (char *ignore, int from_tty)
-{
-  printf_unfiltered (_("Record instruction number is %d.\n"),
-		     record_insn_num);
-}
-
 static struct cmd_list_element *record_cmdlist, *set_record_cmdlist,
 			       *show_record_cmdlist, *info_record_cmdlist;
 
@@ -1412,10 +1412,48 @@ show_record_command (char *args, int fro
   cmd_show_list (show_record_cmdlist, from_tty, "");
 }
 
+/* Display some statistics about the execution log.  */
+
 static void
 info_record_command (char *args, int from_tty)
 {
-  cmd_show_list (info_record_cmdlist, from_tty, "");
+  struct record_entry *p;
+
+  /* Find entry for first actual instruction in the log.  */
+  for (p = record_first.next;
+       p != NULL && p->type != record_end;
+       p = p->next)
+    ;
+
+  /* Do we have a log at all?  */
+  if (p != NULL && p->type == record_end)
+    {
+      /* Display instruction number for first instruction in the log.  */
+      printf_filtered (_("Lowest recorded instruction number is %s.\n"),
+		       pulongest (p->u.end.insn_num));
+
+      /* If we are not at the end of the log, display where we are.  */
+      if (record_list->next != NULL && record_list->type == record_end)
+	printf_filtered (_("Current instruction number is %s.\n"),
+			 pulongest (record_list->u.end.insn_num));
+
+      /* Display instruction number for last instruction in the log.  */
+      printf_filtered (_("Highest recorded instruction number is %s.\n"), 
+		       record_insn_count ? 
+		       pulongest (record_insn_count - 1) : "0");
+
+      /* Display log count.  */
+      printf_filtered (_("Log contains %d instructions.\n"), record_insn_num);
+    }
+  else
+    {
+      printf_filtered (_("Process record is not active, or "
+			 "there is no log yet.\n"));
+    }
+
+  /* Display max log size.  */
+  printf_filtered (_("Max logged instructions is %d.\n"),
+		   record_insn_max_num);
 }
 
 void
@@ -1485,7 +1523,4 @@ Set the maximum number of instructions t
 record/replay buffer.  Zero means unlimited.  Default is 200000."),
 			    set_record_insn_max_num,
 			    NULL, &set_record_cmdlist, &show_record_cmdlist);
-  add_cmd ("insn-number", class_obscure, show_record_insn_number,
-	   _("Show the current number of instructions in the "
-	     "record/replay buffer."), &info_record_cmdlist);
 }

  reply	other threads:[~2009-10-20 22:31 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-10-12 16:32 Michael Snyder
2009-10-12 17:06 ` Tom Tromey
2009-10-12 17:15   ` Michael Snyder
2009-10-12 18:10     ` Tom Tromey
2009-10-13 11:20       ` Pedro Alves
2009-10-13  6:03 ` Hui Zhu
2009-10-13 17:21   ` Michael Snyder
2009-10-13 18:01     ` Michael Snyder
2009-10-20 19:50       ` Michael Snyder
2009-10-20 20:54         ` Pedro Alves
2009-10-20 22:31           ` Michael Snyder [this message]
2009-10-21  0:22             ` Pedro Alves
2009-10-21  1:38               ` Michael Snyder
2009-10-21  3:09                 ` Hui Zhu
2009-10-21 15:24                   ` Michael Snyder
2009-10-22  2:30                     ` Hui Zhu
2009-10-21 10:54                 ` Pedro Alves
2009-10-21 15:23                   ` Michael Snyder
2009-10-22 13:08                     ` Pedro Alves

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=4ADE38DA.8040803@vmware.com \
    --to=msnyder@vmware.com \
    --cc=gdb-patches@sourceware.org \
    --cc=pedro@codesourcery.com \
    --cc=teawater@gmail.com \
    /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