⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sh-lite.patch

📁 Linux-2.6.18内核调试工具补丁程序KGDB。
💻 PATCH
📖 第 1 页 / 共 5 页
字号:
-Index: linux-2.6.16/arch/sh/Kconfig.debug===================================================================--- linux-2.6.16.orig/arch/sh/Kconfig.debug	2006-03-20 11:23:29.000000000 +0530+++ linux-2.6.16/arch/sh/Kconfig.debug	2006-04-25 11:34:01.000000000 +0530@@ -29,96 +29,4 @@ 	  This option is only useful porting the kernel to a new machine, 	  when the kernel may crash or hang before the serial console is 	  initialised. If unsure, say N.--config KGDB-	bool "Include KGDB kernel debugger"-	help-	  Include in-kernel hooks for kgdb, the Linux kernel source level-	  debugger.  See <http://kgdb.sourceforge.net/> for more information.-	  Unless you are intending to debug the kernel, say N here.--menu "KGDB configuration options"-	depends on KGDB--config MORE_COMPILE_OPTIONS-	bool "Add any additional compile options"-	help-	  If you want to add additional CFLAGS to the kernel build, enable this-	  option and then enter what you would like to add in the next question.-	  Note however that -g is already appended with the selection of KGDB.--config COMPILE_OPTIONS-	string "Additional compile arguments"-	depends on MORE_COMPILE_OPTIONS--config KGDB_NMI-	bool "Enter KGDB on NMI"-	default n--config KGDB_THREAD-	bool "Include KGDB thread support"-	default y--config SH_KGDB_CONSOLE-	bool "Console messages through GDB"-	default n--config KGDB_SYSRQ-	bool "Allow SysRq 'G' to enter KGDB"-	default y--config KGDB_KERNEL_ASSERTS-	bool "Include KGDB kernel assertions"-	default n--comment "Serial port setup"--config KGDB_DEFPORT-	int "Port number (ttySCn)"-	default "1"--config KGDB_DEFBAUD-	int "Baud rate"-	default "115200"--choice-	prompt "Parity"-	depends on KGDB-	default KGDB_DEFPARITY_N--config KGDB_DEFPARITY_N-	bool "None"--config KGDB_DEFPARITY_E-	bool "Even"--config KGDB_DEFPARITY_O-	bool "Odd"--endchoice--choice-	prompt "Data bits"-	depends on KGDB-	default KGDB_DEFBITS_8--config KGDB_DEFBITS_8-	bool "8"--config KGDB_DEFBITS_7-	bool "7"--endchoice--endmenu--config FRAME_POINTER-	bool "Compile the kernel with frame pointers"-	default y if KGDB-	help-	  If you say Y here the resulting kernel image will be slightly larger-	  and slower, but it will give very useful debugging information.-	  If you don't debug the kernel, you can say N, but we may not be able-	  to solve problems without frame pointers.- endmenuIndex: linux-2.6.16/arch/sh/Makefile===================================================================--- linux-2.6.16.orig/arch/sh/Makefile	2006-03-20 11:23:29.000000000 +0530+++ linux-2.6.16/arch/sh/Makefile	2006-04-25 11:34:01.000000000 +0530@@ -43,7 +43,6 @@ cflags-$(CONFIG_CPU_SH4A)		+= $(call cc-option,-m4a-nofpu,)  cflags-$(CONFIG_SH_DSP)			+= -Wa,-dsp-cflags-$(CONFIG_SH_KGDB)		+= -g  cflags-$(CONFIG_MORE_COMPILE_OPTIONS)	+= \ 	$(shell echo $(CONFIG_COMPILE_OPTIONS) | sed -e 's/"//g')Index: linux-2.6.16/arch/sh/boards/se/7751/setup.c===================================================================--- linux-2.6.16.orig/arch/sh/boards/se/7751/setup.c	2006-03-20 11:23:29.000000000 +0530+++ linux-2.6.16/arch/sh/boards/se/7751/setup.c	2006-04-25 11:34:01.000000000 +0530@@ -18,10 +18,6 @@ #include <asm/io.h> #include <asm/se7751/se7751.h> -#ifdef CONFIG_SH_KGDB-#include <asm/kgdb.h>-#endif- /*  * Configure the Super I/O chip  */@@ -83,12 +79,6 @@ 	return "7751 SolutionEngine"; } -#ifdef CONFIG_SH_KGDB-static int kgdb_uart_setup(void);-static struct kgdb_sermap kgdb_uart_sermap = -{ "ttyS", 0, kgdb_uart_setup, NULL };-#endif-  /*  * Initialize the board  */@@ -96,133 +86,4 @@ { 	/* Call init_smsc() replacement to set up SuperIO. */ 	/* XXX: RTC setting comes here */-#ifdef CONFIG_SH_KGDB-	kgdb_register_sermap(&kgdb_uart_sermap);-#endif-}--/*********************************************************************- * Currently a hack (e.g. does not interact well w/serial.c, lots of *- * hardcoded stuff) but may be useful if SCI/F needs debugging.      *- * Mostly copied from x86 code (see files asm-i386/kgdb_local.h and  *- * arch/i386/lib/kgdb_serial.c).                                     *- *********************************************************************/--#ifdef CONFIG_SH_KGDB-#include <linux/types.h>-#include <linux/serial.h>-#include <linux/serialP.h>-#include <linux/serial_reg.h>--#define COM1_PORT 0x3f8  /* Base I/O address */-#define COM1_IRQ  4      /* IRQ not used yet */-#define COM2_PORT 0x2f8  /* Base I/O address */-#define COM2_IRQ  3      /* IRQ not used yet */--#define SB_CLOCK 1843200 /* Serial baud clock */-#define SB_BASE (SB_CLOCK/16)-#define SB_MCR UART_MCR_OUT2 | UART_MCR_DTR | UART_MCR_RTS--struct uart_port {-	int base;-};-#define UART_NPORTS 2-struct uart_port uart_ports[] = {-	{ COM1_PORT },-	{ COM2_PORT },-};-struct uart_port *kgdb_uart_port;--#define UART_IN(reg)	inb_p(kgdb_uart_port->base + reg)-#define UART_OUT(reg,v)	outb_p((v), kgdb_uart_port->base + reg)--/* Basic read/write functions for the UART */-#define UART_LSR_RXCERR    (UART_LSR_BI | UART_LSR_FE | UART_LSR_PE)-static int kgdb_uart_getchar(void)-{-	int lsr;-	int c = -1;--	while (c == -1) {-		lsr = UART_IN(UART_LSR);-		if (lsr & UART_LSR_DR) -			c = UART_IN(UART_RX);-		if ((lsr & UART_LSR_RXCERR))-			c = -1;-	}-	return c;-}--static void kgdb_uart_putchar(int c)-{-	while ((UART_IN(UART_LSR) & UART_LSR_THRE) == 0)-		;-	UART_OUT(UART_TX, c);-}--/*- * Initialize UART to configured/requested values.- * (But we don't interrupts yet, or interact w/serial.c)- */-static int kgdb_uart_setup(void)-{-	int port;-	int lcr = 0;-	int bdiv = 0;--	if (kgdb_portnum >= UART_NPORTS) {-		KGDB_PRINTK("uart port %d invalid.\n", kgdb_portnum);-		return -1;-	}--	kgdb_uart_port = &uart_ports[kgdb_portnum];--	/* Init sequence from gdb_hook_interrupt */-	UART_IN(UART_RX);-	UART_OUT(UART_IER, 0);--	UART_IN(UART_RX);	/* Serial driver comments say */-	UART_IN(UART_IIR);	/* this clears interrupt regs */-	UART_IN(UART_MSR);--	/* Figure basic LCR values */-	switch (kgdb_bits) {-	case '7':-		lcr |= UART_LCR_WLEN7;-		break;-	default: case '8': -		lcr |= UART_LCR_WLEN8;-		break;-	}-	switch (kgdb_parity) {-	case 'O':-		lcr |= UART_LCR_PARITY;-		break;-	case 'E':-		lcr |= (UART_LCR_PARITY | UART_LCR_EPAR);-		break;-	default: break;-	}--	/* Figure the baud rate divisor */-	bdiv = (SB_BASE/kgdb_baud);-	-	/* Set the baud rate and LCR values */-	UART_OUT(UART_LCR, (lcr | UART_LCR_DLAB));-	UART_OUT(UART_DLL, (bdiv & 0xff));-	UART_OUT(UART_DLM, ((bdiv >> 8) & 0xff));-	UART_OUT(UART_LCR, lcr);--	/* Set the MCR */-	UART_OUT(UART_MCR, SB_MCR);--	/* Turn off FIFOs for now */-	UART_OUT(UART_FCR, 0);--	/* Setup complete: initialize function pointers */-	kgdb_getchar = kgdb_uart_getchar;-	kgdb_putchar = kgdb_uart_putchar;--	return 0; }-#endif /* CONFIG_SH_KGDB */Index: linux-2.6.16/arch/sh/mm/extable.c===================================================================--- linux-2.6.16.orig/arch/sh/mm/extable.c	2006-03-20 11:23:29.000000000 +0530+++ linux-2.6.16/arch/sh/mm/extable.c	2006-04-25 11:34:01.000000000 +0530@@ -6,6 +6,7 @@  #include <linux/config.h> #include <linux/module.h>+#include <linux/kgdb.h> #include <asm/uaccess.h>  int fixup_exception(struct pt_regs *regs)@@ -17,6 +18,12 @@ 		regs->pc = fixup->fixup; 		return 1; 	}+#ifdef CONFIG_KGDB+	if (atomic_read(&debugger_active) && kgdb_may_fault)+		/* Restore our previous state. */+		kgdb_fault_longjmp(kgdb_fault_jmp_regs);+		/* Never reached. */+#endif  	return 0; }Index: linux-2.6.16/arch/sh/mm/fault.c===================================================================--- linux-2.6.16.orig/arch/sh/mm/fault.c	2006-03-20 11:23:29.000000000 +0530+++ linux-2.6.16/arch/sh/mm/fault.c	2006-04-25 11:34:01.000000000 +0530@@ -28,7 +28,6 @@ #include <asm/pgalloc.h> #include <asm/mmu_context.h> #include <asm/cacheflush.h>-#include <asm/kgdb.h>  extern void die(const char *,struct pt_regs *,long); @@ -45,11 +44,6 @@ 	struct vm_area_struct * vma; 	unsigned long page; -#ifdef CONFIG_SH_KGDB-	if (kgdb_nofault && kgdb_bus_err_hook)-		kgdb_bus_err_hook();-#endif- 	tsk = current; 	mm = tsk->mm; @@ -153,6 +147,7 @@ 	} 	die("Oops", regs, writeaccess); 	do_exit(SIGKILL);+	dump_stack();  /*  * We ran out of memory, or some other thing happened to us that made@@ -202,11 +197,6 @@ 	spinlock_t *ptl; 	int ret = 1; -#ifdef CONFIG_SH_KGDB-	if (kgdb_nofault && kgdb_bus_err_hook)-		kgdb_bus_err_hook();-#endif- #ifdef CONFIG_SH_STORE_QUEUES 	addrmax = P4SEG_STORE_QUE + 0x04000000; #endifIndex: linux-2.6.16/arch/sh/mm/fault-nommu.c===================================================================--- linux-2.6.16.orig/arch/sh/mm/fault-nommu.c	2006-03-20 11:23:29.000000000 +0530+++ linux-2.6.16/arch/sh/mm/fault-nommu.c	2006-04-25 11:34:01.000000000 +0530@@ -29,10 +29,6 @@ #include <asm/mmu_context.h> #include <asm/cacheflush.h> -#if defined(CONFIG_SH_KGDB)-#include <asm/kgdb.h>-#endif- extern void die(const char *,struct pt_regs *,long);  /*@@ -43,11 +39,6 @@ asmlinkage void do_page_fault(struct pt_regs *regs, unsigned long writeaccess, 			      unsigned long address) {-#if defined(CONFIG_SH_KGDB)-	if (kgdb_nofault && kgdb_bus_err_hook)-		kgdb_bus_err_hook();-#endif- 	/* 	 * Oops. The kernel tried to access some bad page. We'll have to 	 * terminate things with extreme prejudice.@@ -69,11 +60,6 @@ asmlinkage int __do_page_fault(struct pt_regs *regs, unsigned long writeaccess, 			       unsigned long address) {-#if defined(CONFIG_SH_KGDB)-	if (kgdb_nofault && kgdb_bus_err_hook)-		kgdb_bus_err_hook();-#endif- 	if (address >= TASK_SIZE) 		return 1; Index: linux-2.6.16/arch/sh/kernel/kgdb-jmp.S===================================================================--- linux-2.6.16.orig/arch/sh/kernel/kgdb-jmp.S	2006-04-25 10:59:23.506518750 +0530+++ linux-2.6.16/arch/sh/kernel/kgdb-jmp.S	2006-04-25 11:34:01.000000000 +0530@@ -0,0 +1,32 @@+#include <linux/linkage.h>++ENTRY(kgdb_fault_setjmp)+	add	#(9*4), r4+	sts.l	pr, @-r4+	mov.l	r15, @-r4+	mov.l	r14, @-r4+	mov.l	r13, @-r4+	mov.l	r12, @-r4+	mov.l	r11, @-r4+	mov.l	r10, @-r4+	mov.l	r9, @-r4+	mov.l	r8, @-r4+	rts+	 mov	#0, r0++ENTRY(kgdb_fault_longjmp)+	mov.l	@r4+, r8+	mov.l	@r4+, r9+	mov.l	@r4+, r10+	mov.l	@r4+, r11+	mov.l	@r4+, r12+	mov.l	@r4+, r13+	mov.l	@r4+, r14+	mov.l	@r4+, r15+	lds.l	@r4+, pr+	mov	r5, r0+	tst	r0, r0+	bf	1f+	mov	#1, r0+1:	rts+	 nopIndex: linux-2.6.16/arch/sh/kernel/kgdb_stub.c===================================================================--- linux-2.6.16.orig/arch/sh/kernel/kgdb_stub.c	2006-03-20 11:23:29.000000000 +0530+++ linux-2.6.16/arch/sh/kernel/kgdb_stub.c	2006-04-25 10:59:23.506518750 +0530@@ -1,1491 +0,0 @@-/*- * May be copied or modified under the terms of the GNU General Public- * License.  See linux/COPYING for more information.- *- * Containes extracts from code by Glenn Engel, Jim Kingdon,- * David Grothe <dave@gcom.com>, Tigran Aivazian <tigran@sco.com>,- * Amit S. Kale <akale@veritas.com>,  William Gatliff <bgat@open-widgets.com>,- * Ben Lee, Steve Chamberlain and Benoit Miller <fulg@iname.com>.- * - * This version by Henry Bell <henry.bell@st.com>- * Minor modifications by Jeremy Siegel <jsiegel@mvista.com>- * - * Contains low-level support for remote debug using GDB. - *- * To enable debugger support, two things need to happen. A call to- * set_debug_traps() is necessary in order to allow any breakpoints- * or error conditions to be properly intercepted and reported to gdb.- * A breakpoint also needs to be generated to begin communication.  This- * is most easily accomplished by a call to breakpoint() which does- * a trapa if the initialisation phase has been successfully completed.- *- * In this case, set_debug_traps() is not used to "take over" exceptions;- * other kernel code is modified instead to enter the kgdb functions here- * when appropriate (see entry.S for breakpoint traps and NMI interrupts,- * see traps.c for kernel error exceptions).- *- * The following gdb commands are supported:- *- *    Command       Function                               Return value- *- *    g             return the value of the CPU registers  hex data or ENN- *    G             set the value of the CPU registers     OK or ENN- *- *    mAA..AA,LLLL  Read LLLL bytes at address AA..AA      hex data or ENN- *    MAA..AA,LLLL: Write LLLL bytes at address AA.AA      OK or ENN- *    XAA..AA,LLLL: Same, but data is binary (not hex)     OK or ENN- *- *    c             Resume at current address              SNN   ( signal NN)- *    cAA..AA       Continue at address AA..AA             SNN- *    CNN;          Resume at current address with signal  SNN- *    CNN;AA..AA    Resume at address AA..AA with signal   SNN- *- *    s             Step one instruction                   SNN- *    sAA..AA       Step one instruction from AA..AA       SNN- *    SNN;          Step one instruction with signal       SNN- *    SNNAA..AA     Step one instruction from AA..AA w/NN  SNN- *- *    k             kill (Detach GDB)- *- *    d             Toggle debug flag- *    D             Detach GDB - *- *    Hct           Set thread t for operations,           OK or ENN- *                  c = 'c' (step, cont), c = 'g' (other- *                  operations)- *- *    qC            Query current thread ID                QCpid- *    qfThreadInfo  Get list of current threads (first)    m<id>- *    qsThreadInfo   "    "  "     "      "   (subsequent)- *    qOffsets      Get section offsets                  Text=x;Data=y;Bss=z- * - *    TXX           Find if thread XX is alive             OK or ENN- *    ?             What was the last sigval ?             SNN   (signal NN)- *    O             Output to GDB console- *- * Remote communication protocol.- *- *    A debug packet whose contents are <data> is encapsulated for- *    transmission in the form:

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -