This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH 4/5] scope ITSET bt


In default, command 'backtrace' apply to the current thread.  After
this patch, command 'bt' can be applied to a set of threads specified
by 'scope'.

gdb:

2013-04-02  Yao Qi  <yao@codesourcery.com>

	* stack.c: Include "itset.h".
	(backtrace_command_1): Rename to ...
	(backtrace_command_2): ... it.  New.
	(backtrace_command_1): New.  If 'target set' is NULL call
	backtrace_command_2, otherwise, switch to each stopped thread,
	and call backtrace_command_2.
---
 gdb/stack.c |   34 ++++++++++++++++++++++++++++++----
 1 files changed, 30 insertions(+), 4 deletions(-)

diff --git a/gdb/stack.c b/gdb/stack.c
index 9ac3123..34a5d61 100644
--- a/gdb/stack.c
+++ b/gdb/stack.c
@@ -55,6 +55,8 @@
 #include "psymtab.h"
 #include "symfile.h"
 
+#include "itset.h"
+
 void (*deprecated_selected_frame_level_changed_hook) (int);
 
 /* The possible choices of "set print frame-arguments", and the value
@@ -1652,7 +1654,7 @@ frame_info (char *addr_exp, int from_tty)
    frames.  */
 
 static void
-backtrace_command_1 (char *count_exp, int show_locals, int from_tty)
+backtrace_command_2 (char *count_exp, int show_locals, int from_tty)
 {
   struct frame_info *fi;
   int count;
@@ -1660,9 +1662,6 @@ backtrace_command_1 (char *count_exp, int show_locals, int from_tty)
   struct frame_info *trailing;
   int trailing_level;
 
-  if (!target_has_stack)
-    error (_("No stack."));
-
   /* The following code must do two things.  First, it must set the
      variable TRAILING to the frame from which we should start
      printing.  Second, it must set the variable count to the number
@@ -1767,6 +1766,33 @@ backtrace_command_1 (char *count_exp, int show_locals, int from_tty)
 }
 
 static void
+backtrace_command_1 (char *count_exp, int show_locals, int from_tty)
+{
+  struct thread_info *thr;
+  struct itset *target_set = itset_get_target_set_reference ();
+
+  if (!target_has_stack)
+    error (_("No stack."));
+
+  if (target_set == NULL)
+    backtrace_command_2 (count_exp, show_locals, from_tty);
+  else
+    {
+      ALL_THREADS (thr)
+	if (thr->state == THREAD_STOPPED
+	    /* Make no sense to print the stack of a running or
+	       exited thread.  */
+	    && itset_contains_thread (target_set, thr))
+	  {
+	    switch_to_thread (thr->ptid);
+	    printf_filtered (_("\nThread %d (%s):\n"), thr->num,
+			     target_pid_to_str (thr->ptid));
+	    backtrace_command_2 (count_exp, show_locals, from_tty);
+	  }
+    }
+}
+
+static void
 backtrace_command (char *arg, int from_tty)
 {
   struct cleanup *old_chain = make_cleanup (null_cleanup, NULL);
-- 
1.7.7.6


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]