1 l-mpm/Documentation/i386/kgdb/kgdbeth.txt | 88 +----
2 l-mpm/arch/i386/kernel/irq.c | 10
3 l-mpm/arch/i386/kernel/kgdb_stub.c | 107 +-----
4 l-mpm/arch/i386/lib/kgdb_serial.c | 2
5 l-mpm/drivers/net/Makefile | 5
6 l-mpm/drivers/net/kgdb_eth.c | 464 ++++--------------------------
7 l-mpm/include/asm-i386/kgdb.h | 11
8 l-mpm/net/core/dev.c | 4
9 8 files changed, 129 insertions(+), 562 deletions(-)
11 Index: linux-2.6.0-test6/drivers/net/kgdb_eth.c
12 ===================================================================
13 --- linux-2.6.0-test6.orig/drivers/net/kgdb_eth.c 2003-10-12 13:12:22.000000000 +0800
14 +++ linux-2.6.0-test6/drivers/net/kgdb_eth.c 2003-10-12 13:12:25.000000000 +0800
17 * Twiddled for 2.6 by Robert Walsh <rjwalsh@durables.org>
18 * and wangdi <wangdi@clusterfs.com>.
20 + * Refactored for netpoll API by Matt Mackall <mpm@selenic.com>
24 -#include <linux/module.h>
25 -#include <linux/errno.h>
26 -#include <linux/signal.h>
27 #include <linux/sched.h>
28 -#include <linux/timer.h>
29 #include <linux/interrupt.h>
30 #include <linux/config.h>
31 -#include <linux/major.h>
32 #include <linux/string.h>
33 -#include <linux/fcntl.h>
34 -#include <linux/termios.h>
35 -#include <asm/kgdb.h>
36 -#include <linux/if_ether.h>
37 -#include <linux/netdevice.h>
38 -#include <linux/etherdevice.h>
39 -#include <linux/skbuff.h>
40 -#include <linux/delay.h>
43 +#include <linux/netpoll.h>
45 #include <asm/system.h>
46 +#include <asm/kgdb.h>
48 -#include <asm/segment.h>
49 #include <asm/bitops.h>
50 #include <asm/system.h>
52 #include <asm/atomic.h>
55 #define GDB_BUF_SIZE 512 /* power of 2, please */
57 static char kgdb_buf[GDB_BUF_SIZE] ;
59 static atomic_t kgdb_buf_in_cnt ;
60 static int kgdb_buf_out_inx ;
62 +#define ETH_QUEUE_SIZE 256
63 +static char eth_queue[ETH_QUEUE_SIZE];
64 +static int outgoing_queue;
66 extern void set_debug_traps(void) ; /* GDB routine */
67 extern void breakpoint(void);
69 -unsigned int kgdb_remoteip = 0;
70 -unsigned short kgdb_listenport = 6443;
71 -unsigned short kgdb_sendport= 6442;
72 -int kgdb_eth = -1; /* Default tty mode */
73 -unsigned char kgdb_remotemac[6] = {0xff,0xff,0xff,0xff,0xff,0xff};
74 -unsigned char kgdb_localmac[6] = {0xff,0xff,0xff,0xff,0xff,0xff};
75 -volatile int kgdb_eth_is_initializing = 0;
76 -int kgdb_eth_need_breakpoint[NR_CPUS];
77 +int kgdboe = 0; /* Default tty mode */
78 +int kgdb_eth_need_breakpoint[NR_CPUS];
80 -struct net_device *kgdb_netdevice = NULL;
81 +static void rx_hook(struct netpoll *np, int port, char *msg, int len);
84 - * Get a char if available, return -1 if nothing available.
85 - * Empty the receive buffer first, then look at the interface hardware.
89 +static struct netpoll np = {
94 + .remote_port = 6442,
95 + .remote_mac = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff},
98 +static int read_char(void)
100 /* intr routine has queued chars */
101 if (atomic_read(&kgdb_buf_in_cnt) != 0)
103 return -1; /* no data */
107 - * Wait until the interface can accept a char, then write it.
110 -write_buffer(char *buf, int len)
111 +static void write_buffer(char *buf, int len)
113 - int total_len, eth_len, ip_len, udp_len;
114 - struct in_device *in_dev;
115 - struct sk_buff *skb;
116 - struct udphdr *udph;
118 - struct ethhdr *eth;
120 - if (!(in_dev = (struct in_device *) kgdb_netdevice->ip_ptr)) {
121 - panic("No in_device available for interface!\n");
124 - if (!(in_dev->ifa_list)) {
125 - panic("No interface address set for interface!\n");
128 - udp_len = len + sizeof(struct udphdr);
129 - ip_len = eth_len = udp_len + sizeof(struct iphdr);
130 - total_len = eth_len + ETH_HLEN;
132 - if (!(skb = alloc_skb(total_len, GFP_ATOMIC))) {
137 - atomic_set(&skb->users, 1);
138 - skb_reserve(skb, total_len - len);
140 - memcpy(skb->data, (unsigned char *) buf, len);
143 - udph = (struct udphdr *) skb_push(skb, sizeof(*udph));
144 - udph->source = htons(kgdb_listenport);
145 - udph->dest = htons(kgdb_sendport);
146 - udph->len = htons(udp_len);
149 - iph = (struct iphdr *)skb_push(skb, sizeof(*iph));
153 - iph->tot_len = htons(ip_len);
157 - iph->protocol = IPPROTO_UDP;
159 - iph->saddr = in_dev->ifa_list->ifa_address;
160 - iph->daddr = kgdb_remoteip;
161 - iph->check = ip_fast_csum((unsigned char *)iph, iph->ihl);
163 - eth = (struct ethhdr *) skb_push(skb, ETH_HLEN);
164 - eth->h_proto = htons(ETH_P_IP);
165 - memcpy(eth->h_source, kgdb_localmac, kgdb_netdevice->addr_len);
166 - memcpy(eth->h_dest, kgdb_remotemac, kgdb_netdevice->addr_len);
169 - spin_lock(&kgdb_netdevice->xmit_lock);
170 - kgdb_netdevice->xmit_lock_owner = smp_processor_id();
172 - if (netif_queue_stopped(kgdb_netdevice)) {
173 - kgdb_netdevice->xmit_lock_owner = -1;
174 - spin_unlock(&kgdb_netdevice->xmit_lock);
176 - kgdb_netdevice->poll_controller(kgdb_netdevice);
180 - kgdb_netdevice->hard_start_xmit(skb, kgdb_netdevice);
181 - kgdb_netdevice->xmit_lock_owner = -1;
182 - spin_unlock(&kgdb_netdevice->xmit_lock);
183 + netpoll_send_udp(&np, buf, len);
187 - * In the interrupt state the target machine will not respond to any
188 - * arp requests, so handle them here.
191 -static struct sk_buff *send_skb = NULL;
194 -kgdb_eth_reply_arp(void)
197 - spin_lock(&kgdb_netdevice->xmit_lock);
198 - kgdb_netdevice->xmit_lock_owner = smp_processor_id();
199 - kgdb_netdevice->hard_start_xmit(send_skb, kgdb_netdevice);
200 - kgdb_netdevice->xmit_lock_owner = -1;
201 - spin_unlock(&kgdb_netdevice->xmit_lock);
207 -make_arp_request(struct sk_buff *skb)
209 - struct arphdr *arp;
210 - unsigned char *arp_ptr;
211 - int type = ARPOP_REPLY;
212 - int ptype = ETH_P_ARP;
214 - unsigned char *sha, *tha;
215 - struct in_device *in_dev = (struct in_device *) kgdb_netdevice->ip_ptr;
217 - /* No arp on this interface */
219 - if (kgdb_netdevice->flags & IFF_NOARP) {
223 - if (!pskb_may_pull(skb, (sizeof(struct arphdr) +
224 - (2 * kgdb_netdevice->addr_len) +
225 - (2 * sizeof(u32))))) {
229 - skb->h.raw = skb->nh.raw = skb->data;
230 - arp = skb->nh.arph;
232 - if ((arp->ar_hrd != htons(ARPHRD_ETHER) &&
233 - arp->ar_hrd != htons(ARPHRD_IEEE802)) ||
234 - arp->ar_pro != htons(ETH_P_IP)) {
238 - /* Understand only these message types */
240 - if (arp->ar_op != htons(ARPOP_REQUEST)) {
244 - /* Extract fields */
246 - arp_ptr= (unsigned char *)(arp+1);
248 - arp_ptr += kgdb_netdevice->addr_len;
249 - memcpy(&sip, arp_ptr, 4);
252 - arp_ptr += kgdb_netdevice->addr_len;
253 - memcpy(&tip, arp_ptr, 4);
255 - if (tip != in_dev->ifa_list->ifa_address) {
259 - if (kgdb_remoteip != sip) {
264 - * Check for bad requests for 127.x.x.x and requests for multicast
265 - * addresses. If this is one such, delete it.
268 - if (LOOPBACK(tip) || MULTICAST(tip)) {
272 - /* reply to the ARP request */
274 - send_skb = alloc_skb(sizeof(struct arphdr) + 2 * (kgdb_netdevice->addr_len + 4) + LL_RESERVED_SPACE(kgdb_netdevice), GFP_ATOMIC);
276 - if (send_skb == NULL) {
280 - skb_reserve(send_skb, LL_RESERVED_SPACE(kgdb_netdevice));
281 - send_skb->nh.raw = send_skb->data;
282 - arp = (struct arphdr *) skb_put(send_skb, sizeof(struct arphdr) + 2 * (kgdb_netdevice->addr_len + 4));
283 - send_skb->dev = kgdb_netdevice;
284 - send_skb->protocol = htons(ETH_P_ARP);
286 - /* Fill the device header for the ARP frame */
288 - if (kgdb_netdevice->hard_header &&
289 - kgdb_netdevice->hard_header(send_skb, kgdb_netdevice, ptype,
290 - kgdb_remotemac, kgdb_localmac,
291 - send_skb->len) < 0) {
292 - kfree_skb(send_skb);
297 - * Fill out the arp protocol part.
299 - * we only support ethernet device type,
300 - * which (according to RFC 1390) should always equal 1 (Ethernet).
303 - arp->ar_hrd = htons(kgdb_netdevice->type);
304 - arp->ar_pro = htons(ETH_P_IP);
306 - arp->ar_hln = kgdb_netdevice->addr_len;
308 - arp->ar_op = htons(type);
310 - arp_ptr=(unsigned char *)(arp + 1);
312 - memcpy(arp_ptr, kgdb_netdevice->dev_addr, kgdb_netdevice->addr_len);
313 - arp_ptr += kgdb_netdevice->addr_len;
314 - memcpy(arp_ptr, &tip, 4);
316 - memcpy(arp_ptr, kgdb_localmac, kgdb_netdevice->addr_len);
317 - arp_ptr += kgdb_netdevice->addr_len;
318 - memcpy(arp_ptr, &sip, 4);
324 * Accept an skbuff from net_device layer and add the payload onto
327 - * When the kgdb stub routine getDebugChar() is called it draws characters
328 - * out of the buffer until it is empty and then reads directly from the
331 - * We do not attempt to write chars from the interrupt routine since
332 - * the stubs do all of that via putDebugChar() which writes one byte
333 - * after waiting for the interface to become ready.
335 - * The debug stubs like to run with interrupts disabled since, after all,
336 - * they run as a consequence of a breakpoint in the kernel.
338 - * NOTE: Return value of 1 means it was for us and is an indication to
339 - * the calling driver to destroy the sk_buff and not send it up the stack.
342 -kgdb_net_interrupt(struct sk_buff *skb)
343 +static void rx_hook(struct netpoll *np, int port, char *msg, int len)
346 - struct iphdr *iph = (struct iphdr*)skb->data;
347 - struct udphdr *udph= (struct udphdr*)(skb->data+(iph->ihl<<2));
348 - unsigned char *data = (unsigned char *) udph + sizeof(struct udphdr);
352 - if ((kgdb_eth != -1) && (!kgdb_netdevice) &&
353 - (iph->protocol == IPPROTO_UDP) &&
354 - (be16_to_cpu(udph->dest) == kgdb_listenport)) {
355 - kgdb_sendport = be16_to_cpu(udph->source);
357 - while (kgdb_eth_is_initializing)
359 - if (!kgdb_netdevice)
361 - if (!kgdb_netdevice) {
362 - /* Lets not even try again. */
367 - if (!kgdb_netdevice) {
370 - if (skb->protocol == __constant_htons(ETH_P_ARP) && !send_skb) {
371 - make_arp_request(skb);
374 - if (iph->protocol != IPPROTO_UDP) {
379 - if (be16_to_cpu(udph->dest) != kgdb_listenport) {
382 + np->remote_port = port;
384 - len = (be16_to_cpu(iph->tot_len) -
385 - (sizeof(struct udphdr) + sizeof(struct iphdr)));
386 + /* Is this gdb trying to attach? */
387 + if (!netpoll_trap() && len == 8 && !strncmp(msg, "$Hc-1#09", 8))
388 + kgdb_schedule_breakpoint();
390 for (i = 0; i < len; i++) {
393 - kgdb_eth_need_breakpoint[smp_processor_id()] = 1;
398 + kgdb_schedule_breakpoint();
400 if (atomic_read(&kgdb_buf_in_cnt) >= GDB_BUF_SIZE) {
401 /* buffer overflow, clear it */
403 @@ -371,112 +108,54 @@
404 kgdb_buf_in_inx &= (GDB_BUF_SIZE - 1);
405 atomic_inc(&kgdb_buf_in_cnt);
408 - if (!kgdb_netdevice->kgdb_is_trapped) {
410 - * If a new gdb instance is trying to attach, we need to
413 - if (!strncmp(data, "$Hc-1#09", 8))
414 - kgdb_eth_need_breakpoint[smp_processor_id()] = 1;
418 -EXPORT_SYMBOL(kgdb_net_interrupt);
422 +static int option_setup(char *opt)
424 - char kgdb_netdev[16];
425 - extern void kgdb_respond_ok(void);
427 - if (kgdb_remotemac[0] == 0xff) {
428 - panic("ERROR! 'gdbeth_remotemac' option not set!\n");
430 - if (kgdb_localmac[0] == 0xff) {
431 - panic("ERROR! 'gdbeth_localmac' option not set!\n");
433 - if (kgdb_remoteip == 0) {
434 - panic("ERROR! 'gdbeth_remoteip' option not set!\n");
436 + return netpoll_parse_options(&np, opt);
439 - sprintf(kgdb_netdev,"eth%d",kgdb_eth);
440 +__setup("kgdboe=", option_setup);
442 +static int init_kgdboe(void)
445 if (num_online_cpus() > CONFIG_NO_KGDB_CPUS) {
446 printk("kgdb: too manu cpus. Cannot enable debugger with more than %d cpus\n", CONFIG_NO_KGDB_CPUS);
450 - for (kgdb_netdevice = dev_base;
451 - kgdb_netdevice != NULL;
452 - kgdb_netdevice = kgdb_netdevice->next) {
453 - if (strncmp(kgdb_netdevice->name, kgdb_netdev, IFNAMSIZ) == 0) {
457 - if (!kgdb_netdevice) {
458 - printk("KGDB NET : Unable to find interface %s\n",kgdb_netdev);
463 - * Call GDB routine to setup the exception vectors for the debugger
468 - * Call the breakpoint() routine in GDB to start the debugging
471 - kgdb_eth_is_initializing = 1;
472 - kgdb_eth_need_breakpoint[smp_processor_id()] = 1;
473 + if(!np.remote_ip || netpoll_setup(&np))
478 + printk(KERN_INFO "kgdb: debugging over ethernet enabled\n");
486 - * This is a GDB stub routine. It waits for a character from the
487 - * serial interface and then returns it. If there is no serial
488 - * interface connection then it returns a bogus value which will
489 - * almost certainly cause the system to hang.
492 -eth_getDebugChar(void)
493 +int eth_getDebugChar(void)
498 - while ((chr = read_char()) < 0) {
500 - kgdb_eth_reply_arp();
502 - if (kgdb_netdevice->poll_controller) {
503 - kgdb_netdevice->poll_controller(kgdb_netdevice);
505 - printk("KGDB NET: Error - Device %s is not supported!\n", kgdb_netdevice->name);
506 - panic("Please add support for kgdb net to this driver");
509 + while ((chr = read_char()) < 0)
514 -#define ETH_QUEUE_SIZE 256
515 -static char eth_queue[ETH_QUEUE_SIZE];
516 -static int outgoing_queue;
519 -eth_flushDebugChar(void)
520 +void eth_flushDebugChar(void)
523 write_buffer(eth_queue, outgoing_queue);
530 -put_char_on_queue(int chr)
531 +static void put_char_on_queue(int chr)
533 eth_queue[outgoing_queue++] = chr;
534 if(outgoing_queue == ETH_QUEUE_SIZE)
535 @@ -485,33 +164,26 @@
542 - * This is a GDB stub routine. It waits until the interface is ready
543 - * to transmit a char and then sends it.
546 -eth_putDebugChar(int chr)
547 +void eth_putDebugChar(int chr)
549 put_char_on_queue(chr); /* this routine will wait */
553 -kgdb_eth_set_trapmode(int mode)
554 +void kgdb_schedule_breakpoint(void)
556 - if (!kgdb_netdevice) {
559 - kgdb_netdevice->kgdb_is_trapped = mode;
560 + kgdb_eth_need_breakpoint[smp_processor_id()] = 1;
564 -kgdb_eth_is_trapped()
565 +void kgdb_process_breakpoint(void)
567 - if (!kgdb_netdevice) {
570 + * Handle a breakpoint queued from inside network driver code
571 + * to avoid reentrancy issues
573 + if (kgdb_eth_need_breakpoint[smp_processor_id()]) {
574 + kgdb_eth_need_breakpoint[smp_processor_id()] = 0;
577 - return kgdb_netdevice->kgdb_is_trapped;
579 -EXPORT_SYMBOL(kgdb_eth_is_trapped);
581 +module_init(init_kgdboe);
582 Index: linux-2.6.0-test6/arch/i386/kernel/kgdb_stub.c
583 ===================================================================
584 --- linux-2.6.0-test6.orig/arch/i386/kernel/kgdb_stub.c 2003-10-12 13:12:22.000000000 +0800
585 +++ linux-2.6.0-test6/arch/i386/kernel/kgdb_stub.c 2003-10-12 18:57:21.625083056 +0800
587 #include <asm/desc.h>
588 #include <linux/inet.h>
589 #include <linux/kallsyms.h>
590 +#include <linux/netpoll.h>
592 /************************************************************************
595 extern int eth_putDebugChar(int); /* write a single character */
596 extern int eth_getDebugChar(void); /* read and return a single char */
597 extern void eth_flushDebugChar(void); /* flush pending characters */
598 -extern void kgdb_eth_set_trapmode(int);
599 -extern void kgdb_eth_reply_arp(void); /*send arp request */
600 -extern volatile int kgdb_eth_is_initializing;
603 /************************************************************************/
604 /* BUFMAX defines the maximum number of characters in inbound/outbound buffers*/
605 @@ -281,13 +278,13 @@
608 * I/O dispatch functions...
609 - * Based upon kgdb_eth, either call the ethernet
610 + * Based upon kgdboe, either call the ethernet
611 * handler or the serial one..
616 - if (kgdb_eth == -1) {
625 - if (kgdb_eth == -1) {
627 return tty_getDebugChar();
629 return eth_getDebugChar();
634 - if (kgdb_eth == -1) {
636 tty_flushDebugChar();
638 eth_flushDebugChar();
639 @@ -494,66 +491,24 @@
641 /* $<packet info>#<checksum>. */
643 - if (kgdb_eth == -1) {
646 - printk("T:%s\n", buffer);
651 - while ((ch = buffer[count])) {
658 - putDebugChar(hexchars[checksum >> 4]);
659 - putDebugChar(hexchars[checksum % 16]);
662 - } while ((getDebugChar() & 0x7f) != '+');
665 - * For udp, we can not transfer too much bytes once.
666 - * We only transfer MAX_SEND_COUNT size bytes each time
669 -#define MAX_SEND_COUNT 30
671 - int send_count = 0, i = 0;
672 - char send_buf[MAX_SEND_COUNT];
675 + printk("T:%s\n", buffer);
679 + while ((ch = buffer[count])) {
686 + putDebugChar(hexchars[checksum >> 4]);
687 + putDebugChar(hexchars[checksum % 16]);
692 - printk("T:%s\n", buffer);
697 - while ((ch = buffer[count])) {
698 - if (send_count >= MAX_SEND_COUNT) {
699 - for(i = 0; i < MAX_SEND_COUNT; i++) {
700 - putDebugChar(send_buf[i]);
705 - send_buf[send_count] = ch;
711 - for(i = 0; i < send_count; i++)
712 - putDebugChar(send_buf[i]);
714 - putDebugChar(hexchars[checksum >> 4]);
715 - putDebugChar(hexchars[checksum % 16]);
717 - } while ((getDebugChar() & 0x7f) != '+');
719 + } while ((getDebugChar() & 0x7f) != '+');
722 static char remcomInBuffer[BUFMAX];
723 @@ -1142,9 +1097,9 @@
725 in_kgdb_entry_log[cpu]++;
726 in_kgdb_here_log[cpu] = regs;
727 - if (cpu == spinlock_cpu || waiting_cpus[cpu].task) {
728 + if (cpu == spinlock_cpu || waiting_cpus[cpu].task)
733 * For protection of the initilization of the spin locks by kgdb
734 * it locks the kgdb spinlock before it gets the wait locks set
735 @@ -1153,16 +1108,18 @@
736 * sequence where the wait lock is removed prior to the kgdb lock
737 * so if kgdb gets unlocked, we just exit.
740 while (spin_is_locked(&kgdb_spinlock) &&
741 !spin_is_locked(waitlocks + cpu)) ;
742 - if (!spin_is_locked(&kgdb_spinlock)) {
743 + if (!spin_is_locked(&kgdb_spinlock))
747 waiting_cpus[cpu].task = current;
748 waiting_cpus[cpu].pid = (current->pid) ? : (PID_MAX + cpu);
749 waiting_cpus[cpu].regs = regs;
751 spin_unlock_wait(waitlocks + cpu);
754 * log departure of this cpu
756 @@ -1281,9 +1238,8 @@
758 __asm__("movl %%cr2,%0":"=r" (address));
760 - if (kgdb_eth != -1) {
761 - kgdb_eth_set_trapmode(1);
764 + netpoll_set_trap(1);
766 kgdb_local_irq_save(flags);
768 @@ -1338,10 +1294,12 @@
769 if (num_online_cpus() > 1) {
770 int me_in_kgdb = in_kgdb_entry_log[smp_processor_id()];
771 smp_send_nmi_allbutself();
773 while (i < num_online_cpus() && time != end_time) {
775 for (j = 0; j < MAX_NO_CPUS; j++) {
776 if (waiting_cpus[j].task &&
777 + waiting_cpus[j].task != NOCPU &&
780 cpu_logged_in[j] = 1;
781 @@ -1526,13 +1484,8 @@
782 remcomOutBuffer[2] = hexchars[signo % 16];
783 remcomOutBuffer[3] = 0;
785 - if (kgdb_eth_is_initializing) {
786 - kgdb_eth_is_initializing = 0;
788 - putpacket(remcomOutBuffer);
790 + putpacket(remcomOutBuffer);
792 - kgdb_eth_reply_arp();
795 remcomOutBuffer[0] = 0;
796 @@ -1689,10 +1642,6 @@
800 - if (kgdb_eth != -1) {
801 - kgdb_eth_set_trapmode(0);
804 /* clear the trace bit */
805 regs.eflags &= 0xfffffeff;
807 @@ -1724,6 +1673,10 @@
813 + netpoll_set_trap(0);
816 asm volatile ("movl %0, %%db6\n"::"r" (0));
818 @@ -2430,63 +2383,3 @@
819 int signo, int err_code, struct pt_regs *linux_regs);
820 gdb_debug_hook *linux_debug_hook = &kgdb_handle_exception; /* histerical reasons... */
822 -static int __init kgdb_opt_kgdbeth(char *str)
824 - kgdb_eth = simple_strtoul(str, NULL, 10);
828 -static int __init kgdb_opt_kgdbeth_remoteip(char *str)
830 - kgdb_remoteip = in_aton(str);
834 -static int __init kgdb_opt_kgdbeth_listenport(char *str)
836 - kgdb_listenport = simple_strtoul(str, NULL, 10);
837 - kgdb_sendport = kgdb_listenport - 1;
841 -static int __init parse_hw_addr(char *str, unsigned char *addr)
852 - sscanf(p, "%x:", &c);
854 - while((*p != 0) && (*p != ':')) {
866 -static int __init kgdb_opt_kgdbeth_remotemac(char *str)
868 - return parse_hw_addr(str, kgdb_remotemac);
870 -static int __init kgdb_opt_kgdbeth_localmac(char *str)
872 - return parse_hw_addr(str, kgdb_localmac);
876 -__setup("gdbeth=", kgdb_opt_kgdbeth);
877 -__setup("gdbeth_remoteip=", kgdb_opt_kgdbeth_remoteip);
878 -__setup("gdbeth_listenport=", kgdb_opt_kgdbeth_listenport);
879 -__setup("gdbeth_remotemac=", kgdb_opt_kgdbeth_remotemac);
880 -__setup("gdbeth_localmac=", kgdb_opt_kgdbeth_localmac);
882 Index: linux-2.6.0-test6/arch/i386/lib/kgdb_serial.c
883 ===================================================================
884 --- linux-2.6.0-test6.orig/arch/i386/lib/kgdb_serial.c 2003-10-12 13:12:22.000000000 +0800
885 +++ linux-2.6.0-test6/arch/i386/lib/kgdb_serial.c 2003-10-12 13:12:25.000000000 +0800
888 kgdb_enable_ints(void)
890 - if (kgdb_eth != -1) {
894 if (gdb_async_info == NULL) {
895 Index: linux-2.6.0-test6/drivers/net/Makefile
896 ===================================================================
897 --- linux-2.6.0-test6.orig/drivers/net/Makefile 2003-10-12 13:12:22.000000000 +0800
898 +++ linux-2.6.0-test6/drivers/net/Makefile 2003-10-12 13:12:25.000000000 +0800
901 obj-$(CONFIG_OAKNET) += oaknet.o 8390.o
903 -obj-$(CONFIG_KGDB) += kgdb_eth.o
905 obj-$(CONFIG_DGRS) += dgrs.o
906 obj-$(CONFIG_RCPCI) += rcpci.o
907 obj-$(CONFIG_VORTEX) += 3c59x.o
909 ifeq ($(CONFIG_SLIP_COMPRESSED),y)
910 obj-$(CONFIG_SLIP) += slhc.o
912 +# Must come after all NICs it might use
913 +obj-$(CONFIG_KGDB) += kgdb_eth.o
915 obj-$(CONFIG_DUMMY) += dummy.o
916 obj-$(CONFIG_DE600) += de600.o
917 Index: linux-2.6.0-test6/include/asm-i386/kgdb.h
918 ===================================================================
919 --- linux-2.6.0-test6.orig/include/asm-i386/kgdb.h 2003-10-12 13:12:23.000000000 +0800
920 +++ linux-2.6.0-test6/include/asm-i386/kgdb.h 2003-10-12 13:12:25.000000000 +0800
925 -extern int kgdb_eth;
926 -extern unsigned kgdb_remoteip;
927 -extern unsigned short kgdb_listenport;
928 -extern unsigned short kgdb_sendport;
929 -extern unsigned char kgdb_remotemac[6];
930 -extern unsigned char kgdb_localmac[6];
931 extern int kgdb_eth_need_breakpoint[];
933 +extern void kgdb_schedule_breakpoint(void);
934 +extern void kgdb_process_breakpoint(void);
936 extern int kgdb_tty_hook(void);
937 extern int kgdb_eth_hook(void);
938 -extern int gdb_net_interrupt(struct sk_buff *skb);
941 * GDB debug stub (or any debug stub) can point the 'linux_debug_hook'
942 Index: linux-2.6.0-test6/Documentation/i386/kgdb/kgdbeth.txt
943 ===================================================================
944 --- linux-2.6.0-test6.orig/Documentation/i386/kgdb/kgdbeth.txt 2003-10-12 13:12:22.000000000 +0800
945 +++ linux-2.6.0-test6/Documentation/i386/kgdb/kgdbeth.txt 2003-10-12 13:12:25.000000000 +0800
948 Robert Walsh <rjwalsh@durables.org> (2.6 port)
949 wangdi <wangdi@clusterfs.com> (2.6 port)
950 +Matt Mackall <mpm@selenic.com> (netpoll api)
951 San Mehat (original 2.4 code)
957 -KGDB supports debugging over ethernet. Only a limited set of ethernet
958 -devices are supported right now, but adding support for new devices
959 -should not be too complicated. See "New Devices" below for details.
961 +KGDB supports debugging over ethernet (kgdboe) via polling of a given
962 +network interface. Most cards should be supported automatically.
963 +Debugging facilities are available as soon as the network driver and
964 +kgdboe have initialized. Unfortunately, this is too late in the boot
965 +process for debugging some issues, but works quite well for many
966 +others. This should not interfere with normal network usage and
967 +doesn't require a dedicated NIC.
975 -You need to use the following command-line options on the TARGET kernel:
978 - gdbeth_remoteip=HOSTIPADDR
979 - gdbeth_remotemac=REMOTEMAC
980 - gdbeth_localmac=LOCALMAC
982 -kgdbeth=DEVICENUM sets the ethernet device number to listen on for
983 -debugging packets. e.g. kgdbeth=0 listens on eth0.
985 -kgdbeth_remoteip=HOSTIPADDR sets the IP address of the HOST machine.
986 -Only packets originating from this IP address will be accepted by the
987 -debugger. e.g. kgdbeth_remoteip=192.168.2.2
988 +You need to use the following command-line option on the TARGET kernel:
990 -kgdbeth_remotemac=REMOTEMAC sets the ethernet address of the HOST machine.
991 -e.g. kgdbeth_remotemac=00:07:70:12:4E:F5
992 + kgdboe=[tgt-port]@<tgt-ip>/[dev],[host-port]@<host-ip>/[host-macaddr]
994 -kgdbeth_localmac=LOCALMAC sets the ethernet address of the TARGET machine.
995 -e.g. kgdbeth_localmac=00:10:9F:18:21:3C
997 + tgt-port source for UDP packets (defaults to 6443)
998 + tgt-ip source IP to use (interface address)
999 + dev network interface (eth0)
1000 + host-port HOST UDP port (6442) (not really used)
1001 + host-ip IP address for HOST machine
1002 + host-macaddr ethernet MAC address for HOST (ff:ff:ff:ff:ff:ff)
1004 -You can also set the following command-line option on the TARGET kernel:
1007 - kgdbeth_listenport=PORT
1008 + kgdboe=7000@192.168.0.1/wlan0,7001@192.168.0.2/00:05:3C:04:47:5D
1009 + kgdboe=@192.168.0.1/,@192.168.0.2/
1011 -kgdbeth_listenport sets the UDP port to listen on for gdb debugging
1012 -packets. The default value is "6443". e.g. kgdbeth_listenport=7654
1013 -causes the kernel to listen on UDP port 7654 for debugging packets.
1014 +Only packets originating from the configured HOST IP address will be
1015 +accepted by the debugger.
1017 On the HOST side, run gdb as normal and use a remote UDP host as the
1021 You can now continue as if you were debugging over a serial line.
1026 -I've used this with NFS and various other network applications (ssh,
1027 -etc.) and it's doesn't appear to interfere with their operation in
1028 -any way. It doesn't seem to effect the NIC it uses - i.e. you don't
1029 -need a dedicated NIC for this.
1034 -In the inital release of this code you _must_ break into the system with the
1035 -debugger by hand, early after boot, as described above.
1037 -Otherwise, the first time the kernel tries to enter the debugger (say, via an
1038 -oops or a BUG), the kgdb stub will doublefault and die because things aren't
1044 -Right now, the following drivers are supported:
1046 - e100 driver (drivers/net/e100/*)
1047 - 3c59x driver (drivers/net/3c59x.c)
1053 -Supporting a new device is straightforward. Just add a "poll" routine to
1054 -the driver and hook it into the poll_controller field in the netdevice
1055 -structure. For an example, look in drivers/net/3c59x.c and search
1056 -for CONFIG_KGDB (two places.)
1058 -The poll routine is usually quite simple - it's usually enough to just
1059 -disable interrupts, call the device's interrupt routine and re-enable
1062 +The current release of this code is exclusive of using kgdb on a
1063 +serial interface, so you must boot without the kgdboe option to use
1064 +serial debugging. Trying to debug the network driver while using it
1065 +will prove interesting.
1070 -Send bug reports to Robert Walsh <rjwalsh@durables.org>.
1071 +Send bug reports to Robert Walsh <rjwalsh@durables.org> Matt
1072 +Mackall <mpm@selenic.com> and wangdi <wangdi@clusterfs.com>.