This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[RFA] Resubmit process record and replay, 3/10


This patch add the process record and replay target.  This is the core
part of process record and replay.

2008-11-16  Hui Zhu  <teawater@gmail.com>

	Process record and replay target.

	* Makefile.in (record.c): New file.
	* record.c, record.h: New file.

 Makefile.in |    4
 b/record.c  | 1156 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 b/record.h  |   99 +++++
 3 files changed, 1257 insertions(+), 2 deletions(-)

Following is the diff with the previous patch:
@@ -1,6 +1,6 @@
 --- a/Makefile.in
 +++ b/Makefile.in
-@@ -657,7 +657,7 @@ SFILES = ada-exp.y ada-lang.c ada-typepr
+@@ -657,7 +657,7 @@
  	valarith.c valops.c valprint.c value.c varobj.c vec.c \
  	wrapper.c \
  	xml-tdesc.c xml-support.c \
@@ -9,7 +9,7 @@

  LINTFILES = $(SFILES) $(YYFILES) $(CONFIG_SRCS) init.c

-@@ -808,7 +808,7 @@ COMMON_OBS = $(DEPFILES) $(CONFIG_OBS) $
+@@ -808,7 +808,7 @@
  	solib.o solib-null.o \
  	prologue-value.o memory-map.o xml-support.o \
  	target-descriptions.o target-memory.o xml-tdesc.o xml-builtin.o \
@@ -18,9 +18,9 @@

  TSOBS = inflow.o

---- a/record.c
+--- a//dev/null
 +++ b/record.c
-@@ -0,0 +1,1143 @@
+@@ -0,0 +1,1156 @@
 +/* Process record and replay target for GDB, the GNU debugger.
 +
 +   Copyright (C) 2008 Free Software Foundation, Inc.
@@ -29,7 +29,7 @@
 +
 +   This program is free software; you can redistribute it and/or modify
 +   it under the terms of the GNU General Public License as published by
-+   the Free Software Foundation; either version 2 of the License, or
++   the Free Software Foundation; either version 3 of the License, or
 +   (at your option) any later version.
 +
 +   This program is distributed in the hope that it will be useful,
@@ -265,9 +265,12 @@
 +
 +  if (target_read_memory (addr, rec->u.mem.val, len))
 +    {
-+      fprintf_unfiltered (gdb_stdlog,
-+			  "Process record: read memory addr = 0x%s len = %d error.\n",
-+			  paddr_nz (addr), len);
++      if (record_debug)
++	{
++	  fprintf_unfiltered (gdb_stdlog,
++			      "Process record: error reading memory at addr = 0x%s len = %d.\n",
++			      paddr_nz (addr), len);
++	}
 +      xfree (rec->u.mem.val);
 +      xfree (rec);
 +      return (-1);
@@ -311,13 +314,13 @@
 +      gdb_assert (record_insn_num <= record_insn_max_num);
 +      if (record_insn_num == record_insn_max_num)
 +	{
-+	  /* Ask user how to do */
++	  /* Ask user what to do */
 +	  if (record_stop_at_limit)
 +	    {
 +	      int q;
 +	      if (set_terminal)
 +		target_terminal_ours ();
-+	      q = yquery (_("The record instruction number
(record-insn-number) is equal to record-insn-number-max.  Do you want
to close record/replay stop when record/replay buffer becomes
full(record-stop-at-limit) then auto delete first record_t?"));
++	      q = yquery (_("Do you want to auto delete previous execute
log entries when record/replay buffer becomes full
(record-stop-at-limit)?"));
 +	      if (set_terminal)
 +		target_terminal_inferior ();
 +	      if (q)
@@ -326,7 +329,7 @@
 +		}
 +	      else
 +		{
-+		  error (_("Process record: record stop the program."));
++		  error (_("Process record: inferior program stopped."));
 +		}
 +	    }
 +	}
@@ -363,9 +366,9 @@
 +  ret = gdbarch_process_record (gdbarch,
 +				regcache_read_pc (record_regcache));
 +  if (ret > 0)
-+    error (_("Process record pause the program."));
++    error (_("Process record: inferior program stopped."));
 +  if (ret < 0)
-+    error (_("Process record record message error."));
++    error (_("Process record: failed to record execution log."));
 +
 +  discard_cleanups (old_cleanups);
 +
@@ -417,7 +420,7 @@
 +    }
 +  if (target_async_permitted)
 +    {
-+      error (_("Process record target can't debug the GNU/Linux
inferior in asynchronous mode (linux-async)."));
++      error (_("Process record target can't debug inferior in
asynchronous mode (target-async)."));
 +    }
 +
 +  if (!gdbarch_process_record_p (current_gdbarch))
@@ -429,7 +432,7 @@
 +  if (RECORD_IS_USED)
 +    {
 +      if (!nquery
-+	  (_("Process record target already running, do you want delete the
old record log?")))
++	  (_("Process record target already running, do you want to delete
the old record log?")))
 +	{
 +	  return;
 +	}
@@ -554,10 +557,10 @@
 +      act.sa_flags = SA_RESTART;
 +      if (sigaction (SIGINT, &act, &old_act))
 +	{
-+	  perror_with_name (_("Process record: sigaction"));
++	  perror_with_name (_("Process record: sigaction failed"));
 +	}
 +      /* If GDB is in terminal_inferior, it will not get the signal.
-+         And in GDB replay mode, GDB don't need to in terminal_inferior
++         And in GDB replay mode, GDB doesn't need to in terminal_inferior
 +         because inferior will not executed.
 +         Then set it to terminal_ours to make GDB get the signal.  */
 +      target_terminal_ours ();
@@ -620,7 +623,7 @@
 +	      if (target_read_memory
 +		  (record_list->u.mem.addr, mem, record_list->u.mem.len))
 +		{
-+		  error (_("Process record: read memory addr = 0x%s len = %d error."),
++		  error (_("Process record: error reading memory at addr = 0x%s len = %d."),
 +			 paddr_nz (record_list->u.mem.addr),
 +			 record_list->u.mem.len);
 +		}
@@ -629,7 +632,7 @@
 +		   record_list->u.mem.len))
 +		{
 +		  error (_
-+			 ("Process record: write memory addr = 0x%s len = %d error."),
++			 ("Process record: error writing memory at addr = 0x%s len = %d."),
 +			 paddr_nz (record_list->u.mem.addr),
 +			 record_list->u.mem.len);
 +		}
@@ -657,7 +660,7 @@
 +	      if (first_record_end && execution_direction == EXEC_REVERSE)
 +		{
 +		  /* When reverse excute, the first record_end is the part of
-+		     current instruction. */
++		     current instruction.  */
 +		  first_record_end = 0;
 +		}
 +	      else
@@ -723,7 +726,7 @@
 +
 +      if (sigaction (SIGALRM, &old_act, NULL))
 +	{
-+	  perror_with_name (_("Process record: sigaction"));
++	  perror_with_name (_("Process record: sigaction failed"));
 +	}
 +
 +replay_out:
@@ -754,7 +757,7 @@
 +}
 +
 +static void
-+record_detach (char *args, int from_tty)
++record_detach (struct target_ops *ops, char *args, int from_tty)
 +{
 +  if (record_debug)
 +    {
@@ -765,7 +768,7 @@
 +}
 +
 +static void
-+record_mourn_inferior (void)
++record_mourn_inferior (struct target_ops *ops)
 +{
 +  if (record_debug)
 +    {
@@ -807,7 +810,7 @@
 +	  if (record_arch_list_add_reg (i))
 +	    {
 +	      record_list_release (record_arch_list_tail);
-+	      error (_("Process record: record message error."));
++	      error (_("Process record: failed to record execution log."));
 +	    }
 +	}
 +    }
@@ -816,13 +819,13 @@
 +      if (record_arch_list_add_reg (regnum))
 +	{
 +	  record_list_release (record_arch_list_tail);
-+	  error (_("Process record: record message error."));
++	  error (_("Process record: failed to record execution log."));
 +	}
 +    }
 +  if (record_arch_list_add_end (0))
 +    {
 +      record_list_release (record_arch_list_tail);
-+      error (_("Process record: record message error."));
++      error (_("Process record: failed to record execution log."));
 +    }
 +  record_list->next = record_arch_list_head;
 +  record_arch_list_head->prev = record_list;
@@ -853,13 +856,13 @@
 +	    {
 +	      n =
 +		nquery (_
-+			("Becuse GDB is in replay mode, changing the value of a register
will destroy the record from this point forward. Change all
register?"));
++			("Becuse GDB is in replay mode, changing the value of a register
will make the execute log unusable from this point onward.  Change all
register?"));
 +	    }
 +	  else
 +	    {
 +	      n =
 +		nquery (_
-+			("Becuse GDB is in replay mode, changing the value of a register
will destroy the record from this point forward. Change register
%s?"),
++			("Becuse GDB is in replay mode, changing the value of a register
will make the execute log unusable from this point onward.  Change
register %s?"),
 +			gdbarch_register_name (get_regcache_arch (regcache),
 +					       regno));
 +	    }
@@ -867,7 +870,7 @@
 +	  if (!n)
 +	    {
 +	      /* Invalidate the value of regcache that set in function
-+	         "regcache_raw_write". */
++	         "regcache_raw_write".  */
 +	      if (regno < 0)
 +		{
 +		  int i;
@@ -883,7 +886,7 @@
 +		  regcache_invalidate (regcache, regno);
 +		}
 +
-+	      error (_("Process record cancel the operation."));
++	      error (_("Process record canceled the operation."));
 +	    }
 +
 +	  /* Destroy the record from here forward.  */
@@ -911,7 +914,7 @@
 +      if (RECORD_IS_REPLAY)
 +	{
 +	  /* Let user choice if he want to write memory or not.  */
-+	  if (!nquery (_("Because GDB is in replay mode, writing to memory
will destroy the record from this point forward.  Write memory at
address 0x%s?"),
++	  if (!nquery (_("Because GDB is in replay mode, writing to memory
will make the execute log unusable from this point onward.  Write
memory at address 0x%s?"),
 +		       paddr_nz (offset)))
 +	    {
 +	      return -1;
@@ -930,13 +933,23 @@
 +      if (record_arch_list_add_mem (offset, len))
 +	{
 +	  record_list_release (record_arch_list_tail);
-+	  fprintf_unfiltered (gdb_stdlog, _("Process record: record message
error."));
++	  if (record_debug)
++	    {
++	      fprintf_unfiltered (gdb_stdlog,
++				  _
++				  ("Process record: failed to record execution log."));
++	    }
 +	  return -1;
 +	}
 +      if (record_arch_list_add_end (0))
 +	{
 +	  record_list_release (record_arch_list_tail);
-+	  fprintf_unfiltered (gdb_stdlog, _("Process record: record message
error."));
++	  if (record_debug)
++	    {
++	      fprintf_unfiltered (gdb_stdlog,
++				  _
++				  ("Process record: failed to record execution log."));
++	    }
 +	  return -1;
 +	}
 +      record_list->next = record_arch_list_head;
@@ -1040,14 +1053,14 @@
 +    {
 +      if (RECORD_IS_REPLAY)
 +	{
-+	  if (!from_tty || query (_("Process record: delete the log from
this point forward and begin to record the running message at current
PC?")))
++	  if (!from_tty || query (_("Delete the log from this point forward
and begin to record the running message at current PC?")))
 +	    {
 +	      record_list_release_next ();
 +	    }
 +	}
 +      else
 +	{
-+	  printf_unfiltered (_("Process record: already at end of record list.\n"));
++	  printf_unfiltered (_("Already at end of record list.\n"));
 +	}
 +
 +    }
@@ -1064,7 +1077,7 @@
 +{
 +  if (RECORD_IS_USED)
 +    {
-+      if (!record_list || !from_tty || query (_("Process record:
delete recorded log and stop recording?")))
++      if (!record_list || !from_tty || query (_("Delete recorded log
and stop recording?")))
 +	{
 +	  unpush_target (&record_ops);
 +	}
@@ -1082,7 +1095,7 @@
 +{
 +  if (record_insn_num > record_insn_max_num && record_insn_max_num)
 +    {
-+      printf_unfiltered (_("Process record: record instructions
number is bigger than record instructions max number.  Auto delete the
first ones.\n"));
++      printf_unfiltered (_("Record instructions number is bigger
than record instructions max number.  Auto delete the first
ones?\n"));
 +
 +      while (record_insn_num > record_insn_max_num)
 +	{
@@ -1107,7 +1120,7 @@
 +  /* Init record_maskall.  */
 +  if (sigfillset (&record_maskall) == -1)
 +    {
-+      perror_with_name (_("Process record: sigfillset"));
++      perror_with_name (_("Process record: sigfillset failed"));
 +    }
 +
 +  /* Init record_first.  */
@@ -1137,7 +1150,7 @@
 +     other affect to GDB such as call function "no_shared_libraries".
 +     So I add special commands to GDB.  */
 +  add_com ("delrecord", class_obscure, cmd_record_delete,
-+	   _("When process record target running in replay mode, delete the
next running messages and begin to record the running message at
current address."));
++	   _("Delete the rest of execution log and start recording it anew."));
 +  add_com_alias ("dr", "delrecord", class_obscure, 1);
 +  add_com ("stoprecord", class_obscure, cmd_record_stop,
 +	   _("Stop the record/replay target."));
@@ -1146,12 +1159,12 @@
 +  /* Record instructions number limit command.  */
 +  add_setshow_boolean_cmd ("record-stop-at-limit", no_class,
 +			    &record_stop_at_limit,
-+			    _("Set record/replay stop when record/replay buffer becomes full."),
-+			    _("Show record/replay stop when record/replay buffer becomes
full."), _("\
++			    _("Set whether record/replay stop when record/replay buffer
becomes full."),
++			    _("Show whether record/replay stop when record/replay buffer
becomes full."), _("\
 +Enable is default value.\n\
-+When enable, if the record/replay buffer becomes full,\n\
-+ask user how to do.\n\
-+When disable, if the record/replay buffer becomes full,\n\
++When enabled, if the record/replay buffer becomes full,\n\
++ask user what to do.\n\
++When disabled, if the record/replay buffer becomes full,\n\
 +delete it and start new recording."), NULL, NULL, &setlist, &showlist);
 +  add_setshow_zinteger_cmd ("record-insn-number-max", no_class,
 +			    &record_insn_max_num,
@@ -1164,7 +1177,7 @@
 +  add_info ("record-insn-number", show_record_insn_number, _("\
 +Show the current number of instructions in the record/replay buffer."));
 +}
---- a/record.h
+--- a//dev/null
 +++ b/record.h
 @@ -0,0 +1,99 @@
 +/* Process record and replay target for GDB, the GNU debugger.
@@ -1175,7 +1188,7 @@
 +
 +   This program is free software; you can redistribute it and/or modify
 +   it under the terms of the GNU General Public License as published by
-+   the Free Software Foundation; either version 2 of the License, or
++   the Free Software Foundation; either version 3 of the License, or
 +   (at your option) any later version.
 +
 +   This program is distributed in the hope that it will be useful,

Attachment: 3-record_target.txt
Description: Text document


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]