From: Michael Snyder Date: Sun, 26 Jul 2009 01:32:59 +0000 (+0000) Subject: 2009-07-25 Michael Snyder X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=ec6f1d7fc6ce620946222aa78b8ee3f7ee90f70c;p=thirdparty%2Fbinutils-gdb.git 2009-07-25 Michael Snyder * checkpoint.c: New file, target-agnostic checkpoints. * checkpoint.h: New file, interface. * Makefile.in (SFILES): Add checkpoint.c. --- diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 1a579a11bbe..0bf1d40d696 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,9 @@ +2009-07-25 Michael Snyder + + * checkpoint.c: New file, target-agnostic checkpoints. + * checkpoint.h: New file, interface. + * Makefile.in (SFILES): Add checkpoint.c. + 2009-07-25 Michael Snyder * target.h (struct target_ops): New methods to_set_checkpoint, diff --git a/gdb/Makefile.in b/gdb/Makefile.in index 7659a8fb481..9876897f4c7 100644 --- a/gdb/Makefile.in +++ b/gdb/Makefile.in @@ -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 index 00000000000..96cce985fd6 --- /dev/null +++ b/gdb/checkpoint.c @@ -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 . */ + +/* 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 : 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 index 00000000000..7b994755662 --- /dev/null +++ b/gdb/checkpoint.h @@ -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 . */ + +#if !defined (CHECKPOINT_H) +#define CHECKPOINT_H 1 + +extern void checkpoint_init (void); + +#endif /* CHECKPOINT_H */