All of lore.kernel.org
 help / color / mirror / Atom feed
* [Xenomai-core] kgdb over ipipe
@ 2006-04-08  9:16 Jan Kiszka
  2006-04-09 12:15 ` Jan Kiszka
  0 siblings, 1 reply; 7+ messages in thread
From: Jan Kiszka @ 2006-04-08  9:16 UTC (permalink / raw)
  To: xenomai-core, adeos-main


[-- Attachment #1.1: Type: text/plain, Size: 1460 bytes --]

Hi,

this is the preliminary, though already usable result of my recent
effort to extend the tool situation for Xenomai: A kgdb patch series for
2.6.15 on x86. It already works quite well but likely does not yet catch
all fatal scenarios (e.g. page faults in the Xenomai domain).

To apply it, you first need to run the standard kgdb patch series
against a vanilla 2.6.15 (I tested .3 and .5), and then extend that
series like follows:

prepare-kgdb-ipipe-x86.patch
adeos-ipipe-2.6.15-i386-1.2-01.patch
kgdb-ipipe.patch
kgdb-ipipe-x86.patch

Note that the adeos patch is also vanilla, i.e. unmodified! I
successfully tested the debugger (via serial cable) by putting a
breakpoint at rt_sem_v and then running the latency test - all fine.

You may want to patch gdb to improve its awareness of modules (see
kgdb.linsyssoft.com, I haven't tried yet), or you retrieve the module
base address (busybox's lsmod does this nicely e.g.) and issue
"add-symbol-file <path_to_your_module.ko> <base_address>" at the gdb prompt.

I once hacked RTAI's old hal patch and an old kgdb over 2.4 together.
That was definitely more patching work than this one here! I'm quite
confident that this time we will be able to maintain the debugger over a
longer period without too much effort. I also think that porting it over
other archs should be fairly easy.

But more on this will follow, I first have to apply the tool on a real
problem...

Jan

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.2: prepare-kgdb-ipipe-x86.patch --]
[-- Type: text/x-patch; name="prepare-kgdb-ipipe-x86.patch", Size: 838 bytes --]

Index: linux-2.6.15.5/arch/i386/kernel/entry.S
===================================================================
--- linux-2.6.15.5.orig/arch/i386/kernel/entry.S	2006-04-07 16:42:54.000000000 +0200
+++ linux-2.6.15.5/arch/i386/kernel/entry.S	2006-04-07 16:47:23.000000000 +0200
@@ -123,7 +123,7 @@
 .previous
 
 
-KPROBE_ENTRY(ret_from_fork)
+ENTRY(ret_from_fork)
 	pushl %eax
 	call schedule_tail
 	GET_THREAD_INFO(%ebp)
@@ -470,7 +470,7 @@
 	pushl $do_simd_coprocessor_error
 	jmp error_code
 
-KPROBE_ENTRY(device_not_available)
+ENTRY(device_not_available)
 	pushl $-1			# mark this as an int
 	SAVE_ALL
 	movl %cr0, %eax
@@ -652,7 +652,7 @@
 	jmp error_code
 #endif
 
-KPROBE_ENTRY(spurious_interrupt_bug)
+ENTRY(spurious_interrupt_bug)
 	pushl $0
 	pushl $do_spurious_interrupt_bug
 	jmp error_code

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.3: kgdb-ipipe.patch --]
[-- Type: text/x-patch; name="kgdb-ipipe.patch", Size: 5248 bytes --]

Index: linux-2.6.15.3-kgdb/kernel/kgdb.c
===================================================================
--- linux-2.6.15.3-kgdb.orig/kernel/kgdb.c	2006-04-08 04:54:37.000000000 +0200
+++ linux-2.6.15.3-kgdb/kernel/kgdb.c	2006-04-08 11:01:42.000000000 +0200
@@ -740,7 +740,7 @@
 	unsigned long flags;
 	int processor;
 
-	local_irq_save(flags);
+	local_irq_save_hw(flags);
 	processor = smp_processor_id();
 	kgdb_info[processor].debuggerinfo = regs;
 	kgdb_info[processor].task = current;
@@ -770,7 +770,7 @@
 	/* Signal the master processor that we are done */
 	atomic_set(&procindebug[processor], 0);
 	spin_unlock(&slavecpulocks[processor]);
-	local_irq_restore(flags);
+	local_irq_restore_hw(flags);
 }
 #endif
 
@@ -1033,7 +1033,7 @@
 	 * Interrupts will be restored by the 'trap return' code, except when
 	 * single stepping.
 	 */
-	local_irq_save(flags);
+	local_irq_save_hw(flags);
 
 	/* Hold debugger_active */
 	procid = smp_processor_id();
@@ -1056,7 +1056,7 @@
 	if (atomic_read(&cpu_doing_single_step) != -1 &&
 	    atomic_read(&cpu_doing_single_step) != procid) {
 		atomic_set(&debugger_active, 0);
-		local_irq_restore(flags);
+		local_irq_restore_hw(flags);
 		goto acquirelock;
 	}
 
@@ -1556,7 +1556,7 @@
 kgdb_restore:
 	/* Free debugger_active */
 	atomic_set(&debugger_active, 0);
-	local_irq_restore(flags);
+	local_irq_restore_hw(flags);
 
 	return error;
 }
@@ -1925,9 +1925,9 @@
 	if (!kgdb_connected || atomic_read(&debugger_active) != 0)
 		return 0;
 	if ((code == SYS_RESTART) || (code == SYS_HALT) || (code == SYS_POWER_OFF)){
-		local_irq_save(flags);
+		local_irq_save_hw(flags);
 		put_packet("X00");
-		local_irq_restore(flags);
+		local_irq_restore_hw(flags);
 	}
 	return NOTIFY_DONE;
 }		
@@ -1942,9 +1942,9 @@
 	if (!kgdb_connected || atomic_read(&debugger_active) != 0)
 		return;
 
-	local_irq_save(flags);
+	local_irq_save_hw(flags);
 	kgdb_msg_write(s, count);
-	local_irq_restore(flags);
+	local_irq_restore_hw(flags);
 }
 
 static struct console kgdbcons = {
Index: linux-2.6.15.3-kgdb/drivers/serial/8250_kgdb.c
===================================================================
--- linux-2.6.15.3-kgdb.orig/drivers/serial/8250_kgdb.c	2006-04-08 04:54:37.000000000 +0200
+++ linux-2.6.15.3-kgdb/drivers/serial/8250_kgdb.c	2006-04-08 11:01:42.000000000 +0200
@@ -301,6 +301,10 @@
 			"GDB-stub", current_port) < 0)
 		printk(KERN_ERR "KGDB failed to request the serial IRQ (%d)\n",
 		       current_port->irq);
+#ifdef CONFIG_IPIPE
+	ipipe_control_irq(current_port->irq, 0,
+			IPIPE_HANDLE_MASK|IPIPE_STICKY_MASK|IPIPE_SYSTEM_MASK);
+#endif /* CONFIG_IPIPE */
 }
 
 static __init int kgdb_init_io(void)
Index: linux-2.6.15.3-kgdb/include/linux/kgdb.h
===================================================================
--- linux-2.6.15.3-kgdb.orig/include/linux/kgdb.h	2006-04-08 04:54:37.000000000 +0200
+++ linux-2.6.15.3-kgdb/include/linux/kgdb.h	2006-04-08 11:01:42.000000000 +0200
@@ -271,5 +271,14 @@
 /* Stubs for when KGDB is not set. */
 static const atomic_t debugger_active = ATOMIC_INIT(0);
 #endif				/* CONFIG_KGDB */
+
+#ifdef CONFIG_IPIPE
+void kgdb_catch_domain(struct ipipe_domain *ipd);
+int kgdb_catch_event_allowed(unsigned event);
+#else /* !CONFIG_IPIPE */
+#define kgdb_catch_domain(ipd)
+#define kgdb_catch_event_allowed(event) 1
+#endif /* CONFIG_IPIPE */
+
 #endif				/* _KGDB_H_ */
 #endif				/* __KERNEL__ */
Index: linux-2.6.15.3-kgdb/kernel/ipipe/generic.c
===================================================================
--- linux-2.6.15.3-kgdb.orig/kernel/ipipe/generic.c	2006-04-08 04:54:37.000000000 +0200
+++ linux-2.6.15.3-kgdb/kernel/ipipe/generic.c	2006-04-08 11:01:42.000000000 +0200
@@ -29,6 +29,9 @@
 #ifdef CONFIG_PROC_FS
 #include <linux/proc_fs.h>
 #endif	/* CONFIG_PROC_FS */
+#ifdef CONFIG_KGDB
+#include <linux/kgdb.h>
+#endif	/* CONFIG_KGDB */
 
 MODULE_DESCRIPTION("I-pipe");
 MODULE_LICENSE("GPL");
@@ -106,6 +109,10 @@
 
 	printk(KERN_WARNING "I-pipe: Domain %s registered.\n", ipd->name);
 
+#ifdef CONFIG_KGDB
+	kgdb_catch_domain(ipd);
+#endif
+
 	/*
 	 * Finally, allow the new domain to perform its initialization
 	 * chores.
@@ -277,6 +284,11 @@
 		self = 1;
 	}
 
+#ifdef CONFIG_KGDB
+	if (!kgdb_catch_event_allowed(event))
+		return 0; /* silently ignore request */
+#endif
+
 	if (event >= IPIPE_NR_EVENTS)
 		return -EINVAL;
 
Index: linux-2.6.15.3-kgdb/lib/Kconfig.debug
===================================================================
--- linux-2.6.15.3-kgdb.orig/lib/Kconfig.debug	2006-04-08 04:54:37.000000000 +0200
+++ linux-2.6.15.3-kgdb/lib/Kconfig.debug	2006-04-08 11:01:42.000000000 +0200
@@ -250,7 +250,7 @@
 
 config KGDB_ONLY_MODULES
 	bool "KGDB: Use only kernel modules for I/O"
-	depends on MODULES
+	depends on MODULES && !IPIPE
 	help
 	  Use only kernel modules to configure KGDB I/O after the
 	  kernel is booted.
@@ -295,7 +295,7 @@
 endchoice
 
 config KGDBOE
-	tristate "KGDB: On ethernet" if !KGDBOE_NOMODULE
+	tristate "KGDB: On ethernet" if !KGDBOE_NOMODULE && !IPIPE
 	depends on m && KGDB
 	select NETPOLL
 	select NETPOLL_TRAP

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.4: kgdb-ipipe-x86.patch --]
[-- Type: text/x-patch; name="kgdb-ipipe-x86.patch", Size: 2652 bytes --]

Index: linux-2.6.15.3-kgdb/arch/i386/kernel/entry.S
===================================================================
--- linux-2.6.15.3-kgdb.orig/arch/i386/kernel/entry.S	2006-04-08 04:54:36.000000000 +0200
+++ linux-2.6.15.3-kgdb/arch/i386/kernel/entry.S	2006-04-08 11:01:52.000000000 +0200
@@ -194,7 +194,7 @@
 .previous
 
 
-ENTRY(ret_from_fork)
+KPROBE_ENTRY(ret_from_fork)
 	STI_COND_HW
 	pushl %eax
 	call schedule_tail
@@ -582,7 +582,7 @@
 	PUSH_XCODE(do_simd_coprocessor_error)
 	jmp error_code
 
-ENTRY(device_not_available)
+KPROBE_ENTRY(device_not_available)
 	pushl $-1			# mark this as an int
 	SAVE_ALL
 	DIVERT_EXCEPTION(device_not_available)
@@ -767,7 +767,7 @@
 	jmp error_code
 #endif
 
-ENTRY(spurious_interrupt_bug)
+KPROBE_ENTRY(spurious_interrupt_bug)
 	pushl $0
 	PUSH_XCODE(do_spurious_interrupt_bug)
 	jmp error_code
Index: linux-2.6.15.3-kgdb/arch/i386/kernel/ipipe-root.c
===================================================================
--- linux-2.6.15.3-kgdb.orig/arch/i386/kernel/ipipe-root.c	2006-04-08 04:54:36.000000000 +0200
+++ linux-2.6.15.3-kgdb/arch/i386/kernel/ipipe-root.c	2006-04-08 11:01:52.000000000 +0200
@@ -34,6 +34,9 @@
 #include <asm/irq.h>
 #include <asm/desc.h>
 #include <asm/io.h>
+#ifdef CONFIG_KGDB
+#include <linux/kgdb.h>
+#endif  /* CONFIG_KGDB */
 #ifdef CONFIG_X86_LOCAL_APIC
 #include <asm/tlbflush.h>
 #include <asm/fixmap.h>
@@ -248,6 +251,10 @@
 	ipipe_root_domain->irqs[IPIPE_SERVICE_IPI2].control &= ~IPIPE_SYSTEM_MASK;
 	ipipe_root_domain->irqs[IPIPE_SERVICE_IPI3].control &= ~IPIPE_SYSTEM_MASK;
 #endif	/* CONFIG_X86_LOCAL_APIC */
+
+#ifdef CONFIG_KGDB
+	kgdb_catch_domain(ipipe_root_domain);
+#endif
 }
 
 static inline void __fixup_if(struct pt_regs *regs)
Index: linux-2.6.15.3-kgdb/arch/i386/kernel/kgdb.c
===================================================================
--- linux-2.6.15.3-kgdb.orig/arch/i386/kernel/kgdb.c	2006-04-08 04:54:36.000000000 +0200
+++ linux-2.6.15.3-kgdb/arch/i386/kernel/kgdb.c	2006-04-08 11:01:52.000000000 +0200
@@ -362,3 +362,22 @@
 	.flags = KGDB_HW_BREAKPOINT,
 };
 
+#ifdef CONFIG_IPIPE
+int kgdb_catch_debug(unsigned event, struct ipipe_domain *ipd, void *data)
+{
+	struct pt_regs *regs = (struct pt_regs *)data;
+
+	return !kgdb_handle_exception(event, SIGTRAP, -1, regs);
+}
+
+void kgdb_catch_domain(struct ipipe_domain *ipd)
+{
+	ipipe_catch_event(ipd, 1, kgdb_catch_debug);
+	ipipe_catch_event(ipd, 3, kgdb_catch_debug);
+}
+
+int kgdb_catch_event_allowed(unsigned event)
+{
+	return ((event != 1) && (event != 3));
+}
+#endif /* CONFIG_IPIPE */

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 252 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2006-04-16 10:55 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-04-08  9:16 [Xenomai-core] kgdb over ipipe Jan Kiszka
2006-04-09 12:15 ` Jan Kiszka
2006-04-09 21:29   ` [Adeos-main] " Philippe Gerum
2006-04-11 19:57     ` Jan Kiszka
2006-04-11 20:20       ` Philippe Gerum
2006-04-11 21:34         ` Jan Kiszka
2006-04-16 10:55           ` Philippe Gerum

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.