aboutsummaryrefslogtreecommitdiff
path: root/gdb
diff options
context:
space:
mode:
authorChristopher Faylor <me+cygwin@cgf.cx>2000-11-17 03:49:41 +0000
committerChristopher Faylor <me+cygwin@cgf.cx>2000-11-17 03:49:41 +0000
commite35ce267f5838c87c6fdfaec396c2f2600c478c0 (patch)
tree528936ef23c4158168d3c1aee84dea54289812dd /gdb
parent165cd47f5eabd61fc53c930450493378ac9f1a8c (diff)
downloadgdb-e35ce267f5838c87c6fdfaec396c2f2600c478c0.zip
gdb-e35ce267f5838c87c6fdfaec396c2f2600c478c0.tar.gz
gdb-e35ce267f5838c87c6fdfaec396c2f2600c478c0.tar.bz2
* thread.c (thread_apply_all_command): Save the command before executing it
because it may be modified. Restore the saved command so that the same command is executed on next thread. (thread_apply_command): Same correction.
Diffstat (limited to 'gdb')
-rw-r--r--gdb/ChangeLog7
-rw-r--r--gdb/thread.c16
2 files changed, 23 insertions, 0 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 8507deb..8df4bd4 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,10 @@
+2000-11-16 Christopher Faylor <cgf@redhat.com>
+
+ * thread.c (thread_apply_all_command): Save the command before
+ executing it because it may be modified. Restore the saved command so
+ that the same command is executed on next thread.
+ (thread_apply_command): Same correction.
+
2000-11-16 Michael Snyder <msnyder@cleaver.cygnus.com>
* regcache.c (read_register_bytes): Failing to set register_valid
diff --git a/gdb/thread.c b/gdb/thread.c
index 94f0b3f..7f50976 100644
--- a/gdb/thread.c
+++ b/gdb/thread.c
@@ -517,6 +517,8 @@ thread_apply_all_command (char *cmd, int from_tty)
{
struct thread_info *tp;
struct cleanup *old_chain;
+ struct cleanup *saved_cmd_cleanup_chain;
+ char *saved_cmd;
if (cmd == NULL || *cmd == '\000')
error ("Please specify a command following the thread ID list");
@@ -527,6 +529,10 @@ thread_apply_all_command (char *cmd, int from_tty)
traversing it for "thread apply all". MVS */
target_find_new_threads ();
+ /* Save a copy of the command in case it is clobbered by
+ execute_command */
+ saved_cmd = strdup (cmd);
+ saved_cmd_cleanup_chain = make_cleanup (free, (void *) saved_cmd);
for (tp = thread_list; tp; tp = tp->next)
if (thread_alive (tp))
{
@@ -540,8 +546,10 @@ thread_apply_all_command (char *cmd, int from_tty)
target_pid_to_str (inferior_pid));
#endif
execute_command (cmd, from_tty);
+ strcpy (cmd, saved_cmd); /* Restore exact command used previously */
}
+ do_cleanups (saved_cmd_cleanup_chain);
do_cleanups (old_chain);
}
@@ -551,6 +559,8 @@ thread_apply_command (char *tidlist, int from_tty)
char *cmd;
char *p;
struct cleanup *old_chain;
+ struct cleanup *saved_cmd_cleanup_chain;
+ char *saved_cmd;
if (tidlist == NULL || *tidlist == '\000')
error ("Please specify a thread ID list");
@@ -562,6 +572,10 @@ thread_apply_command (char *tidlist, int from_tty)
old_chain = make_cleanup_restore_current_thread (inferior_pid);
+ /* Save a copy of the command in case it is clobbered by
+ execute_command */
+ saved_cmd = strdup (cmd);
+ saved_cmd_cleanup_chain = make_cleanup (free, (void *) saved_cmd);
while (tidlist < cmd)
{
struct thread_info *tp;
@@ -608,10 +622,12 @@ thread_apply_command (char *tidlist, int from_tty)
target_pid_to_str (inferior_pid));
#endif
execute_command (cmd, from_tty);
+ strcpy (cmd, saved_cmd); /* Restore exact command used previously */
}
}
}
+ do_cleanups (saved_cmd_cleanup_chain);
do_cleanups (old_chain);
}