diff -upN /dev/null current/scripts/gdb/README
--- /dev/null	2004-02-24 15:23:11.000000000 -0800
+++ current/scripts/gdb/README	2004-03-30 13:19:35.000000000 -0800
@@ -0,0 +1,3 @@
+A couple of patches against gdb-6.0 from Jim Houston <jhouston@new.localdomain>
+
+They are required for using kgdb on x86_64 targets.
diff -upN /dev/null current/scripts/gdb/gdb-switch-stacks.patch
--- /dev/null	2004-02-24 15:23:11.000000000 -0800
+++ current/scripts/gdb/gdb-switch-stacks.patch	2004-03-30 13:19:35.000000000 -0800
@@ -0,0 +1,83 @@
+Return-Path: <jhouston@h00e098094f32.ne.client2.attbi.com>
+Received: from mnm [127.0.0.1]
+	by localhost with POP3 (fetchmail-5.9.0)
+	for akpm@localhost (single-drop); Thu, 08 Jan 2004 17:54:39 -0800 (PST)
+Received: from fire-1.osdl.org (air1.pdx.osdl.net [172.20.0.5])
+	by mail.osdl.org (8.11.6/8.11.6) with ESMTP id i091r1o18423
+	for <akpm@osdl.org>; Thu, 8 Jan 2004 17:53:01 -0800
+Received: from rwcrmhc13.comcast.net (rwcrmhc13.comcast.net [204.127.198.39])
+	by fire-1.osdl.org (8.12.8/8.12.8) with ESMTP id i091r0Av030132
+	for <akpm@osdl.org>; Thu, 8 Jan 2004 17:53:01 -0800
+Received: from h00e098094f32.ne.client2.attbi.com ([24.60.234.83])
+          by comcast.net (rwcrmhc13) with ESMTP
+          id <2004010901525401500b89aoe>; Fri, 9 Jan 2004 01:52:54 +0000
+Received: by h00e098094f32.ne.client2.attbi.com (Postfix, from userid 500)
+	id 6B592C60FC; Thu,  8 Jan 2004 20:52:33 -0500 (EST)
+To: Andrew Morton <akpm@osdl.org>
+From: jim.houston@comcast.net
+Subject: gdb-switch-stacks.patch
+Message-Id: <20040109015233.6B592C60FC@h00e098094f32.ne.client2.attbi.com>
+Date: Thu,  8 Jan 2004 20:52:33 -0500 (EST)
+X-MIMEDefang-Filter: osdl$Revision: 1.45 $
+X-Scanned-By: MIMEDefang 2.36
+X-Spam-Checker-Version: SpamAssassin 2.60 (1.212-2003-09-23-exp) on mnm
+X-Spam-Level: 
+X-Spam-Status: No, hits=-4.6 required=2.0 tests=BAYES_00,NO_REAL_NAME 
+	autolearn=no version=2.60
+
+
+Hi Andrew,
+
+This patch to gdb-6.0 adds an option to disable an error check
+which reports a non-contiguous stack as corrupted.  This is
+needed to get a reliable stack trace using kgdb on Opteron 
+because the kernel uses a separate per-processor interrupt stack.
+
+This option is enabled with:
+
+     set backtrace switch-stacks on
+
+Jim Houston - Concurrent Computer Corp.
+
+-
+
+diff -urN old/gdb-6.0/gdb/frame.c new/gdb-6.0/gdb/frame.c
+--- old/gdb-6.0/gdb/frame.c	2003-12-31 15:27:45.866840920 -0500
++++ new/gdb-6.0/gdb/frame.c	2003-12-31 15:27:58.310949128 -0500
+@@ -138,6 +138,7 @@
+ /* Flag to indicate whether backtraces should stop at main et.al.  */
+ 
+ static int backtrace_past_main;
++static int backtrace_switch_stacks;
+ static unsigned int backtrace_limit = UINT_MAX;
+ 
+ 
+@@ -1971,7 +1972,7 @@
+      the next frame.  This happens when a frame unwind goes backwards.
+      Since the sentinel frame doesn't really exist, don't compare the
+      inner-most against that sentinel.  */
+-  if (this_frame->level > 0
++  if (!backtrace_switch_stacks && this_frame->level > 0
+       && frame_id_inner (get_frame_id (this_frame),
+ 			 get_frame_id (this_frame->next)))
+     error ("Previous frame inner to this frame (corrupt stack?)");
+@@ -2461,6 +2462,19 @@
+ 			   NULL, NULL, &set_backtrace_cmdlist,
+ 			   &show_backtrace_cmdlist);
+ 
++  add_setshow_boolean_cmd ("switch-stacks", class_obscure,
++			   &backtrace_switch_stacks, "\
++Set if thread may use multiple stacks.  This flag disables checks in\n\
++the stack trace which expect that the stack grew in a consistent direction.\n\
++This option is needed for kernel debug when the kernel has separate\n\
++process and interrupt stacks.", "\
++Show if thread may use multiple stacks.  This flag disables checks in\n\
++the stack trace which expect that the stack grew in a consistent direction.\n\
++This option is needed for kernel debug when the kernel has separate\n\
++process and interrupt stacks.",
++			   NULL, NULL, &set_backtrace_cmdlist,
++			   &show_backtrace_cmdlist);
++
+   add_setshow_uinteger_cmd ("limit", class_obscure,
+ 			    &backtrace_limit, "\
+ Set an upper bound on the number of backtrace levels.\n\
diff -upN /dev/null current/scripts/gdb/gdb-thread-skip-frame.patch
--- /dev/null	2004-02-24 15:23:11.000000000 -0800
+++ current/scripts/gdb/gdb-thread-skip-frame.patch	2004-03-30 13:19:35.000000000 -0800
@@ -0,0 +1,133 @@
+Received: from mnm [127.0.0.1]
+	by localhost with POP3 (fetchmail-5.9.0)
+	for akpm@localhost (single-drop); Thu, 08 Jan 2004 18:10:40 -0800 (PST)
+Received: from fire-1.osdl.org (air1.pdx.osdl.net [172.20.0.5])
+	by mail.osdl.org (8.11.6/8.11.6) with ESMTP id i0929qo20750
+	for <akpm@osdl.org>; Thu, 8 Jan 2004 18:09:52 -0800
+Received: from sccrmhc13.comcast.net (sccrmhc13.comcast.net [204.127.202.64])
+	by fire-1.osdl.org (8.12.8/8.12.8) with ESMTP id i0929qAv031470
+	for <akpm@osdl.org>; Thu, 8 Jan 2004 18:09:52 -0800
+Received: from h00e098094f32.ne.client2.attbi.com ([24.60.234.83])
+          by comcast.net (sccrmhc13) with ESMTP
+          id <2004010902094601600ni0oje>; Fri, 9 Jan 2004 02:09:46 +0000
+Received: by h00e098094f32.ne.client2.attbi.com (Postfix, from userid 500)
+	id 6DA02C60FC; Thu,  8 Jan 2004 21:09:20 -0500 (EST)
+From: Jim Houston <jhouston@new.localdomain>
+To: Andrew Morton <akpm@osdl.org>
+Subject: gdb-thread-skip-frame.patch
+Message-Id: <20040109020920.6DA02C60FC@h00e098094f32.ne.client2.attbi.com>
+Date: Thu,  8 Jan 2004 21:09:20 -0500 (EST)
+X-MIMEDefang-Filter: osdl$Revision: 1.45 $
+X-Scanned-By: MIMEDefang 2.36
+X-Spam-Checker-Version: SpamAssassin 2.60 (1.212-2003-09-23-exp) on mnm
+X-Spam-Level: 
+X-Spam-Status: No, hits=-4.9 required=2.0 tests=BAYES_00 autolearn=ham 
+	version=2.60
+
+
+Hi Andrew,
+
+In the i386 kgdb_stub, George Anzinger has code to find the first
+stack frame which is not in the scheduler.  He returns the register
+information for this frame so the "info thread" command will
+display an interesting frame.
+
+Doing this on the x86_64 was not as easy because frame pointers
+are not used consistently.  The attached patch adds an option to 
+gdb to skip over frames which are executing function listed in the
+option.
+
+Use:
+	set skip-frame thread_return,schedule_timeout
+
+Jim Houston - Concurrent Computer Corp.
+
+--
+
+--- old/gdb-6.0/gdb/thread.c	2004-01-06 12:34:14.786496352 -0500
++++ new/gdb-6.0/gdb/thread.c	2004-01-06 12:34:28.804365312 -0500
+@@ -404,6 +404,43 @@
+     }
+ }
+ 
++/*
++ * When using gdb as a kernel debugger, its really boring to
++ * see every thread is blocked in schedule.  By setting a
++ * list of functions with "set skip-frame schedule,thread_return" 
++ * we can display the frame that called into the scheduler.
++ */
++static char *skip_frame_string;
++
++int
++skip_frame(struct frame_info *fi)
++{
++  struct minimal_symbol *msym;
++  CORE_ADDR pc;
++  char *name;
++  char *s, *r;
++  int n;
++
++  pc = get_frame_pc (fi);
++  msym = lookup_minimal_symbol_by_pc_section(pc, NULL);
++  if (!msym)
++    return 0;
++  name = SYMBOL_LINKAGE_NAME(msym);
++
++  for (s = skip_frame_string; s && *s ; ) {
++    if ((r = strchr(s, ',')))
++      n = r - s - 1;
++    else
++      n = strlen(s);
++    if (n && strncmp(s, name, n) == 0)
++      return 1;
++    if (!r)
++      break;
++    s = r + 1;
++  }
++  return 0;
++}
++
+ /* Print information about currently known threads 
+ 
+  * Note: this has the drawback that it _really_ switches
+@@ -416,7 +453,7 @@
+ {
+   struct thread_info *tp;
+   ptid_t current_ptid;
+-  struct frame_info *cur_frame;
++  struct frame_info *cur_frame, *fi;
+   int saved_frame_level = frame_relative_level (get_selected_frame ());
+   int counter;
+   char *extra_info;
+@@ -448,6 +485,18 @@
+       puts_filtered ("  ");
+ 
+       switch_to_thread (tp->ptid);
++
++      if (skip_frame_string) {
++	/* skip up the stack to an interesting frame. */
++        fi = get_selected_frame ();
++        while (fi) {
++          if (!skip_frame(fi))
++            break;
++          fi = get_prev_frame(fi);
++  	  if (fi)
++            select_frame(fi);
++        }
++      }
+       print_stack_frame (get_selected_frame (), -1, 0);
+     }
+ 
+@@ -740,4 +789,12 @@
+ 
+   if (!xdb_commands)
+     add_com_alias ("t", "thread", class_run, 1);
++
++  add_show_from_set (add_set_cmd ("skip-frame", class_obscure,
++    var_string_noescape, (char *)&skip_frame_string, "\
++Set list of functions to skip when choosing the frame to display\n\
++for a info-thread command.  When gdb is used for kernel debug this option\n\
++allows the frame which calls the scheduler to be displayed rather than\n\
++having all blocked threads showing the same function in the scheduler.",
++    &setlist), &showlist);
+ }