]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
2009-07-25 Michael Snyder <msnyder@vmware.com>
authorMichael Snyder <msnyder@vmware.com>
Sun, 26 Jul 2009 01:32:59 +0000 (01:32 +0000)
committerMichael Snyder <msnyder@vmware.com>
Sun, 26 Jul 2009 01:32:59 +0000 (01:32 +0000)
* checkpoint.c: New file, target-agnostic checkpoints.
* checkpoint.h: New file, interface.
* Makefile.in (SFILES): Add checkpoint.c.

gdb/ChangeLog
gdb/Makefile.in
gdb/checkpoint.c [new file with mode: 0644]
gdb/checkpoint.h [new file with mode: 0644]

index 1a579a11bbefa051ad5db43c332387a549084ac8..0bf1d40d6963b01ade21279405096a0642e64ccd 100644 (file)
@@ -1,3 +1,9 @@
+2009-07-25  Michael Snyder  <msnyder@vmware.com>
+
+       * checkpoint.c: New file, target-agnostic checkpoints.
+       * checkpoint.h: New file, interface.
+       * Makefile.in (SFILES): Add checkpoint.c.
+
 2009-07-25  Michael Snyder  <msnyder@vmware.com>
 
        * target.h (struct target_ops): New methods to_set_checkpoint,
index 7659a8fb481db2ced46fb58db6fe431f8468faa5..9876897f4c7179113f0e36aa3bd9206fa315e679 100644 (file)
@@ -667,7 +667,7 @@ SFILES = ada-exp.y ada-lang.c ada-typeprint.c ada-valprint.c ada-tasks.c \
        stabsread.c stack.c std-regs.c symfile.c symfile-mem.c symmisc.c \
        symtab.c \
        target.c target-descriptions.c target-memory.c \
-       thread.c top.c tracepoint.c \
+       thread.c top.c tracepoint.c checkpoint.c \
        trad-frame.c \
        tramp-frame.c \
        typeprint.c \
@@ -736,7 +736,7 @@ coff-pe-read.h parser-defs.h gdb_ptrace.h mips-linux-tdep.h \
 m68k-tdep.h spu-tdep.h jv-lang.h environ.h solib-irix.h amd64-tdep.h \
 doublest.h regset.h hppa-tdep.h ppc-linux-tdep.h rs6000-tdep.h \
 gdb_locale.h gdb_dirent.h arch-utils.h trad-frame.h gnu-nat.h \
-language.h nbsd-tdep.h wrapper.h solib-svr4.h \
+language.h nbsd-tdep.h wrapper.h solib-svr4.h checkpoint.h \
 macroexp.h ui-file.h regcache.h gdb_string.h tracepoint.h i386-tdep.h \
 inf-child.h p-lang.h event-top.h gdbtypes.h scm-tags.h user-regs.h \
 regformats/regdef.h config/alpha/nm-osf3.h  config/i386/nm-i386gnu.h \
@@ -786,6 +786,7 @@ COMMON_OBS = $(DEPFILES) $(CONFIG_OBS) $(YYOBJ) \
        block.o symtab.o symfile.o symmisc.o linespec.o dictionary.o \
        infcall.o \
        infcmd.o infrun.o \
+       checkpoint.o \
        expprint.o environ.o stack.o thread.o \
        exceptions.o \
        inf-child.o \
diff --git a/gdb/checkpoint.c b/gdb/checkpoint.c
new file mode 100644 (file)
index 0000000..96cce98
--- /dev/null
@@ -0,0 +1,97 @@
+/* Target-agnostic module for checkpoint commands.
+
+   Copyright (C) 2009 Free Software Foundation, Inc.
+
+   This file is part of GDB.
+
+   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 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
+
+/* XXX mvs put the actual commands here, and add them to gdb's
+   command lists only by request.
+
+   TBD: actually manage the list here?
+   How would that interplay with forks as written now?
+*/
+
+#include "defs.h"
+#include "target.h"
+#include "gdbcmd.h"
+
+/* Set a checkpoint (call target_ops method).  */
+
+static void
+checkpoint_command (char *args, int from_tty)
+{
+  if (target_set_checkpoint)
+    target_set_checkpoint (args, from_tty);
+  else
+    error (_("checkpoint command not implemented for this target."));
+}
+
+/* Restore a checkpoint (call target_ops method).  */
+
+static void
+restart_command (char *args, int from_tty)
+{
+  if (target_restore_checkpoint)
+    target_restore_checkpoint (args, from_tty);
+  else
+    error (_("restart command not implemented for this target."));
+}
+
+/* Delete a checkpoint (call target_ops method).  */
+
+static void
+delete_checkpoint_command (char *args, int from_tty)
+{
+  if (target_unset_checkpoint)
+    target_unset_checkpoint (args, from_tty);
+  else
+    error (_("delete checkpoint command not implemented for this target."));
+}
+
+static void
+info_checkpoints_command (char *args, int from_tty)
+{
+  if (target_info_checkpoints)
+    target_info_checkpoints (args, from_tty);
+  else
+    error (_("info checkpoints command not implemented for this target."));
+}
+
+
+/* Initializer function checkpoint_init().
+   Note -- not called in the usual gdb module-initializer manner, 
+   but only by explicit request by targets that want checkpoints.  */
+
+void
+checkpoint_init (void)
+{
+  add_com ("checkpoint", class_obscure, checkpoint_command, _("\
+Create a checkpoint that can be restored later via 'restart'."));
+
+  /* Restart command: restore the context of a specified checkpoint
+     process.  */
+
+  add_com ("restart", class_obscure, restart_command, _("\
+restart <n>: restore program context from a checkpoint.\n\
+Argument 'n' is checkpoint ID, as displayed by 'info checkpoints'."));
+
+  add_cmd ("checkpoint", class_obscure, delete_checkpoint_command, _("\
+Delete a previously saved checkpoint."),
+          &deletelist);
+
+  add_info ("checkpoints", info_checkpoints_command,
+           _("IDs of currently known checkpoints."));
+}
diff --git a/gdb/checkpoint.h b/gdb/checkpoint.h
new file mode 100644 (file)
index 0000000..7b99475
--- /dev/null
@@ -0,0 +1,25 @@
+/* External interface for checkpoint module.
+   Copyright (C) 2009
+   Free Software Foundation, Inc.
+
+   This file is part of GDB.
+
+   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 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
+
+#if !defined (CHECKPOINT_H)
+#define CHECKPOINT_H 1
+
+extern void checkpoint_init (void);
+
+#endif /* CHECKPOINT_H */