• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

GNU Binutils with patches for OS216


Commit MetaInfo

Revision6eee65c06383be15eb6d4ede86897a2257c64850 (tree)
Time2006-04-01 06:36:27
AuthorMichael Snyder <msnyder@vmwa...>
CommiterMichael Snyder

Log Message

2006-03-31 Michael Snyder <msnyder@redhat.com>

User interface for reverse execution.
* Makefile.in (reverse.c): New file.
* reverse.c: New file. User interface for reverse execution.

Change Summary

Incremental Difference

--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -34,6 +34,12 @@
3434 * infrun.c: Make sure to check for EXEC_REVERSE not EXEC_FORWARD,
3535 since targets that don't implement execdir will return EXEC_ERROR.
3636
37+2006-03-31 Michael Snyder <msnyder@redhat.com>
38+
39+ User interface for reverse execution.
40+ * Makefile.in (reverse.c): New file.
41+ * reverse.c: New file. User interface for reverse execution.
42+
3743 2006-03-31 Andrew Stubbs <andrew.stubbs@st.com>
3844
3945 * value.h (struct internalvar): Add field 'endian'.
--- a/gdb/Makefile.in
+++ b/gdb/Makefile.in
@@ -543,7 +543,7 @@ SFILES = ada-exp.y ada-lang.c ada-typeprint.c ada-valprint.c \
543543 objfiles.c osabi.c observer.c \
544544 p-exp.y p-lang.c p-typeprint.c p-valprint.c parse.c printcmd.c \
545545 prologue-value.c \
546- regcache.c reggroups.c remote.c remote-fileio.c \
546+ regcache.c reggroups.c remote.c remote-fileio.c reverse.c \
547547 scm-exp.c scm-lang.c scm-valprint.c \
548548 sentinel-frame.c \
549549 serial.c ser-base.c ser-unix.c \
@@ -927,7 +927,8 @@ COMMON_OBS = $(DEPFILES) $(CONFIG_OBS) $(YYOBJ) \
927927 signals.o \
928928 kod.o kod-cisco.o \
929929 gdb-events.o \
930- exec.o bcache.o objfiles.o observer.o minsyms.o maint.o demangle.o \
930+ exec.o reverse.o \
931+ bcache.o objfiles.o observer.o minsyms.o maint.o demangle.o \
931932 dbxread.o coffread.o coff-pe-read.o elfread.o \
932933 dwarfread.o dwarf2read.o mipsread.o stabsread.o corefile.o \
933934 dwarf2expr.o dwarf2loc.o dwarf2-frame.o \
@@ -2493,6 +2494,8 @@ remote-st.o: remote-st.c $(defs_h) $(gdbcore_h) $(target_h) $(gdb_string_h) \
24932494 remote-utils.o: remote-utils.c $(defs_h) $(gdb_string_h) $(gdbcmd_h) \
24942495 $(target_h) $(serial_h) $(gdbcore_h) $(inferior_h) $(remote_utils_h) \
24952496 $(regcache_h)
2497+reverse.o: reverse.c $(defs_h) $(gdb_string_h) $(target_h) $(cli_cmds_h) \
2498+ $(cli_decode_h) $(top_h)
24962499 rom68k-rom.o: rom68k-rom.c $(defs_h) $(gdbcore_h) $(target_h) $(monitor_h) \
24972500 $(serial_h) $(regcache_h) $(value_h) $(m68k_tdep_h)
24982501 rs6000-nat.o: rs6000-nat.c $(defs_h) $(inferior_h) $(target_h) $(gdbcore_h) \
--- /dev/null
+++ b/gdb/reverse.c
@@ -0,0 +1,197 @@
1+/* Reverse execution and reverse debugging.
2+
3+ Copyright (C) 2006 Free Software Foundation, Inc.
4+
5+ This file is part of GDB.
6+
7+ This program is free software; you can redistribute it and/or modify
8+ it under the terms of the GNU General Public License as published by
9+ the Free Software Foundation; either version 2 of the License, or
10+ (at your option) any later version.
11+
12+ This program is distributed in the hope that it will be useful,
13+ but WITHOUT ANY WARRANTY; without even the implied warranty of
14+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15+ GNU General Public License for more details.
16+
17+ You should have received a copy of the GNU General Public License
18+ along with this program; if not, write to the Free Software
19+ Foundation, Inc., 51 Franklin Street, Fifth Floor,
20+ Boston, MA 02110-1301, USA. */
21+
22+#include "defs.h"
23+#include "gdb_string.h"
24+#include "target.h"
25+#include "top.h"
26+#include "cli/cli-cmds.h"
27+#include "cli/cli-decode.h"
28+
29+/* User interface for reverse debugging:
30+ Set exec-direction / show exec-direction commands
31+ (returns error unles target implements to_set_execdir method). */
32+
33+static const char exec_forward[] = "forward";
34+static const char exec_reverse[] = "reverse";
35+static const char *exec_direction = exec_forward;
36+static const char *exec_direction_names[] = {
37+ exec_forward,
38+ exec_reverse,
39+ NULL
40+};
41+
42+static void
43+set_exec_direction_func (char *args, int from_tty,
44+ struct cmd_list_element *cmd)
45+{
46+ if (target_get_execution_direction () != EXEC_ERROR)
47+ {
48+ enum exec_direction_kind dir = EXEC_ERROR;
49+
50+ if (!strcmp (exec_direction, exec_forward))
51+ dir = EXEC_FORWARD;
52+ else if (!strcmp (exec_direction, exec_reverse))
53+ dir = EXEC_REVERSE;
54+
55+ if (target_set_execution_direction (dir) != EXEC_ERROR)
56+ return;
57+ }
58+ error (_("Target `%s' does not support execution-direction."),
59+ target_shortname);
60+}
61+
62+static void
63+show_exec_direction_func (struct ui_file *out, int from_tty,
64+ struct cmd_list_element *cmd, const char *value)
65+{
66+ enum exec_direction_kind dir = target_get_execution_direction ();
67+
68+ switch (dir) {
69+ case EXEC_FORWARD:
70+ fprintf_filtered (out, "Forward.\n");
71+ break;
72+ case EXEC_REVERSE:
73+ fprintf_filtered (out, "Reverse.\n");
74+ break;
75+ case EXEC_ERROR:
76+ default:
77+ error (_("Target `%s' does not support execution-direction."),
78+ target_shortname);
79+ break;
80+ }
81+}
82+
83+/* User interface:
84+ reverse-step, reverse-next etc.
85+ (returns error unles target implements to_set_execdir method). */
86+
87+static void execdir_default (void *notused)
88+{
89+ /* Return execution direction to default state. */
90+ target_set_execution_direction (EXEC_FORWARD);
91+}
92+
93+static void
94+exec_reverse_once (char *cmd, char *args, int from_tty)
95+{
96+ /* String buffer for command consing. */
97+ char reverse_command[512];
98+ enum exec_direction_kind dir = target_get_execution_direction ();
99+
100+ if (dir == EXEC_ERROR)
101+ error (_("Target %s does not support this command."), target_shortname);
102+
103+ if (dir == EXEC_REVERSE)
104+ error (_("Already in reverse mode. Use '%s' or 'set exec-dir forward'."),
105+ cmd);
106+
107+ if (target_set_execution_direction (EXEC_REVERSE) == EXEC_ERROR)
108+ error (_("Target %s does not support this command."), target_shortname);
109+
110+ make_cleanup (execdir_default, NULL);
111+ sprintf (reverse_command, "%s %s", cmd, args ? args : "");
112+ execute_command (reverse_command, from_tty);
113+}
114+
115+static void
116+reverse_step (char *args, int from_tty)
117+{
118+ exec_reverse_once ("step", args, from_tty);
119+}
120+
121+static void
122+reverse_stepi (char *args, int from_tty)
123+{
124+ exec_reverse_once ("stepi", args, from_tty);
125+}
126+
127+static void
128+reverse_next (char *args, int from_tty)
129+{
130+ exec_reverse_once ("next", args, from_tty);
131+}
132+
133+static void
134+reverse_nexti (char *args, int from_tty)
135+{
136+ exec_reverse_once ("nexti", args, from_tty);
137+}
138+
139+static void
140+reverse_continue (char *args, int from_tty)
141+{
142+ exec_reverse_once ("continue", args, from_tty);
143+}
144+
145+static void
146+reverse_finish (char *args, int from_tty)
147+{
148+ exec_reverse_once ("finish", args, from_tty);
149+}
150+
151+void
152+_initialize_reverse (void)
153+{
154+ add_setshow_enum_cmd ("exec-direction", class_run, exec_direction_names,
155+ &exec_direction, "Set direction of execution.\n\
156+Options are 'forward' or 'reverse'.",
157+ "Show direction of execution (forward/reverse).",
158+ "Tells gdb whether to execute forward or backward.",
159+ set_exec_direction_func, show_exec_direction_func,
160+ &setlist, &showlist);
161+
162+ add_com ("reverse-step", class_run, reverse_step, _("\
163+Step program backward until it reaches the beginning of another source line.\n\
164+Argument N means do this N times (or till program stops for another reason).")
165+ );
166+ add_com_alias ("rs", "reverse-step", class_alias, 1);
167+
168+ add_com ("reverse-next", class_run, reverse_next, _("\
169+Step program backward, proceeding through subroutine calls.\n\
170+Like the \"reverse-step\" command as long as subroutine calls do not happen;\n\
171+when they do, the call is treated as one instruction.\n\
172+Argument N means do this N times (or till program stops for another reason).")
173+ );
174+ add_com_alias ("rn", "reverse-next", class_alias, 1);
175+
176+ add_com ("reverse-stepi", class_run, reverse_stepi, _("\
177+Step backward exactly one instruction.\n\
178+Argument N means do this N times (or till program stops for another reason).")
179+ );
180+ add_com_alias ("rsi", "reverse-stepi", class_alias, 0);
181+
182+ add_com ("reverse-nexti", class_run, reverse_nexti, _("\
183+Step backward one instruction, but proceed through called subroutines.\n\
184+Argument N means do this N times (or till program stops for another reason).")
185+ );
186+ add_com_alias ("rni", "reverse-nexti", class_alias, 0);
187+
188+ add_com ("reverse-continue", class_run, reverse_continue, _("\
189+Continue program being debugged, running in reverse.\n\
190+If proceeding from breakpoint, a number N may be used as an argument,\n\
191+which means to set the ignore count of that breakpoint to N - 1 (so that\n\
192+the breakpoint won't break until the Nth time it is reached)."));
193+ add_com_alias ("rc", "reverse-continue", class_alias, 0);
194+
195+ add_com ("reverse-finish", class_run, reverse_finish, _("\
196+Execute backward until just before selected stack frame is called."));
197+}