This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[PATCH for review][PR gdb/15853] 'thread apply all inetrrupt&' shows inefficiency on remote targets
- From: Muhammad Bilal <mbilal at codesourcery dot com>
- To: "gdb-patches at sourceware dot org" <gdb-patches at sourceware dot org>
- Date: Mon, 19 Aug 2013 18:53:24 +0500
- Subject: [PATCH for review][PR gdb/15853] 'thread apply all inetrrupt&' shows inefficiency on remote targets
Hi,
While I was playing with non-stop thread debugging, I have observed that.
In the case of 'interrupt -a&' command gdb sends only one packet to
stop all threads as $vCont;t#b9...
But in case of 'thread apply all interrupt&' GDB issues individual packet for each thread.I think that In non-stop mode
'interrupt -a&' and 'thread apply all interrupt&' commands are equals but time efficiency of later command is less.
Also,
If user issues a command like 'thread apply all interrupt -a&'
GDB accepts it and GDB will stop all threads on first vcount;t packets but due to loops iteration on all threads,
GDB sends vcount;t packet for all remaining threads although GDB has already stop all thread so IMO it is a bug.
Please find proposed patch for this issue.\
2013-08-19 Muhammad Bilal <mbilal@codesourcery.com>
PR gdb/15853
* thread.c (apply_all): Define new variable.
(thread_apply_all_command): Make a check, to Sending single
vCount packet on remote stup by 'thread apply all interrupt'
command.
* infcmd.c (all_threads): Redifine as Global variable.
(interrupt_target_command): Generate an error message on
'thread apply all interrupt -a&' command.
* inferior.h (apply_all): Declare.
(all_threads): Likewise.
Index: infcmd.c
===================================================================
RCS file: /cvs/src/src/gdb/infcmd.c,v
retrieving revision 1.333
diff -u -p -r1.333 infcmd.c
--- infcmd.c 11 Jul 2013 09:07:41 -0000 1.333
+++ infcmd.c 19 Aug 2013 13:52:27 -0000
@@ -2776,22 +2776,28 @@ interrupt_target_1 (int all_threads)
if the `-a' switch is used. */
/* interrupt [-a] */
+int all_threads = 0;
static void
interrupt_target_command (char *args, int from_tty)
{
if (target_can_async_p ())
{
- int all_threads = 0;
dont_repeat (); /* Not for the faint of heart. */
if (args != NULL
&& strncmp (args, "-a", sizeof ("-a") - 1) == 0)
+ {
+ if (!non_stop)
+ error (_("-a is meaningless in all-stop mode."));
+ else if (apply_all)
+ error (_("-a is meaningless in thread apply all command."));
+ else
+ all_threads = 1;
+ }
+ else if (apply_all)
all_threads = 1;
- if (!non_stop && all_threads)
- error (_("-a is meaningless in all-stop mode."));
-
interrupt_target_1 (all_threads);
}
}
Index: inferior.h
===================================================================
RCS file: /cvs/src/src/gdb/inferior.h,v
retrieving revision 1.185
diff -u -p -r1.185 inferior.h
--- inferior.h 14 May 2013 20:32:15 -0000 1.185
+++ inferior.h 19 Aug 2013 13:52:28 -0000
@@ -128,6 +128,12 @@ extern int detach_fork;
system's address space randomization feature when starting an
inferior. */
extern int disable_randomization;
+/* When we are using the thread apply all command. */
+extern int apply_all;
+
+/* If command is apply on all threads. */
+extern int all_threads;
+
extern void generic_mourn_inferior (void);
extern void terminal_save_ours (void);
Index: thread.c
===================================================================
RCS file: /cvs/src/src/gdb/thread.c,v
retrieving revision 1.155
diff -u -p -r1.155 thread.c
--- thread.c 15 Jul 2013 11:14:32 -0000 1.155
+++ thread.c 19 Aug 2013 13:52:28 -0000
@@ -1208,7 +1208,7 @@ make_cleanup_restore_current_thread (voi
thread apply 1 2 7 4 backtrace Apply backtrace cmd to threads
1,2,7,4
thread apply 2-7 9 p foo(1) Apply p foo(1) cmd to threads 2->7 & 9
thread apply all p x/i $pc Apply x/i $pc cmd to all threads. */
-
+int apply_all = 0;
static void
thread_apply_all_command (char *cmd, int from_tty)
{
@@ -1216,6 +1216,7 @@ thread_apply_all_command (char *cmd, int
char *saved_cmd;
int tc;
struct thread_array_cleanup ta_cleanup;
+ apply_all = 1;
if (cmd == NULL || *cmd == '\000')
error (_("Please specify a command following the thread ID list"));
@@ -1260,7 +1261,11 @@ thread_apply_all_command (char *cmd, int
tp_array[k]->num,
target_pid_to_str (inferior_ptid));
execute_command (cmd, from_tty);
-
+ if (all_threads)
+ {
+ all_threads = 0;
+ break;
+ }
/* Restore exact command used previously. */
strcpy (cmd, saved_cmd);
}
Thanks,
-Bilal