Skip to contentSkip to conversation

kgdb support in vanilla 2.6.2

DISCUSSION Pavel Machek 6 participants 16 messages Feb 4, 2004 – Feb 21, 2004

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

Hi!

It seems that some kgdb support is in 2.6.2-linus:

+++ b/Documentation/sh/kgdb.txt Tue Feb 3 19:45:43 2004
@@ -0,0 +1,179 @@
+
+This file describes the configuration and behavior of KGDB for the SH +kernel. Based on a description from Henry Bell <[email protected]>, it +has been modified to account for quirks in the current implementation. +

That's great, can we get i386 kgdb, too? Or at least amd64 kgdb ;-). [Or was it a mistake? It seems unlikely that kgdb could enter Linus tree without major flamewar...]

Pavel

Signature · 2 lines
When do you have a heart between your knees?
[Johanka's followup: and *two* hearts?]
#1 lore raw
Quoted 2 lines · Pavel Machek

It seems that some kgdb support is in 2.6.2-linus:

Lots of architectures have had in-kernel kgdb support for a long time. Just none of the three which I use :(

I wouldn't support inclusion of i386 kgdb until it has had a lot of cleanup, possible de-featuritisification and some thought has been applied to splitting it into arch and generic bits. It's quite a lot of work.

#2 lore raw

Hi!

Quoted 8 lines
Quoted 1 line

It seems that some kgdb support is in 2.6.2-linus:

Lots of architectures have had in-kernel kgdb support for a long time. Just none of the three which I use :(

I wouldn't support inclusion of i386 kgdb until it has had a lot of cleanup, possible de-featuritisification and some thought has been applied to splitting it into arch and generic bits. It's quite a lot of work.

What about Amit's kgdb?

It's a *lot* cleaner. It does not have all the features (kgdb-eth is not yet ready for prime time). Would you accept that?

Oh and it is already split into arch-dependend and arch-independend parts, plus it has cleanly separated i/o methods...
Pavel

Signature · 2 lines
When do you have a heart between your knees?
[Johanka's followup: and *two* hearts?]
#3 lore raw
Quoted 10 lines · Pavel Machek
Quoted 9 lines
Quoted 2 lines

It seems that some kgdb support is in 2.6.2-linus:

Lots of architectures have had in-kernel kgdb support for a long time. Just none of the three which I use :(

I wouldn't support inclusion of i386 kgdb until it has had a lot of cleanup, possible de-featuritisification and some thought has been applied to splitting it into arch and generic bits. It's quite a lot of work.

Quoted 7 lines

What about Amit's kgdb?

It's a *lot* cleaner. It does not have all the features (kgdb-eth is not yet ready for prime time). Would you accept that?

Oh and it is already split into arch-dependend and arch-independend parts, plus it has cleanly separated i/o methods...

That all sounds positive. I was waiting until that effort settles down a bit before taking it for a ride. I have a bad habit of finding bugs in the gdb stub for some reason.

#4 lore raw
In reply to Pavel Machek
Quoted 11 lines · Pavel Machek

Hi!

Quoted 8 lines
Quoted 1 line

It seems that some kgdb support is in 2.6.2-linus:

Lots of architectures have had in-kernel kgdb support for a long time. Just none of the three which I use :(

I wouldn't support inclusion of i386 kgdb until it has had a lot of cleanup, possible de-featuritisification and some thought has been applied to splitting it into arch and generic bits. It's quite a lot of work.

Quoted 7 lines

What about Amit's kgdb?

It's a *lot* cleaner. It does not have all the features (kgdb-eth is not yet ready for prime time). Would you accept that?

Oh and it is already split into arch-dependend and arch-independend parts, plus it has cleanly separated i/o methods...

.. and it's supported on i386, x86_64 and PPC32 right now.

Andrew, what features of George's version don't you like? Right now I'm working on moving the kgdb-eth driver that uses netpoll over into Amit's version, and thinking of a cleaner away to allow for both early debugging and multiple drivers (eth or serial A or serial B).

Signature · 2 lines
Tom Rini
http://gate.crashing.org/~trini/
#5 lore raw
Quoted 2 lines · Tom Rini

Andrew, what features of George's version don't you like?

This is bad:

akpm:/usr/src/25> grep '^+#ifdef' patches/kgdb-ga.patch | wc -l

     83

and the fact that it touches 36 different files.

Any time I've had to do any maintenance work against that stub I get lost in a twisty maze and just whine at George about it. It's just all over the place. Yes, this is partly the nature of the beast, but I don't see that a ton of effort has been put into reducing the straggliness.

Quoted 4 lines

Right now
I'm working on moving the kgdb-eth driver that uses netpoll over into Amit's version, and thinking of a cleaner away to allow for both early debugging and multiple drivers (eth or serial A or serial B).

Sounds good.

Look, there's a lot of interest in this and I of course am fully supportive. If someone could send me Amit's patchset when they think I should test it, I could then talk about it more usefully.

#6 lore raw
Quoted 21 lines · Andrew Morton
Quoted 2 lines · Tom Rini

Andrew, what features of George's version don't you like?

This is bad:

akpm:/usr/src/25> grep '^+#ifdef' patches/kgdb-ga.patch | wc -l

     83

and the fact that it touches 36 different files.

Any time I've had to do any maintenance work against that stub I get lost in a twisty maze and just whine at George about it. It's just all over the place. Yes, this is partly the nature of the beast, but I don't see that a ton of effort has been put into reducing the straggliness.

Quoted 4 lines

Right now
I'm working on moving the kgdb-eth driver that uses netpoll over into Amit's version, and thinking of a cleaner away to allow for both early debugging and multiple drivers (eth or serial A or serial B).

Quoted 5 lines

Sounds good.

Look, there's a lot of interest in this and I of course am fully supportive. If someone could send me Amit's patchset when they think I should test it, I could then talk about it more usefully.

Alright. I hope to soon have netpoll'ed kgdb-over-ethernet happy. From there, I'll send you a patch that's Amit's work + cleanups / fixes, and better PPC support. Then we can see which features are in George's version become a must-have.

Signature · 2 lines
Tom Rini
http://gate.crashing.org/~trini/
#7 lore raw
In reply to Andrew Morton
Quoted 11 lines · Andrew Morton
Quoted 1 line · Tom Rini

Andrew, what features of George's version don't you like?

This is bad:

akpm:/usr/src/25> grep '^+#ifdef' patches/kgdb-ga.patch | wc -l

     83

and the fact that it touches 36 different files.

Been away from this for a while, but I do think this needs a comment. The fact that it touches 36 files is tilted rather strongly in that a good number of those files are in the Document/* tree. I.e. there is a rather larger amount of documentation.

As to the #ifdefs, I once worked on a kernel (HPUX if you must know) where you could NOT remove the debug stub and its bits. Turns out the kernel began to depend on the code that was supposed to be debugging it. I rather strongly try to avoid Heisenberg and the nasty thinks that arise from this sort of thing. I think you will find that most of those #ifdefs are "#ifdef CONFIG_KGDB" so that it you turn it off it is just as if the patch was not done (save the configure script, of course).

There is also the attempt to make one patch cover several kernels (such as in the 2.4 case where we may have O(1) or not) and also the preempt or not AND at the same time, want to debug the preempt code.

Quoted 5 lines

Any time I've had to do any maintenance work against that stub I get lost in a twisty maze and just whine at George about it. It's just all over the place. Yes, this is partly the nature of the beast, but I don't see that a ton of effort has been put into reducing the straggliness.

Yes, I agree. Some of this is caused by the need to work with a rather fixed interface to gdb. We would, for example, like to tell gdb to flush its cache from time to time. It would also be nice if gdb were to hint to us about what it was trying to do. The single step over a break point comes to mind here, as does the function call set up. Still, improvements can be made.

Quoted 1 line
Signature · 3 lines
George Anzinger   [email protected]
High-res-timers:  http://sourceforge.net/projects/high-res-timers/
Preemption patch: http://www.kernel.org/pub/linux/kernel/people/rml
#8 lore raw
In reply to Andrew Morton
Quoted 7 lines · Andrew Morton
Quoted 3 lines · Pavel Machek

It seems that some kgdb support is in 2.6.2-linus:

Quoted 7 lines

Lots of architectures have had in-kernel kgdb support for a long time. Just none of the three which I use :(

I wouldn't support inclusion of i386 kgdb until it has had a lot of cleanup, possible de-featuritisification and some thought has been applied to splitting it into arch and generic bits. It's quite a lot of work.

Amit has started at least the third activity--he has split much of kgdb into arch and generic bits.

Could you elaborate a little on the first two?

What major kinds of cleanup are we talking about? Style issues?

What features (or classes of features) do you find excessive? Would it be sufficient to add a few config items to control subfeatures of kgdb?

These are not idle questions. If the amount of work to get it ready for acceptance is tractable, I know a company that may be willing to pay to have the work done.

Quoted 7 lines

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

#9 lore raw

Hi!

Quoted 11 lines
Quoted 3 lines

I wouldn't support inclusion of i386 kgdb until it has had a lot of cleanup, possible de-featuritisification and some thought has been applied to splitting it into arch and generic bits. It's quite a lot of work.

Amit has started at least the third activity--he has split much of kgdb into arch and generic bits.

Could you elaborate a little on the first two?

What major kinds of cleanup are we talking about? Style issues?

Quoted 7 lines

What features (or classes of features) do you find excessive? Would it be sufficient to add a few config items to control subfeatures of kgdb?

These are not idle questions. If the amount of work to get it ready for acceptance is tractable, I know a company that may be willing to pay to have the work done.

Well, I guess I know two more such companies. Seems like everyone and their aunt want kgdb these days :-).
Pavel

Signature · 2 lines
When do you have a heart between your knees?
[Johanka's followup: and *two* hearts?]
#10 lore raw
In reply to La Monte H.P. Yarroll
Quoted 13 lines · La Monte H.P. Yarroll
Quoted 10 lines · Andrew Morton
Quoted 3 lines · Pavel Machek

It seems that some kgdb support is in 2.6.2-linus:

Lots of architectures have had in-kernel kgdb support for a long time. Just none of the three which I use :(

Quoted 8 lines
Quoted 5 lines

I wouldn't support inclusion of i386 kgdb until it has had a lot of cleanup, possible de-featuritisification and some thought has been applied to splitting it into arch and generic bits. It's quite a lot of work.

Amit has started at least the third activity--he has split much of kgdb into arch and generic bits.

Yes.

Quoted 3 lines

Could you elaborate a little on the first two?

What major kinds of cleanup are we talking about? Style issues?

Coding style compliance, reduction of ifdefs, etc. Reduction of patch footprint. There are a few features in the patch in -mm which I am not aware of anyone having used.

Quoted 4 lines

What features (or classes of features) do you find excessive? Would it be sufficient to add a few config items to control subfeatures of kgdb?

People have added timestamping infrastructure, stack overflow testing and inbuilt assertion frameworks to various gdb stubs at various times. We need to take a look at such things and really convice ourselves that they're worthwhile. Personally, I'd only be interested in the basic stub.

I need to take a look at Amit's current patch - it sounds good.

#11 lore raw

Hi!

Quoted 13 lines
Quoted 3 lines

Could you elaborate a little on the first two?

What major kinds of cleanup are we talking about? Style issues?

Coding style compliance, reduction of ifdefs, etc. Reduction of patch footprint. There are a few features in the patch in -mm which I am not aware of anyone having used.

Quoted 4 lines

What features (or classes of features) do you find excessive? Would it be sufficient to add a few config items to control subfeatures of kgdb?

Quoted 6 lines

People have added timestamping infrastructure, stack overflow testing and inbuilt assertion frameworks to various gdb stubs at various times. We need to take a look at such things and really convice ourselves that they're worthwhile. Personally, I'd only be interested in the basic stub.

I need to take a look at Amit's current patch - it sounds good.

Amit's version does not contain neither timestamping, nor assertions, nor overflows.

It has config option that allows it to hook into scheduling (CONFIG_KGDB_THREAD) that wraps schedules() with some code. Without that, patch is not intrusive at all. It would look like (untested, but you should get the idea):

[I combined i386, core and serial patch; that's minimum usefull configuration, and killed code inside CONFIG_KGDB_THREAD, as its a little intrusive. It does not look bad at all.]

Pavel

include/linux/debugger.h +0 -0
@@ -0,0 +1,67 @@

....definition of gdb_debug_hook and some functions to keep ifdef noise down...

include/linux/kgdb.h +0 -0
@@ -0,0 +1,113 @@

...definition of kgdb_breakpoint, kgdb_arch and kgdb_serial...

init/main.c +2 -0
@@ -39,6 +39,7 @@
 #include <linux/writeback.h>
 #include <linux/cpu.h>
 #include <linux/efi.h>
+#include <linux/debugger.h>
 
 #include <asm/io.h>
 #include <asm/bugs.h>
@@ -578,6 +579,7 @@ static int init(void * unused)
 	do_pre_smp_initcalls();
 
 	smp_init();
+	debugger_entry();
 	do_basic_setup();
 
 	prepare_namespace();
kernel/kgdbstub.c +0 -0
@@ -0,0 +1,1236 @@

...okay, here lies the debugger. It still could take some cleanups.

kernel/Makefile +1 -0
@@ -19,6 +19,7 @@ obj-$(CONFIG_BSD_PROCESS_ACCT) += acct.o
 obj-$(CONFIG_COMPAT) += compat.o
 obj-$(CONFIG_IKCONFIG) += configs.o
 obj-$(CONFIG_IKCONFIG_PROC) += configs.o
+obj-$(CONFIG_KGDB) += kgdbstub.o
 
 ifneq ($(CONFIG_IA64),y)
 # According to Alan Modra <[email protected]>, the -fno-omit-frame-pointer is
kernel/module.c +10 -0
@@ -727,6 +727,11 @@ sys_delete_module(const char __user *nam
 	mod->state = MODULE_STATE_GOING;
 	restart_refcounts();
 
+	down(&notify_mutex);
+	notifier_call_chain(&module_notify_list, MODULE_STATE_GOING,
+				mod);
+	up(&notify_mutex);
+
 	/* Never wait if forced. */
 	if (!forced && module_refcount(mod) != 0)
 		wait_for_zero_refcount(mod);
@@ -1744,7 +1749,12 @@ sys_init_module(void __user *umod,
 	if (ret < 0) {
 		/* Init routine failed: abort.  Try to protect us from
                    buggy refcounters. */
+
 		mod->state = MODULE_STATE_GOING;
+		down(&notify_mutex);
+		notifier_call_chain(&module_notify_list, MODULE_STATE_GOING,
+					mod);
+		up(&notify_mutex);
 		synchronize_kernel();
 		if (mod->unsafe)
 			printk(KERN_ERR "%s: module is now stuck!\n",
kernel/sched.c +3 -0
@@ -37,6 +37,7 @@
 #include <linux/rcupdate.h>
 #include <linux/cpu.h>
 #include <linux/percpu.h>
+#include <linux/debugger.h>
 
 #ifdef CONFIG_NUMA
 #define cpu_to_node_mask(cpu) node_to_cpumask(cpu_to_node(cpu))
@@ -2851,6 +2869,8 @@ void __might_sleep(char *file, int line)
 #if defined(in_atomic)
 	static unsigned long prev_jiffy;	/* ratelimiting */
 
+	if (atomic_read(&debugger_active))
+		return;
 	if ((in_atomic() || irqs_disabled()) && system_running) {
 		if (time_before(jiffies, prev_jiffy + HZ) && prev_jiffy)
 			return;
Makefile +2 -0
@@ -439,6 +439,8 @@ endif
 
 ifndef CONFIG_FRAME_POINTER
 CFLAGS		+= -fomit-frame-pointer
+else
+CFLAGS		+= -fno-omit-frame-pointer
 endif
 
 ifdef CONFIG_DEBUG_INFO
arch/i386/Kconfig +31 -0
@@ -1252,6 +1252,37 @@ config DEBUG_SPINLOCK_SLEEP
 	  If you say Y here, various routines which may sleep will become very
 	  noisy if they are called with a spinlock held.	
 
+config KGDB
+	bool "KGDB: kernel debugging with remote gdb"
+	depends on DEBUG_KERNEL
+	select DEBUG_INFO
+	select FRAME_POINTER
+	help
+	  If you say Y here, it will be possible to remotely debug the
+	  kernel using gdb. This enlarges your kernel image disk size by
+	  several megabytes and requires a machine with more than 128 MB
+	  RAM to avoid excessive linking time. 
+	  Documentation of kernel debugger available at
+	  http://kgdb.sourceforge.net
+	  This is only useful for kernel hackers. If unsure, say N.
+
+config KGDB_THREAD
+	bool "KGDB: Thread analysis"
+	depends on KGDB
+	help
+	  With thread analysis enabled, gdb can talk to kgdb stub to list
+	  threads and to get stack trace for a thread. This option also enables
+	  some code which helps gdb get exact status of thread. Thread analysis
+	  adds some overhead to schedule and down functions. You can disable
+	  this option if you do not want to compromise on speed.
+
+config KGDB_CONSOLE
+	bool "KGDB: Console messages through gdb"
+	depends on KGDB
+	help
+	  If you say Y here, console messages will appear through gdb.
+	  Other consoles such as tty or ttyS will continue to work as usual.
+
 config FRAME_POINTER
 	bool "Compile the kernel with frame pointers"
 	help
arch/i386/kernel/entry.S +10 -0
@@ -399,7 +399,17 @@ vector=vector+1
 	ALIGN
 common_interrupt:
 	SAVE_ALL
+	movl %esp, %eax
+/* Create a fake function call followed by a fake function prologue to fool
+ * gdb into believing that this is a normal function call. */
+	pushl EIP(%eax)
+
+common_interrupt_1:
+	pushl %ebp
+	movl %esp, %ebp
+	pushl %eax
 	call do_IRQ
+	addl $12, %esp
 	jmp ret_from_intr
 
 #define BUILD_INTERRUPT(name, nr)	\
arch/i386/kernel/i386-stub.c +0 -0
@@ -0,0 +1,457 @@

...and i386 dependend parts go here...

arch/i386/kernel/Makefile +1 -0
@@ -31,6 +31,7 @@ obj-y				+= sysenter.o vsyscall.o
 obj-$(CONFIG_ACPI_SRAT) 	+= srat.o
 obj-$(CONFIG_HPET_TIMER) 	+= time_hpet.o
 obj-$(CONFIG_EFI) 		+= efi.o efi_stub.o
+obj-$(CONFIG_KGDB)		+= i386-stub.o
 
 EXTRA_AFLAGS   := -traditional
 
arch/i386/kernel/nmi.c +13 -1
@@ -25,6 +25,7 @@
 #include <linux/module.h>
 #include <linux/nmi.h>
 #include <linux/sysdev.h>
+#include <linux/debugger.h>
 
 #include <asm/smp.h>
 #include <asm/mtrr.h>
@@ -420,14 +421,25 @@ void nmi_watchdog_tick (struct pt_regs *
 	int sum, cpu = smp_processor_id();
 
 	sum = irq_stat[cpu].apic_timer_irqs;
+	if (atomic_read(&debugger_active)) {
 
-	if (last_irq_sums[cpu] == sum) {
+		/*
+		 * The machine is in debugger, hold this cpu if already
+		 * not held.
+		 */
+		debugger_nmihook(cpu, regs);
+		alert_counter[cpu] = 0;
+
+	} else if (last_irq_sums[cpu] == sum) {
 		/*
 		 * Ayiee, looks like this CPU is stuck ...
 		 * wait a few IRQs (5 seconds) before doing the oops ...
 		 */
 		alert_counter[cpu]++;
 		if (alert_counter[cpu] == 5*nmi_hz) {
+
+			CHK_DEBUGGER(2,SIGSEGV,0,regs,)
+
 			spin_lock(&nmi_print_lock);
 			/*
 			 * We are in trouble anyway, lets at least try
arch/i386/kernel/signal.c +2 -1
@@ -580,7 +580,8 @@ int do_signal(struct pt_regs *regs, sigs
 		 * have been cleared if the watchpoint triggered
 		 * inside the kernel.
 		 */
-		__asm__("movl %0,%%db7"	: : "r" (current->thread.debugreg[7]));
+		if (current->thread.debugreg[7])
+			__asm__("movl %0,%%db7"	: : "r" (current->thread.debugreg[7]));
 
 		/* Whee!  Actually deliver the signal.  */
 		handle_signal(signr, &info, oldset, regs);
arch/i386/kernel/traps.c +15 -6
@@ -51,6 +51,7 @@
 
 #include <linux/irq.h>
 #include <linux/module.h>
+#include <linux/debugger.h>
 
 #include "mach_traps.h"
 
@@ -256,6 +257,7 @@ void die(const char * str, struct pt_reg
 {
 	static int die_counter;
 
+	CHK_DEBUGGER(1,SIGTRAP,err,regs,)
 	console_verbose();
 	spin_lock_irq(&die_lock);
 	bust_spinlocks(1);
@@ -330,6 +332,7 @@ static inline void do_trap(int trapnr, i
 #define DO_ERROR(trapnr, signr, str, name) \
 asmlinkage void do_##name(struct pt_regs * regs, long error_code) \
 { \
+	CHK_DEBUGGER(trapnr,signr,error_code,regs,)\
 	do_trap(trapnr, signr, str, 0, regs, error_code, NULL); \
 }
 
@@ -347,7 +350,10 @@ asmlinkage void do_##name(struct pt_regs
 #define DO_VM86_ERROR(trapnr, signr, str, name) \
 asmlinkage void do_##name(struct pt_regs * regs, long error_code) \
 { \
+	CHK_DEBUGGER(trapnr,signr,error_code,regs,goto skip_trap)\
 	do_trap(trapnr, signr, str, 1, regs, error_code, NULL); \
+skip_trap: \
+	return; \
 }
 
 #define DO_VM86_ERROR_INFO(trapnr, signr, str, name, sicode, siaddr) \
@@ -547,7 +553,7 @@ asmlinkage void do_debug(struct pt_regs 
 	tsk->thread.debugreg[6] = condition;
 
 	/* Mask out spurious TF errors due to lazy TF clearing */
-	if (condition & DR_STEP) {
+	if (condition & DR_STEP && !debugger_step) {
 		/*
 		 * The TF error should be masked out only if the current
 		 * process is not traced and if the TRAP flag has been set
@@ -570,11 +576,13 @@ asmlinkage void do_debug(struct pt_regs 
 	info.si_errno = 0;
 	info.si_code = TRAP_BRKPT;
 	
-	/* If this is a kernel mode trap, save the user PC on entry to 
-	 * the kernel, that's what the debugger can make sense of.
-	 */
-	info.si_addr = ((regs->xcs & 3) == 0) ? (void *)tsk->thread.eip : 
-	                                        (void *)regs->eip;
+
+	/* If this is a kernel mode trap, we need to reset db7 to allow us
+	 * to continue sanely */
+	if ((regs->xcs & 3) == 0)
+		goto clear_dr7;
+
+	info.si_addr = (void *)regs->eip;
 	force_sig_info(SIGTRAP, &info, tsk);
 
 	/* Disable additional traps. They'll be re-enabled when
@@ -584,6 +592,7 @@ clear_dr7:
 	__asm__("movl %0,%%db7"
 		: /* no output */
 		: "r" (0));
+	CHK_DEBUGGER(1,SIGTRAP,error_code,regs,)
 	return;
 
 debug_vm86:
arch/i386/mm/fault.c +14 -0
@@ -2,6 +2,11 @@
  *  linux/arch/i386/mm/fault.c
  *
  *  Copyright (C) 1995  Linus Torvalds
+ *
+ *  Change History
+ *
+ *	Tigran Aivazian <[email protected]>	Remote debugging support.
+ *
  */
 
 #include <linux/signal.h>
@@ -21,6 +26,7 @@
 #include <linux/vt_kern.h>		/* For unblank_screen() */
 #include <linux/highmem.h>
 #include <linux/module.h>
+#include <linux/debugger.h>
 
 #include <asm/system.h>
 #include <asm/uaccess.h>
@@ -262,6 +268,12 @@ asmlinkage void do_page_fault(struct pt_
 	if (in_atomic() || !mm)
 		goto bad_area_nosemaphore;
 
+	if (debugger_memerr_expected) {
+		/* This fault was caused by memory access through a debugger.
+		 * Don't handle it like user accesses */
+		goto no_context;
+	}
+
 	down_read(&mm->mmap_sem);
 
 	vma = find_vma(mm, address);
@@ -399,6 +411,8 @@ no_context:
  	if (is_prefetch(regs, address))
  		return;
 
+	CHK_DEBUGGER(14, SIGSEGV,error_code, regs,)
+
 /*
  * Oops. The kernel tried to access some bad page. We'll have to
  * terminate things with extreme prejudice.
include/asm-i386/kgdb.h +0 -0
@@ -0,0 +1,49 @@

....i386-specific kgdb stuff....

include/asm-i386/processor.h +2 -0
@@ -425,6 +426,8 @@ struct thread_struct {
 	unsigned int		saved_fs, saved_gs;
 /* IO permissions */
 	unsigned long	*io_bitmap_ptr;
+	void *		debuggerinfo;
+
 };
 
 #define INIT_THREAD  {							\
drivers/serial/8250.c +39 -0
@@ -1198,12 +1198,17 @@ static void serial8250_break_ctl(struct 
 	spin_unlock_irqrestore(&up->port.lock, flags);
 }
 
+static int released_irq = -1;
+
 static int serial8250_startup(struct uart_port *port)
 {
 	struct uart_8250_port *up = (struct uart_8250_port *)port;
 	unsigned long flags;
 	int retval;
 
+	if (up->port.irq == released_irq)
+		return -EBUSY;
+
 	up->capabilities = uart_config[up->port.type].flags;
 
 	if (up->port.type == PORT_16C950) {
@@ -1869,6 +1874,10 @@ static void __init serial8250_register_p
 	for (i = 0; i < UART_NR; i++) {
 		struct uart_8250_port *up = &serial8250_ports[i];
 
+		if (up->port.irq == released_irq) {
+			continue;
+		}
+
 		up->port.line = i;
 		up->port.ops = &serial8250_pops;
 		init_timer(&up->timer);
@@ -2138,6 +2147,36 @@ void serial8250_resume_port(int line)
 	uart_resume_port(&serial8250_reg, &serial8250_ports[line].port);
 }
 
+/*
+ * Find all the ports using the given irq and shut them down.
+ * Result should be that the irq will be released.
+ * At most one irq can be released this way.
+ * Once an irq is released, any attempts to initialize a port with that irq
+ * will fail with EBUSY.
+ */
+
+int serial8250_release_irq(int irq)
+{
+        struct uart_8250_port *up;
+	int ttyS;
+
+	if (released_irq != -1) {
+		return 1;
+	}
+	released_irq = irq;
+	for (ttyS = 0; ttyS < UART_NR; ttyS++){
+		up =  &serial8250_ports[ttyS];
+		if (up->port.irq == irq && (irq_lists + irq)->head) {
+#ifdef CONFIG_DEBUG_SPINLOCK   /* ugly business... */
+			if(up->port.lock.magic != SPINLOCK_MAGIC)
+				spin_lock_init(&up->port.lock);
+#endif
+			serial8250_shutdown(&up->port);
+		}
+        }
+	return 0;
+}
+
 static int __init serial8250_init(void)
 {
 	int ret, i;
drivers/serial/Kconfig +7 -0
diff -Naurp linux-2.6.1/drivers/serial/Kconfig linux-2.6.1-kgdb-2.1.0-8250/drivers/serial/Kconfig
@@ -6,6 +6,13 @@
 
 menu "Serial drivers"
 
+config KGDB_8250
+	bool "KGDB: On generic serial port (8250)"
+	depends on KGDB
+	help
+	  Uses generic serial port (8250) for kgdb. This is independent of the
+	  option 9250/16550 and compatible serial port.
+
 #
 # The new 8250/16550 serial drivers
 config SERIAL_8250
drivers/serial/kgdb_8250.c +0 -0
@@ -0,0 +1,408 @@

....second copy of serial driver I guess....

drivers/serial/Makefile +2 -0
@@ -32,3 +32,5 @@ obj-$(CONFIG_SERIAL_COLDFIRE) += mcfseri
 obj-$(CONFIG_V850E_UART) += v850e_uart.o
 obj-$(CONFIG_SERIAL98) += serial98.o
 obj-$(CONFIG_SERIAL_PMACZILOG) += pmac_zilog.o
+
+obj-$(CONFIG_KGDB_8250) += kgdb_8250.o
drivers/serial/serial_core.c +5 -1
@@ -1209,7 +1209,11 @@ static void uart_set_termios(struct tty_
 static void uart_close(struct tty_struct *tty, struct file *filp)
 {
 	struct uart_state *state = tty->driver_data;
-	struct uart_port *port = state->port;
+	struct uart_port *port;
+
+	if (!state)
+		return;
+	port = state->port;
 
 	BUG_ON(!kernel_locked());
 	DPRINTK("uart_close(%d) called\n", port->line);
Signature · 2 lines
When do you have a heart between your knees?
[Johanka's followup: and *two* hearts?]
#12 lore raw
In reply to Andrew Morton

Andrew Morton wrote:
~

Quoted 30 lines
Quoted 9 lines
Quoted 6 lines

I wouldn't support inclusion of i386 kgdb until it has had a lot of cleanup, possible de-featuritisification and some thought has been applied to splitting it into arch and generic bits. It's quite a lot of work.

Amit has started at least the third activity--he has split much of kgdb into arch and generic bits.

Yes.

Quoted 3 lines

Could you elaborate a little on the first two?

What major kinds of cleanup are we talking about? Style issues?

Coding style compliance, reduction of ifdefs, etc. Reduction of patch footprint. There are a few features in the patch in -mm which I am not aware of anyone having used.

Quoted 4 lines

What features (or classes of features) do you find excessive? Would it be sufficient to add a few config items to control subfeatures of kgdb?

Quoted 5 lines

People have added timestamping infrastructure, stack overflow testing and inbuilt assertion frameworks to various gdb stubs at various times. We need to take a look at such things and really convice ourselves that they're worthwhile. Personally, I'd only be interested in the basic stub.

Well, I have NEVER had a stack overflow, but then it is only a few lines. Likewise the assertions I think can go in favor of BUG and friends.

The timestamping I added at a time when the alternative that was suggested was LTT, which, at the time did not even come close to touching what I needed to do.
The timestamp code is designed to catch things that can only be observed when
running close to real speed. Especially on SMP systems, relative arrival times at spinlocks and friends can be very useful. Would there be less objection if we removed the configure option for it ;)

Signature · 3 lines
George Anzinger   [email protected]
High-res-timers:  http://sourceforge.net/projects/high-res-timers/
Preemption patch: http://www.kernel.org/pub/linux/kernel/people/rml
#13 lore raw
In reply to Pavel Machek
Quoted 12 lines · Pavel Machek

Hi!

It seems that some kgdb support is in 2.6.2-linus:

+++ b/Documentation/sh/kgdb.txt Tue Feb 3 19:45:43 2004

(quoted diff) +5 -0
@@ -0,0 +1,179 @@
+
+This file describes the configuration and behavior of KGDB for the SH
+kernel. Based on a description from Henry Bell <[email protected]>, it
+has been modified to account for quirks in the current implementation.
+
Quoted 3 lines

That's great, can we get i386 kgdb, too? Or at least amd64 kgdb ;-). [Or was it a mistake? It seems unlikely that kgdb could enter Linus tree without major flamewar...]

FWIW, there has been PPC32 KGDB support in kernel.org for ages. OTOH, I'm quite happy that SH kgdb support came in (mental note made to talk to Henry about the KGDB merging stuffs).

Signature · 2 lines
Tom Rini
http://gate.crashing.org/~trini/
#14 lore raw
Quoted 8 lines · Tom Rini
Quoted 8 lines

+++ b/Documentation/sh/kgdb.txt Tue Feb 3 19:45:43 2004

(quoted diff) +5 -0
@@ -0,0 +1,179 @@
+
+This file describes the configuration and behavior of KGDB for the SH
+kernel. Based on a description from Henry Bell <[email protected]>, it
+has been modified to account for quirks in the current implementation.
+
Quoted 8 lines
Quoted 3 lines

That's great, can we get i386 kgdb, too? Or at least amd64 kgdb ;-). [Or was it a mistake? It seems unlikely that kgdb could enter Linus tree without major flamewar...]

FWIW, there has been PPC32 KGDB support in kernel.org for ages. OTOH, I'm quite happy that SH kgdb support came in (mental note made to talk to Henry about the KGDB merging stuffs).

The SH kgdb work is a combination of effort by Henry Bell and Jeremy Siegel, (ST and MV both had their own versions, Jeremy did the sync work between the two) neither of which have touched it since mid 2.4 or so when it was first merged into the LinuxSH tree.

Getting the SH kgdb stuff updated is on my TODO list, I'd definitely be interested in getting this stuff in sync with Amit's work as well. Any pointers?

#15 lore raw
Quoted 17 lines · Paul Mundt
Quoted 8 lines · Tom Rini
Quoted 8 lines

+++ b/Documentation/sh/kgdb.txt Tue Feb 3 19:45:43 2004

(quoted diff) +5 -0
@@ -0,0 +1,179 @@
+
+This file describes the configuration and behavior of KGDB for the SH
+kernel. Based on a description from Henry Bell <[email protected]>, it
+has been modified to account for quirks in the current implementation.
+
Quoted 8 lines
Quoted 3 lines

That's great, can we get i386 kgdb, too? Or at least amd64 kgdb ;-). [Or was it a mistake? It seems unlikely that kgdb could enter Linus tree without major flamewar...]

FWIW, there has been PPC32 KGDB support in kernel.org for ages. OTOH, I'm quite happy that SH kgdb support came in (mental note made to talk to Henry about the KGDB merging stuffs).

Quoted 8 lines

The SH kgdb work is a combination of effort by Henry Bell and Jeremy Siegel, (ST and MV both had their own versions, Jeremy did the sync work between the two) neither of which have touched it since mid 2.4 or so when it was first merged into the LinuxSH tree.

Getting the SH kgdb stuff updated is on my TODO list, I'd definitely be interested in getting this stuff in sync with Amit's work as well. Any pointers?

What Amit has is at http://kgdb.sf.net/
What I've done on top of this is at bk://ppc.bkbits.net/linux-2.6-kgdb and http://www.codemonkey.org.uk/projects/bitkeeper/kgdb .

Signature · 2 lines
Tom Rini
http://gate.crashing.org/~trini/