* BitKeeper repo for KGDB
@ 2004-01-27 18:40 Tom Rini
2004-01-27 19:31 ` Sam Ravnborg
` (3 more replies)
0 siblings, 4 replies; 25+ messages in thread
From: Tom Rini @ 2004-01-27 18:40 UTC (permalink / raw)
To: akpm, george, amitkale, Andi Kleen, jim.houston; +Cc: Kernel Mailing List
Hello everybody. Since I've been talking with George off-list about
trying to merge the various versions of KGDB around, and I just read the
thread between Andy and Jim about conflicting on KGDB work, I've put up
a BitKeeper repository[1] to try and coordinate things.
What's in there right now is Amit's kgdb 2.1.0, without the ethernet
patch. There's also all of the changes for PPC and for generic stuffs
that I've been doing of late.
What I'll be doing shortly (this afternoon even) is to change from a
struct of function pointers, for the arch specific functions, into a set
of provided, weak, variants and then allow arches to override as needed.
What I'd like is for someone to move the ethernet bits from the -mm tree
into here, and for people to merge the fixes / enhancements that're in
their per-arch stubs in the -mm tree into the split design that Amit's
version has.
Comments? Screams? Patches? :)
[1]: If anyone here won't / can't use BitKeeper, I'll happily move over
to a repo someone else sets up in something else.
--
Tom Rini
http://gate.crashing.org/~trini/
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: BitKeeper repo for KGDB
2004-01-27 18:40 BitKeeper repo for KGDB Tom Rini
@ 2004-01-27 19:31 ` Sam Ravnborg
2004-01-27 19:46 ` Dave Jones
2004-01-27 20:07 ` Chris Wright
` (2 subsequent siblings)
3 siblings, 1 reply; 25+ messages in thread
From: Sam Ravnborg @ 2004-01-27 19:31 UTC (permalink / raw)
To: Tom Rini, davej
Cc: akpm, george, amitkale, Andi Kleen, jim.houston,
Kernel Mailing List
On Tue, Jan 27, 2004 at 11:40:29AM -0700, Tom Rini wrote:
>
> [1]: If anyone here won't / can't use BitKeeper, I'll happily move over
> to a repo someone else sets up in something else.
Or you could ask Dave Jones if he can take nightly snapshots - as
he does for sparse and udev.
Sam
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: BitKeeper repo for KGDB
2004-01-27 19:31 ` Sam Ravnborg
@ 2004-01-27 19:46 ` Dave Jones
0 siblings, 0 replies; 25+ messages in thread
From: Dave Jones @ 2004-01-27 19:46 UTC (permalink / raw)
To: Tom Rini, akpm, george, amitkale, Andi Kleen, jim.houston,
Kernel Mailing List
On Tue, Jan 27, 2004 at 08:31:49PM +0100, Sam Ravnborg wrote:
> On Tue, Jan 27, 2004 at 11:40:29AM -0700, Tom Rini wrote:
> >
> > [1]: If anyone here won't / can't use BitKeeper, I'll happily move over
> > to a repo someone else sets up in something else.
>
> Or you could ask Dave Jones if he can take nightly snapshots - as
> he does for sparse and udev.
Hmm, reminds me, the scripts to make those snapshots broke when I migrated to
the new box. I'll go fix them up. But yeah, sure. If you want me to
add them to the snapshot list, just mail me the bk: url and I'll
add it.
Dave
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: BitKeeper repo for KGDB
2004-01-27 18:40 BitKeeper repo for KGDB Tom Rini
2004-01-27 19:31 ` Sam Ravnborg
@ 2004-01-27 20:07 ` Chris Wright
2004-01-27 21:02 ` Tom Rini
2004-01-28 16:51 ` Pavel Machek
2004-01-30 18:18 ` Tom Rini
3 siblings, 1 reply; 25+ messages in thread
From: Chris Wright @ 2004-01-27 20:07 UTC (permalink / raw)
To: Tom Rini
Cc: akpm, george, amitkale, Andi Kleen, jim.houston,
Kernel Mailing List
* Tom Rini (trini@kernel.crashing.org) wrote:
> Hello everybody. Since I've been talking with George off-list about
> trying to merge the various versions of KGDB around, and I just read the
> thread between Andy and Jim about conflicting on KGDB work, I've put up
> a BitKeeper repository[1] to try and coordinate things.
<snip>
> [1]: If anyone here won't / can't use BitKeeper, I'll happily move over
> to a repo someone else sets up in something else.
seems I missed where the repo is.
thanks,
-chris
--
Linux Security Modules http://lsm.immunix.org http://lsm.bkbits.net
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: BitKeeper repo for KGDB
2004-01-27 20:07 ` Chris Wright
@ 2004-01-27 21:02 ` Tom Rini
2004-01-28 9:50 ` Dave Jones
0 siblings, 1 reply; 25+ messages in thread
From: Tom Rini @ 2004-01-27 21:02 UTC (permalink / raw)
To: Chris Wright
Cc: akpm, george, amitkale, Andi Kleen, jim.houston,
Kernel Mailing List
On Tue, Jan 27, 2004 at 12:07:44PM -0800, Chris Wright wrote:
> * Tom Rini (trini@kernel.crashing.org) wrote:
> > Hello everybody. Since I've been talking with George off-list about
> > trying to merge the various versions of KGDB around, and I just read the
> > thread between Andy and Jim about conflicting on KGDB work, I've put up
> > a BitKeeper repository[1] to try and coordinate things.
> <snip>
> > [1]: If anyone here won't / can't use BitKeeper, I'll happily move over
> > to a repo someone else sets up in something else.
>
> seems I missed where the repo is.
> thanks,
> -chris
Der, whoops.
bk://ppc.bkbits.net/linux-2.6-kgdb
--
Tom Rini
http://gate.crashing.org/~trini/
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: BitKeeper repo for KGDB
2004-01-27 21:02 ` Tom Rini
@ 2004-01-28 9:50 ` Dave Jones
0 siblings, 0 replies; 25+ messages in thread
From: Dave Jones @ 2004-01-28 9:50 UTC (permalink / raw)
To: Tom Rini
Cc: Chris Wright, akpm, george, amitkale, Andi Kleen, jim.houston,
Kernel Mailing List
On Tue, Jan 27, 2004 at 02:02:47PM -0700, Tom Rini wrote:
> > seems I missed where the repo is.
> Der, whoops.
>
> bk://ppc.bkbits.net/linux-2.6-kgdb
daily diffs vs mainline generated at..
http://www.codemonkey.org.uk/projects/bitkeeper/kgdb
Dave
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: BitKeeper repo for KGDB
2004-01-27 18:40 BitKeeper repo for KGDB Tom Rini
2004-01-27 19:31 ` Sam Ravnborg
2004-01-27 20:07 ` Chris Wright
@ 2004-01-28 16:51 ` Pavel Machek
2004-01-28 17:05 ` Tom Rini
2004-01-30 18:18 ` Tom Rini
3 siblings, 1 reply; 25+ messages in thread
From: Pavel Machek @ 2004-01-28 16:51 UTC (permalink / raw)
To: Tom Rini
Cc: akpm, george, amitkale, Andi Kleen, jim.houston,
Kernel Mailing List
Hi!
> Hello everybody. Since I've been talking with George off-list about
> trying to merge the various versions of KGDB around, and I just read the
> thread between Andy and Jim about conflicting on KGDB work, I've put up
> a BitKeeper repository[1] to try and coordinate things.
>
> What's in there right now is Amit's kgdb 2.1.0, without the ethernet
> patch. There's also all of the changes for PPC and for generic stuffs
> that I've been doing of late.
>
> What I'll be doing shortly (this afternoon even) is to change from a
> struct of function pointers, for the arch specific functions, into a set
> of provided, weak, variants and then allow arches to override as needed.
>
> What I'd like is for someone to move the ethernet bits from the -mm tree
> into here, and for people to merge the fixes / enhancements that're in
> their per-arch stubs in the -mm tree into the split design that Amit's
> version has.
>
> Comments? Screams? Patches? :)
This one. It compiles. It needs -netpoll. It probably does not work.
Pavel
--- tmp/linux/drivers/net/kgdb_eth.c 2004-01-26 10:18:45.000000000 +0100
+++ linux/drivers/net/kgdb_eth.c 2004-01-24 19:02:28.000000000 +0100
@@ -14,6 +14,9 @@
* Reveral changes to make it free of device driver changes.
* Added internal buffers for this interface.
* by Amit S. Kale <amitkale@emsyssoft.com>
+ *
+ * Refactored for netpoll API by Matt Mackall <mpm@selenic.com>
+ *
* Some cleanups by Pavel Machek <pavel@suse.cz>
*/
@@ -37,6 +40,8 @@
#include <linux/irq.h>
#include <linux/inet.h>
#include <linux/notifier.h>
+#include <linux/netpoll.h>
+
#include <net/tcp.h>
#include <net/udp.h>
@@ -47,656 +52,121 @@
#include <asm/system.h>
#include <asm/atomic.h>
-#define GDB_BUF_SIZE 512 /* power of 2, please */
-
-#define CHUNKSIZE 30
-#define MAXINCHUNK (CHUNKSIZE + 8)
-
-static char kgdb_buf[GDB_BUF_SIZE];
-static int kgdb_buf_in_inx;
-static atomic_t kgdb_buf_in_cnt;
-static int kgdb_buf_out_inx;
-
-static unsigned int kgdb_remoteip = 0;
-static unsigned short kgdb_listenport = 6443;
-static unsigned short kgdb_sendport= 6442;
-static int kgdb_eth = -1; /* Default tty mode */
-static unsigned char kgdb_remotemac[6] = {0xff,0xff,0xff,0xff,0xff,0xff};
-static unsigned char kgdb_localmac[6] = {0xff,0xff,0xff,0xff,0xff,0xff};
-
-static char kgdbeth_sendbuf[MAXINCHUNK];
-static int kgdbeth_sendbufchars;
-static irqreturn_t (*kgdbeth_irqhandler)(int, void *, struct pt_regs *) = NULL;
-
-struct net_device *kgdb_netdevice = NULL;
-
-/* Indicates dept of recursion for xmitlock hold */
-static int xlock_hold_count = 0;
-
-/* kgdb ethernet ring buffers. Increase the space if you get panics in
- * kgdbeth_alloc_skb.
- * Status of send_skbs can be known from the field users.
- * If it's 1 the buffer is free.
- * If the count 2 or more, the buffer is in use.
- * Keeping 1 as the initial count prevents kfree_skb from freeing it. */
-#define SEND_BUFLEN 1024
-#define NUM_SENDBUF 128
-static char *send_bufs[NUM_SENDBUF];
-static struct sk_buff *send_skbs[NUM_SENDBUF];
-static struct sk_buff *send_skb;
-static int bufnum;
-
-static char kgdb_netdev_name[16];
-
-#ifdef CONFIG_KGDB_CONSOLE
-#error kgdb over ethernet is not yet ready for console messages.
-#endif
-
-/*
- * Returns next skb from kgdb skbs.
- * Initializes users field of the skb to 2 so that kfree_skb doesn't attempt
- * freeing it.
- * Always call after holding xmitlock of the ethernet device.
- */
-
-struct sk_buff *kgdbeth_alloc_skb(int size)
-{
- struct sk_buff *skb;
- u8 *data;
- int i;
-
- i = bufnum;
-
- do {
- skb = send_skbs[i];
-
- if (atomic_read(&skb->users) == 1) {
- bufnum = i;
- i = -1;
- break;
- }
- i = (i + 1) % NUM_SENDBUF;
- } while (i != bufnum);
- if (i == bufnum) {
- panic("kgdb ethernet buffer overflow\n");
- }
- data = (u8 *)(send_bufs[bufnum]);
-
- size = SKB_DATA_ALIGN(size);
- if (size + sizeof(struct skb_shared_info) > SEND_BUFLEN)
- panic("kgdb ethernet buffer too short for this request");
-
- memset(skb, 0, offsetof(struct sk_buff, truesize));
- skb->truesize = size + sizeof(struct sk_buff);
- atomic_set(&skb->users, 2);
- skb->head = data;
- skb->data = data;
- skb->tail = data;
- skb->end = data + size;
-
- atomic_set(&(skb_shinfo(skb)->dataref), 1);
- skb_shinfo(skb)->nr_frags = 0;
- skb_shinfo(skb)->tso_size = 0;
- skb_shinfo(skb)->tso_segs = 0;
- skb_shinfo(skb)->frag_list = NULL;
-
- return skb;
-}
-
-/* Holds xmitlock of the ethernet device
- * Recursive calls allowed */
-static void kgdbeth_lock(void)
-{
- if (spin_is_locked(&kgdb_netdevice->xmit_lock)) {
- if (kgdb_netdevice->xmit_lock_owner == smp_processor_id()) {
- goto gotit;
- }
- }
- spin_lock(&kgdb_netdevice->xmit_lock);
- kgdb_netdevice->xmit_lock_owner = smp_processor_id();
-
-gotit:
- xlock_hold_count++;
-}
+#define IN_BUF_SIZE 512 /* power of 2, please */
+#define OUT_BUF_SIZE 256
-/* releases xmitlock of the ethernet device
- * Recursive calls allowed */
-static void kgdbeth_unlock(void)
-{
- if (--xlock_hold_count) {
- kgdb_netdevice->xmit_lock_owner = -1;
- spin_unlock(&kgdb_netdevice->xmit_lock);
- }
-}
-
-/*
- * Get a char if available, return -1 if nothing available.
- * Empty the receive buffer first, then look at the interface hardware.
- */
-static int
-read_char(void)
-{
- /* intr routine has queued chars */
- if (atomic_read(&kgdb_buf_in_cnt) != 0) {
- int chr;
-
- chr = kgdb_buf[kgdb_buf_out_inx++];
- kgdb_buf_out_inx &= (GDB_BUF_SIZE - 1);
- atomic_dec(&kgdb_buf_in_cnt);
- return chr;
- }
-
- return -1; /* no data */
-}
+static char in_buf[IN_BUF_SIZE], out_buf[OUT_BUF_SIZE];
+static int in_head, in_tail, out_count;
+static atomic_t in_count;
+int kgdboe = 0; /* Default to tty mode */
+
+extern void set_debug_traps(void);
+extern void breakpoint(void);
+static void rx_hook(struct netpoll *np, int port, char *msg, int len);
+
+static struct netpoll np = {
+ .name = "kgdboe",
+ .dev_name = "eth0",
+ .rx_hook = rx_hook,
+ .local_port = 6443,
+ .remote_port = 6442,
+ .remote_mac = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff},
+};
-/*
- * Wait until the interface can accept a char, then write it.
- */
-static void
-write_buffer(char *buf, int len)
+int eth_getDebugChar(void)
{
- int total_len, eth_len, ip_len, udp_len;
- struct in_device *in_dev;
- struct sk_buff *skb;
- struct udphdr *udph;
- struct iphdr *iph;
- struct ethhdr *eth;
-
- if (!(in_dev = (struct in_device *) kgdb_netdevice->ip_ptr)) {
- panic("No in_device available for interface!\n");
- }
-
- if (!(in_dev->ifa_list)) {
- panic("No interface address set for interface!\n");
- }
- kgdbeth_lock();
+ int chr;
- udp_len = len + sizeof(struct udphdr);
- ip_len = eth_len = udp_len + sizeof(struct iphdr);
- total_len = eth_len + ETH_HLEN;
-
- skb = kgdbeth_alloc_skb(total_len);
-
- skb_reserve(skb, total_len - 1);
-
- memcpy(skb->data, (unsigned char *) buf, len);
- skb->len += len;
-
- udph = (struct udphdr *) skb_push(skb, sizeof(*udph));
- udph->source = htons(kgdb_listenport);
- udph->dest = htons(kgdb_sendport);
- udph->len = htons(udp_len);
- udph->check = 0;
-
- iph = (struct iphdr *)skb_push(skb, sizeof(*iph));
- iph->version = 4;
- iph->ihl = 5;
- iph->tos = 0;
- iph->tot_len = htons(ip_len);
- iph->id = 0;
- iph->frag_off = 0;
- iph->ttl = 64;
- iph->protocol = IPPROTO_UDP;
- iph->check = 0;
- iph->saddr = in_dev->ifa_list->ifa_address;
- iph->daddr = kgdb_remoteip;
- iph->check = ip_fast_csum((unsigned char *)iph, iph->ihl);
-
- eth = (struct ethhdr *) skb_push(skb, ETH_HLEN);
- eth->h_proto = htons(ETH_P_IP);
- memcpy(eth->h_source, kgdb_localmac, kgdb_netdevice->addr_len);
- memcpy(eth->h_dest, kgdb_remotemac, kgdb_netdevice->addr_len);
-
- kgdb_netdevice->hard_start_xmit(skb, kgdb_netdevice);
- BUG_ON(atomic_read(&skb->users) != 1);
- kgdbeth_unlock();
-}
-
-static void kgdbeth_flush(void)
-{
- if (!kgdbeth_sendbufchars) {
- return;
- }
- write_buffer(kgdbeth_sendbuf, kgdbeth_sendbufchars);
- kgdbeth_sendbufchars = 0;
-}
+ while (atomic_read(&in_count) == 0)
+ netpoll_poll(&np);
-static void kgdbeth_write_char(int chr)
-{
- if (kgdbeth_sendbufchars == MAXINCHUNK) {
- kgdbeth_flush();
- }
- kgdbeth_sendbuf[kgdbeth_sendbufchars++] = chr;
+ chr = in_buf[in_tail++];
+ in_tail &= (IN_BUF_SIZE - 1);
+ atomic_dec(&in_count);
+ return chr;
}
-
-/*
- * In the interrupt state the target machine will not respond to any
- * arp requests, so handle them here.
- */
-
-static void
-kgdb_eth_reply_arp(void)
+void eth_flushDebugChar(void)
{
- if (send_skb) {
- kgdbeth_lock();
- kgdb_netdevice->hard_start_xmit(send_skb, kgdb_netdevice);
- send_skb = NULL;
- kgdbeth_unlock();
+ if(out_count && np.dev) {
+ netpoll_send_udp(&np, out_buf, out_count);
+ out_count = 0;
}
}
-static int
-make_arp_request(struct sk_buff *skb)
+void eth_putDebugChar(int chr)
{
- struct arphdr *arp;
- unsigned char *arp_ptr;
- int type = ARPOP_REPLY;
- int ptype = ETH_P_ARP;
- u32 sip, tip;
- unsigned char *sha, *tha;
- struct in_device *in_dev = (struct in_device *) kgdb_netdevice->ip_ptr;
-
- /* No arp on this interface */
-
- if (kgdb_netdevice->flags & IFF_NOARP) {
- return 0;
- }
-
- if (!pskb_may_pull(skb, (sizeof(struct arphdr) +
- (2 * kgdb_netdevice->addr_len) +
- (2 * sizeof(u32))))) {
- return 0;
- }
-
- skb->h.raw = skb->nh.raw = skb->data;
- arp = skb->nh.arph;
-
- if ((arp->ar_hrd != htons(ARPHRD_ETHER) &&
- arp->ar_hrd != htons(ARPHRD_IEEE802)) ||
- arp->ar_pro != htons(ETH_P_IP)) {
- return 0;
- }
-
- /* Understand only these message types */
-
- if (arp->ar_op != htons(ARPOP_REQUEST)) {
- return 0;
- }
-
- /* Extract fields */
-
- arp_ptr= (unsigned char *)(arp+1);
- sha = arp_ptr;
- arp_ptr += kgdb_netdevice->addr_len;
- memcpy(&sip, arp_ptr, 4);
- arp_ptr += 4;
- tha = arp_ptr;
- arp_ptr += kgdb_netdevice->addr_len;
- memcpy(&tip, arp_ptr, 4);
-
- if (tip != in_dev->ifa_list->ifa_address) {
- return 0;
- }
-
- if (kgdb_remoteip != sip) {
- return 0;
- }
-
- /*
- * Check for bad requests for 127.x.x.x and requests for multicast
- * addresses. If this is one such, delete it.
- */
-
- if (LOOPBACK(tip) || MULTICAST(tip)) {
- return 0;
- }
- /* reply to the ARP request */
-
- kgdbeth_lock();
- if (send_skb) {
- /* Get rid of any previous replies to ARP request. We hope
- * that regular reply to ARP by network layers would have gone
- * out by now. */
- kfree_skb(send_skb);
- }
- send_skb = kgdbeth_alloc_skb(sizeof(struct arphdr) +
- 2 * (kgdb_netdevice->addr_len + 4) +
- LL_RESERVED_SPACE(kgdb_netdevice));
- kgdbeth_unlock();
-
- skb_reserve(send_skb, LL_RESERVED_SPACE(kgdb_netdevice));
- send_skb->nh.raw = send_skb->data;
- arp = (struct arphdr *) skb_put(send_skb, sizeof(struct arphdr) + 2 * (kgdb_netdevice->addr_len + 4));
- send_skb->dev = kgdb_netdevice;
- send_skb->protocol = htons(ETH_P_ARP);
-
- /* Fill the device header for the ARP frame */
-
- if (kgdb_netdevice->hard_header &&
- kgdb_netdevice->hard_header(send_skb, kgdb_netdevice, ptype,
- kgdb_remotemac, kgdb_localmac,
- send_skb->len) < 0) {
- kfree_skb(send_skb);
- return 0;
- }
-
- /*
- * Fill out the arp protocol part.
- *
- * we only support ethernet device type,
- * which (according to RFC 1390) should always equal 1 (Ethernet).
- */
-
- arp->ar_hrd = htons(kgdb_netdevice->type);
- arp->ar_pro = htons(ETH_P_IP);
-
- arp->ar_hln = kgdb_netdevice->addr_len;
- arp->ar_pln = 4;
- arp->ar_op = htons(type);
-
- arp_ptr=(unsigned char *)(arp + 1);
-
- memcpy(arp_ptr, kgdb_netdevice->dev_addr, kgdb_netdevice->addr_len);
- arp_ptr += kgdb_netdevice->addr_len;
- memcpy(arp_ptr, &tip, 4);
- arp_ptr += 4;
- memcpy(arp_ptr, kgdb_localmac, kgdb_netdevice->addr_len);
- arp_ptr += kgdb_netdevice->addr_len;
- memcpy(arp_ptr, &sip, 4);
- return 0;
+ out_buf[out_count++] = chr;
+ if(out_count == OUT_BUF_SIZE)
+ eth_flushDebugChar();
}
-
-/*
- * Accept an skbuff from net_device layer and add the payload onto
- * kgdb buffer
- *
- * When the kgdb stub routine read_char() is called it draws characters
- * out of the buffer until it is empty and then polls the hardware.
- *
- * Return value of NET_RX_DROP means skb was used by this function.
- * NET_RX_SUCCESS indicates this function didn't use it.
-
- * Be prepared to respond to ARP requests. Let the caller also handle
- * them if debugger is not active. We'll respond to the ARP request when
- * a debugging session begins. It's necessary to respond to the request as the
- * debugging session may begin even before kernel has a chance finish the
- * response.
- */
-int
-kgdb_net_interrupt(struct sk_buff *skb)
+static void rx_hook(struct netpoll *np, int port, char *msg, int len)
{
- unsigned char chr;
- struct iphdr *iph = (struct iphdr*)skb->data;
- struct udphdr *udph= (struct udphdr*)(skb->data+(iph->ihl<<2));
- unsigned char *data = (unsigned char *) udph + sizeof(struct udphdr);
- int len;
- int i;
-
- if (!kgdb_initialized || !kgdb_netdevice) {
- goto out;
- }
- if (skb->protocol == __constant_htons(ETH_P_ARP) && !send_skb) {
- make_arp_request(skb);
- goto out;
- }
- if (iph->protocol != IPPROTO_UDP ||
- be16_to_cpu(udph->dest) != kgdb_listenport)
- goto out;
+ int i;
- kgdb_sendport = be16_to_cpu(udph->source);
+ np->remote_port = port;
- len = (be16_to_cpu(iph->tot_len) -
- (sizeof(struct udphdr) + sizeof(struct iphdr)));
+ /* Is this gdb trying to attach? */
+ if (!netpoll_trap() && len == 8 && !strncmp(msg, "$Hc-1#09", 8))
+ printk(KERN_CRIT "Someone is trying to attach\n");
+// kgdb_schedule_breakpoint();
for (i = 0; i < len; i++) {
- chr = *data++;
- if (chr == 3)
- {
- if (!atomic_read(&debugger_active)) {
- breakpoint();
- }
- continue;
- }
- if (atomic_read(&kgdb_buf_in_cnt) >= GDB_BUF_SIZE) {
- /* buffer overflow, clear it */
- kgdb_buf_in_inx = 0;
- atomic_set(&kgdb_buf_in_cnt, 0);
- kgdb_buf_out_inx = 0;
- break;
- }
- kgdb_buf[kgdb_buf_in_inx++] = chr;
- kgdb_buf_in_inx &= (GDB_BUF_SIZE - 1);
- atomic_inc(&kgdb_buf_in_cnt) ;
- }
- return NET_RX_DROP;
-
-out:
- if (atomic_read(&debugger_active))
- return NET_RX_DROP;
- return NET_RX_SUCCESS;
-}
+ if (msg[i] == 3) /* Check for ^C? */
+ printk(KERN_CRIT "Someone is trying to ^C?\n");
+// kgdb_schedule_breakpoint();
-/*
- * Initializes ethernet interface to kgdb.
- * Searches the device list and finds the device specified on kernel command
- * line.
- * Finds the irq handler for the device and saves its reference.
- * Initializes kgdbeth data structures.
- */
-
-int
-kgdbeth_hook(void)
-{
- extern void kgdb_respond_ok(void);
- struct irqaction *ia_ptr;
- int i;
-
- sprintf(kgdb_netdev_name, "eth%d", kgdb_eth);
-
- for (kgdb_netdevice = dev_base;
- kgdb_netdevice != NULL;
- kgdb_netdevice = kgdb_netdevice->next) {
- if (strncmp(kgdb_netdevice->name, kgdb_netdev_name, IFNAMSIZ) == 0) {
- break;
- }
- }
- if (!kgdb_netdevice) {
- printk("kgdbeth: Unable to find interface %s\n",
- kgdb_netdev_name);
- return -ENODEV;
- }
- if (!(kgdb_netdevice->flags & IFF_UP)) {
- return -EINVAL;
- }
- ia_ptr = irq_desc[kgdb_netdevice->irq].action;
- while (ia_ptr) {
- if (!strncmp(kgdb_netdev_name, ia_ptr->name, IFNAMSIZ)) {
- kgdbeth_irqhandler = ia_ptr->handler;
+ if (atomic_read(&in_count) >= IN_BUF_SIZE) {
+ /* buffer overflow, clear it */
+ in_head = in_tail = 0;
+ atomic_set(&in_count, 0);
break;
}
- ia_ptr = ia_ptr->next;
- }
- if (!kgdbeth_irqhandler) {
- printk("kgdbeth: Interface %s doesn't have an interrupt"
- " handler cannot use it\n", kgdb_netdev_name);
- return -EINVAL;
- }
- for (i = 0; i < NUM_SENDBUF; i++) {
- send_skbs[i] = kmalloc(sizeof (struct sk_buff), GFP_KERNEL);
- send_bufs[i] = kmalloc(SEND_BUFLEN, GFP_KERNEL);
- if (!send_skbs[i] || !send_bufs[i]) {
- printk("kgdbeth: not enough memory\n");
- return -ENOMEM;
- }
- atomic_set(&(send_skbs[i]->users), 1);
+ in_buf[in_head++] = msg[i];
+ in_head &= (IN_BUF_SIZE - 1);
+ atomic_inc(&in_count);
}
-
-
- return 0;
}
-/*
- * kgdbeth_read_char
- *
- * This is a GDB stub routine. It waits for a character from the
- * ethernet interface and then returns it.
- */
-static int
-kgdbeth_read_char(void)
+static int option_setup(char *opt)
{
- int chr;
-
- while ((chr = read_char()) < 0) {
- if (send_skb) {
- kgdb_eth_reply_arp();
- }
- (*kgdbeth_irqhandler)(kgdb_netdevice->irq,
- (void *)kgdb_netdevice, 0);
- }
- return chr;
+ return netpoll_parse_options(&np, opt);
}
-/*
- * Hold onto the xmitlock and keep holding till the session ends.
- * Disable device irq and keep it disabled till this session ends.
- * Respond to last arp request we have received. It may not not have be
- * responded yet.
- */
-static void kgdbeth_begin_session(void) {
- kgdbeth_lock();
- disable_irq(kgdb_netdevice->irq);
- kgdb_eth_reply_arp();
-}
+__setup("kgdboe=", option_setup);
-static void kgdbeth_end_session(void)
+static int init_kgdboe(void)
{
- enable_irq(kgdb_netdevice->irq);
- kgdbeth_unlock();
-}
-
-struct kgdb_serial kgdbeth_serial = {
- .chunksize = CHUNKSIZE,
- .read_char = kgdbeth_read_char,
- .write_char = kgdbeth_write_char,
- .hook = kgdbeth_hook,
- .flush = kgdbeth_flush,
- .begin_session = kgdbeth_begin_session,
- .end_session = kgdbeth_end_session,
-};
+#ifdef CONFIG_SMP
+ if (num_online_cpus() > CONFIG_NO_KGDB_CPUS) {
+ printk("kgdb: too manu cpus. Cannot enable debugger with more than %d cpus\n", CONFIG_NO_KGDB_CPUS);
+ return -1;
+ }
+#endif
+// set_debug_traps();
-static int __init parse_hw_addr(char **ptr, unsigned char *addr,
- unsigned char delimiter)
-{
- int i = 0;
+ if(!np.remote_ip || netpoll_setup(&np))
+ return 1;
- while(**ptr != delimiter)
- {
- unsigned int c;
+ kgdboe = 1;
+ printk(KERN_INFO "kgdb: debugging over ethernet enabled\n");
- if (sscanf(*ptr, "%x", &c) != 1) {
- return 1;
- }
- addr[i++] = c;
- do
- (*ptr)++;
- while((**ptr != delimiter) && (*(*ptr -1) != ':'));
- if (i > 6)
- return -EINVAL;
- }
- if (i != 6)
- return -EINVAL;
return 0;
}
-int kgdbeth_thread(void *data)
-{
- struct net_device *ndev = (struct net_device *)data;
- daemonize("kgdbeth");
- while (!ndev->ip_ptr) {
- schedule();
- }
- debugger_entry();
- return 0;
-}
+static int hook(void) { printk("Hook called\n"); return 0; }
+static int begin(void) { printk("Begin called\n"); return 0; }
+static int end(void) { printk("End called\n"); return 0; }
-int kgdbeth_event(struct notifier_block * self, unsigned long val, void * data)
-{
- if (strcmp(((struct net_device *)data)->name, kgdb_netdev_name)) {
- goto out;
- }
- if (val!= NETDEV_UP)
- goto out;
- kernel_thread(kgdbeth_thread, data, CLONE_KERNEL);
+module_init(init_kgdboe);
-out:
- return NOTIFY_DONE;
-}
-static struct notifier_block nb = {
- .notifier_call = kgdbeth_event,
+struct kgdb_serial kgdbeth_serial = {
+ .chunksize = 1,
+ .read_char = eth_getDebugChar,
+ .write_char = eth_putDebugChar,
+ .hook = hook,
+ .flush = eth_flushDebugChar,
+ .begin_session = begin,
+ .end_session = end,
};
-
-/*
- * Syntax for this cmdline option is
- * kgdbeth=interfacenum,localmac,listenport,remoteip,remotemac
- */
-
-static int __init kgdbeth_opt(char *str)
-{
- char ipaddrstr[16];
- char *ipaddrptr = ipaddrstr;
- extern int register_netdevice_notifier(struct notifier_block *nb);
-
-
- if (register_netdevice_notifier(&nb)) {
- printk("KGDB_ETH: couldn't register notifier\n");
- return 0;
- }
-
- /* interfacenum */
- if (*str < '0' || *str > '9')
- goto errout;
- kgdb_eth = *str - '0';
- str++;
- if (*str != ',')
- goto errout;
- str++;
-
- /* localmac */
- if (parse_hw_addr(&str, kgdb_localmac, ','))
- goto errout;
- str++;
-
- /* port */
- kgdb_listenport = simple_strtoul(str, &str, 10);
-
- if (*str != ',')
- goto errout;
- str++;
-
- /* remoteip */
- while (*str != ',') {
- if (!*str)
- goto errout;
- *ipaddrptr = *str;
- str++;
- ipaddrptr++;
- }
- str++;
- *ipaddrptr = '\0';
- kgdb_remoteip = in_aton(ipaddrstr);
-
- /* remotemac */
- if (parse_hw_addr(&str, kgdb_remotemac, '\0'))
- goto errout;
-
- kgdb_serial = &kgdbeth_serial;
- return 1;
-
-errout:
- printk("Invalid syntax for option kgdbeth=\n");
- return 0;
-}
-
-__setup("kgdbeth=", kgdbeth_opt);
--- tmp/linux/net/core/dev.c 2004-01-26 10:18:51.000000000 +0100
+++ linux/net/core/dev.c 2004-01-24 18:53:56.000000000 +0100
@@ -1428,15 +1428,6 @@
int this_cpu;
struct softnet_data *queue;
unsigned long flags;
- int ret;
- int kgdb_net_interrupt(struct sk_buff *skb);
-
-#ifdef CONFIG_KGDB_ETH
- /* See if kgdb_eth wants this packet */
- if ((ret = kgdb_net_interrupt(skb)) == NET_RX_DROP) {
- return ret;
- }
-#endif
#ifdef CONFIG_NETPOLL_RX
if (skb->dev->netpoll_rx && netpoll_rx(skb)) {
--- tmp/linux/net/core/skbuff.c 2004-01-26 10:18:45.000000000 +0100
+++ linux/net/core/skbuff.c 2004-01-24 18:58:44.000000000 +0100
@@ -127,11 +127,6 @@
{
struct sk_buff *skb;
u8 *data;
- struct sk_buff *kgdbeth_alloc_skb(int size);
-
- if (atomic_read(&debugger_active)) {
- return kgdbeth_alloc_skb(size);
- }
/* Get the HEAD */
skb = kmem_cache_alloc(skbuff_head_cache,
--
When do you have a heart between your knees?
[Johanka's followup: and *two* hearts?]
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: BitKeeper repo for KGDB
2004-01-28 16:51 ` Pavel Machek
@ 2004-01-28 17:05 ` Tom Rini
2004-01-28 17:44 ` Pavel Machek
0 siblings, 1 reply; 25+ messages in thread
From: Tom Rini @ 2004-01-28 17:05 UTC (permalink / raw)
To: Pavel Machek
Cc: akpm, george, amitkale, Andi Kleen, jim.houston,
Kernel Mailing List
On Wed, Jan 28, 2004 at 05:51:05PM +0100, Pavel Machek wrote:
> Hi!
>
> > Hello everybody. Since I've been talking with George off-list about
> > trying to merge the various versions of KGDB around, and I just read the
> > thread between Andy and Jim about conflicting on KGDB work, I've put up
> > a BitKeeper repository[1] to try and coordinate things.
> >
> > What's in there right now is Amit's kgdb 2.1.0, without the ethernet
> > patch. There's also all of the changes for PPC and for generic stuffs
> > that I've been doing of late.
> >
> > What I'll be doing shortly (this afternoon even) is to change from a
> > struct of function pointers, for the arch specific functions, into a set
> > of provided, weak, variants and then allow arches to override as needed.
> >
> > What I'd like is for someone to move the ethernet bits from the -mm tree
> > into here, and for people to merge the fixes / enhancements that're in
> > their per-arch stubs in the -mm tree into the split design that Amit's
> > version has.
> >
> > Comments? Screams? Patches? :)
>
> This one. It compiles. It needs -netpoll. It probably does not work.
Er, what's this against? I don't have drivers/net/kgdb_eth.c in my repo
right now (nor the -netpoll patch, but I'll happily take a patch to add
the kgdb over enet stub and -netpoll).
--
Tom Rini
http://gate.crashing.org/~trini/
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: BitKeeper repo for KGDB
2004-01-28 17:05 ` Tom Rini
@ 2004-01-28 17:44 ` Pavel Machek
2004-01-28 17:56 ` Tom Rini
0 siblings, 1 reply; 25+ messages in thread
From: Pavel Machek @ 2004-01-28 17:44 UTC (permalink / raw)
To: Tom Rini
Cc: akpm, george, amitkale, Andi Kleen, jim.houston,
Kernel Mailing List
Hi!
> > > Hello everybody. Since I've been talking with George off-list about
> > > trying to merge the various versions of KGDB around, and I just read the
> > > thread between Andy and Jim about conflicting on KGDB work, I've put up
> > > a BitKeeper repository[1] to try and coordinate things.
> > >
> > > What's in there right now is Amit's kgdb 2.1.0, without the ethernet
> > > patch. There's also all of the changes for PPC and for generic stuffs
> > > that I've been doing of late.
> > >
> > > What I'll be doing shortly (this afternoon even) is to change from a
> > > struct of function pointers, for the arch specific functions, into a set
> > > of provided, weak, variants and then allow arches to override as needed.
> > >
> > > What I'd like is for someone to move the ethernet bits from the -mm tree
> > > into here, and for people to merge the fixes / enhancements that're in
> > > their per-arch stubs in the -mm tree into the split design that Amit's
> > > version has.
> > >
> > > Comments? Screams? Patches? :)
> >
> > This one. It compiles. It needs -netpoll. It probably does not work.
>
> Er, what's this against? I don't have drivers/net/kgdb_eth.c in my repo
> right now (nor the -netpoll patch, but I'll happily take a patch to add
> the kgdb over enet stub and -netpoll).
It's against 2.6 + -netpoll + Amit's patch.
Pavel
--
When do you have a heart between your knees?
[Johanka's followup: and *two* hearts?]
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: BitKeeper repo for KGDB
2004-01-28 17:44 ` Pavel Machek
@ 2004-01-28 17:56 ` Tom Rini
2004-01-28 18:04 ` Pavel Machek
2004-02-06 22:35 ` Tom Rini
0 siblings, 2 replies; 25+ messages in thread
From: Tom Rini @ 2004-01-28 17:56 UTC (permalink / raw)
To: Pavel Machek
Cc: akpm, george, amitkale, Andi Kleen, jim.houston,
Kernel Mailing List
On Wed, Jan 28, 2004 at 06:44:02PM +0100, Pavel Machek wrote:
> Hi!
>
> > > > Hello everybody. Since I've been talking with George off-list about
> > > > trying to merge the various versions of KGDB around, and I just read the
> > > > thread between Andy and Jim about conflicting on KGDB work, I've put up
> > > > a BitKeeper repository[1] to try and coordinate things.
> > > >
> > > > What's in there right now is Amit's kgdb 2.1.0, without the ethernet
> > > > patch. There's also all of the changes for PPC and for generic stuffs
> > > > that I've been doing of late.
> > > >
> > > > What I'll be doing shortly (this afternoon even) is to change from a
> > > > struct of function pointers, for the arch specific functions, into a set
> > > > of provided, weak, variants and then allow arches to override as needed.
> > > >
> > > > What I'd like is for someone to move the ethernet bits from the -mm tree
> > > > into here, and for people to merge the fixes / enhancements that're in
> > > > their per-arch stubs in the -mm tree into the split design that Amit's
> > > > version has.
> > > >
> > > > Comments? Screams? Patches? :)
> > >
> > > This one. It compiles. It needs -netpoll. It probably does not work.
> >
> > Er, what's this against? I don't have drivers/net/kgdb_eth.c in my repo
> > right now (nor the -netpoll patch, but I'll happily take a patch to add
> > the kgdb over enet stub and -netpoll).
>
> It's against 2.6 + -netpoll + Amit's patch.
But doesn't -mm have a kgdb over enet driver that does work? It's just
not been ported to Amit's bits, right?
--
Tom Rini
http://gate.crashing.org/~trini/
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: BitKeeper repo for KGDB
2004-01-28 17:56 ` Tom Rini
@ 2004-01-28 18:04 ` Pavel Machek
2004-02-06 22:35 ` Tom Rini
1 sibling, 0 replies; 25+ messages in thread
From: Pavel Machek @ 2004-01-28 18:04 UTC (permalink / raw)
To: Tom Rini
Cc: akpm, george, amitkale, Andi Kleen, jim.houston,
Kernel Mailing List
Hi!
> > > Er, what's this against? I don't have drivers/net/kgdb_eth.c in my repo
> > > right now (nor the -netpoll patch, but I'll happily take a patch to add
> > > the kgdb over enet stub and -netpoll).
> >
> > It's against 2.6 + -netpoll + Amit's patch.
>
> But doesn't -mm have a kgdb over enet driver that does work? It's just
> not been ported to Amit's bits, right?
Yes.
I took kgdb-over-ethernet from -mm and made it compile with rest of
Amit's code.
Pavel
--
When do you have a heart between your knees?
[Johanka's followup: and *two* hearts?]
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: BitKeeper repo for KGDB
2004-01-27 18:40 BitKeeper repo for KGDB Tom Rini
` (2 preceding siblings ...)
2004-01-28 16:51 ` Pavel Machek
@ 2004-01-30 18:18 ` Tom Rini
3 siblings, 0 replies; 25+ messages in thread
From: Tom Rini @ 2004-01-30 18:18 UTC (permalink / raw)
To: Kernel Mailing List
On Tue, Jan 27, 2004 at 11:40:29AM -0700, Tom Rini wrote:
> Hello everybody. Since I've been talking with George off-list about
> trying to merge the various versions of KGDB around, and I just read the
> thread between Andy and Jim about conflicting on KGDB work, I've put up
> a BitKeeper repository[1] to try and coordinate things.
Since then, here's the highlights of what I've done so far:
ChangeSet@1.1510, 2004-01-30 11:14:44-07:00, trini@kernel.crashing.org
Lots of changes to the serial stub driver.
In sum, it's got many of the features (but not all) of George
Anzginer's version (+ fix or two), and fully flushed out and tested
support for SERIAL_IOMEM.
ChangeSet@1.1509, 2004-01-30 11:10:03-07:00, trini@kernel.crashing.org
Change *kgdb_serial into kgdb_serial_driver. We will now have
only one serial driver.
ChangeSet@1.1508, 2004-01-30 10:44:55-07:00, trini@kernel.crashing.org
Convert the kgdb ethernet driver over to netpoll.
Patch from Pavel Machek <pavel@suse.cz>, who warns this probably
doesn't work.
ChangeSet@1.1505, 2004-01-29 14:30:47-07:00, trini@kernel.crashing.org
Move all KGDB questions into kernel/Kconfig.kgdb.
ChangeSet@1.1504, 2004-01-27 16:59:06-07:00, trini@kernel.crashing.org
- PPC32: Add KGDB support for PRePs (part of MULTIPLATFORM).
- PPC32: Add a choice of baud rate for the gen550 backend.
ChangeSet@1.1503, 2004-01-27 14:44:54-07:00, trini@kernel.crashing.org
Remove the function pointers from kgdb_ops.
Most have become kgdb_foo, instead of foo. The exceptions
are the gdb/kgdb register fiddling functions.
kgdb_gdb_regs_to_regs makes my head hurt.
ChangeSet@1.1502, 2004-01-27 11:46:13-07:00, trini@kernel.crashing.org
Merge by hand to current 2.6 bk.
--- UNTESTED, x86_64 might be broken ---
ChangeSet@1.1474.149.3, 2004-01-27 11:32:54-07:00, trini@kernel.crashing.org
- Send a 'T' packet initially, not an 'S' followed by 'p'
- On PPC32, try to pass in the correct signal back.
I'm mostly happy with the serial changes (and I'll set aside the user
console bits from George's version for now), but comments and criticisms
would be welcome. And as a reminder the BitKeeper version is
bk://ppc.bkbits.net/linux-2.6-kgdb and there's snapshots (thanks Dave!)
at http://www.codemonkey.org.uk/projects/bitkeeper/kgdb
--
Tom Rini
http://gate.crashing.org/~trini/
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: BitKeeper repo for KGDB
2004-01-28 17:56 ` Tom Rini
2004-01-28 18:04 ` Pavel Machek
@ 2004-02-06 22:35 ` Tom Rini
2004-02-06 22:55 ` Pavel Machek
1 sibling, 1 reply; 25+ messages in thread
From: Tom Rini @ 2004-02-06 22:35 UTC (permalink / raw)
To: Pavel Machek
Cc: akpm, george, amitkale, Andi Kleen, jim.houston,
Kernel Mailing List
On Wed, Jan 28, 2004 at 10:56:47AM -0700, Tom Rini wrote:
> On Wed, Jan 28, 2004 at 06:44:02PM +0100, Pavel Machek wrote:
[snip]
> > It's against 2.6 + -netpoll + Amit's patch.
>
> But doesn't -mm have a kgdb over enet driver that does work? It's just
> not been ported to Amit's bits, right?
OK. Based on this, and some other fixes, I've pushed my first cut of
KGDB over ethernet. It's not quite as robust as I'd like right now (I'm
still getting it just-right for connecting live), and I've got some not
quite finished improvements still locally, but it does work.
--
Tom Rini
http://gate.crashing.org/~trini/
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: BitKeeper repo for KGDB
2004-02-06 22:35 ` Tom Rini
@ 2004-02-06 22:55 ` Pavel Machek
2004-02-06 23:02 ` Tom Rini
0 siblings, 1 reply; 25+ messages in thread
From: Pavel Machek @ 2004-02-06 22:55 UTC (permalink / raw)
To: Tom Rini
Cc: akpm, george, amitkale, Andi Kleen, jim.houston,
Kernel Mailing List
Hi!
> > > It's against 2.6 + -netpoll + Amit's patch.
> >
> > But doesn't -mm have a kgdb over enet driver that does work? It's just
> > not been ported to Amit's bits, right?
>
> OK. Based on this, and some other fixes, I've pushed my first cut of
> KGDB over ethernet. It's not quite as robust as I'd like right now (I'm
> still getting it just-right for connecting live), and I've got some not
> quite finished improvements still locally, but it does work.
Is there way to get plain diff (against -mm or against Amit or
something?)
Pavel
--
When do you have a heart between your knees?
[Johanka's followup: and *two* hearts?]
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: BitKeeper repo for KGDB
2004-02-06 22:55 ` Pavel Machek
@ 2004-02-06 23:02 ` Tom Rini
2004-02-09 1:29 ` Matt Mackall
0 siblings, 1 reply; 25+ messages in thread
From: Tom Rini @ 2004-02-06 23:02 UTC (permalink / raw)
To: Pavel Machek
Cc: akpm, george, amitkale, Andi Kleen, jim.houston,
Kernel Mailing List
On Fri, Feb 06, 2004 at 11:55:35PM +0100, Pavel Machek wrote:
> Hi!
>
> > > > It's against 2.6 + -netpoll + Amit's patch.
> > >
> > > But doesn't -mm have a kgdb over enet driver that does work? It's just
> > > not been ported to Amit's bits, right?
> >
> > OK. Based on this, and some other fixes, I've pushed my first cut of
> > KGDB over ethernet. It's not quite as robust as I'd like right now (I'm
> > still getting it just-right for connecting live), and I've got some not
> > quite finished improvements still locally, but it does work.
>
> Is there way to get plain diff (against -mm or against Amit or
> something?)
I'll post a diff against -mm next week when I'm a bit happier with it,
but the following is against Amit's version + your patch to port it to
netpoll:
--- a/arch/ppc/kernel/ppc-stub.c Fri Feb 6 16:01:20 2004
+++ b/arch/ppc/kernel/ppc-stub.c Fri Feb 6 16:01:20 2004
@@ -252,9 +252,6 @@
return -1;
}
-/* We can either use this driver, which relies on other hooks, or
- * provide on some boards make use of kgdb_8250 */
-#ifndef CONFIG_KGDB_8250
static void
kgdbppc_write_char(int chr)
{
@@ -275,12 +272,11 @@
return 0;
}
-struct kgdb_serial kgdb_serial_driver = {
+struct kgdb_serial kgdbppc_serial = {
.read_char = kgdbppc_read_char,
.write_char = kgdbppc_write_char,
.hook = kgdbppc_hook
};
-#endif
int
kgdb_arch_init(void)
@@ -291,7 +287,18 @@
debugger_iabr_match = kgdb_iabr_match;
debugger_dabr_match = kgdb_dabr_match;
+ /* If we have the bigger 8250 serial driver, set that to be
+ * the output now. */
+#ifdef CONFIG_KGDB_8250
+ extern struct kgdb_serial kgdb8250_serial_driver;
+ kgdb_serial = &kgdb8250_serial_driver;
+#else
+ /* Take our serial driver. */
+ kgdb_serial = &kgdbppc_serial;
+#endif
+
return 0;
+
}
/*
--- a/drivers/net/Makefile Fri Feb 6 16:01:20 2004
+++ b/drivers/net/Makefile Fri Feb 6 16:01:20 2004
@@ -31,8 +31,6 @@
obj-$(CONFIG_OAKNET) += oaknet.o 8390.o
-obj-$(CONFIG_KGDB_ETH) += kgdb_eth.o
-
obj-$(CONFIG_DGRS) += dgrs.o
obj-$(CONFIG_RCPCI) += rcpci.o
obj-$(CONFIG_VORTEX) += 3c59x.o
@@ -190,4 +188,6 @@
obj-$(CONFIG_HAMRADIO) += hamradio/
obj-$(CONFIG_IRDA) += irda/
+# Netpoll users must be last.
obj-$(CONFIG_NETCONSOLE) += netconsole.o
+obj-$(CONFIG_KGDB_ETH) += kgdb_eth.o
--- a/drivers/net/kgdb_eth.c Fri Feb 6 16:01:20 2004
+++ b/drivers/net/kgdb_eth.c Fri Feb 6 16:01:20 2004
@@ -53,7 +53,7 @@
#include <asm/atomic.h>
#define IN_BUF_SIZE 512 /* power of 2, please */
-#define OUT_BUF_SIZE 256
+#define OUT_BUF_SIZE 30 /* We don't want to send too big of a packet. */
static char in_buf[IN_BUF_SIZE], out_buf[OUT_BUF_SIZE];
static int in_head, in_tail, out_count;
@@ -109,13 +109,11 @@
/* Is this gdb trying to attach? */
if (!netpoll_trap() && len == 8 && !strncmp(msg, "$Hc-1#09", 8))
- printk(KERN_CRIT "Someone is trying to attach\n");
-// kgdb_schedule_breakpoint();
+ breakpoint();
for (i = 0; i < len; i++) {
- if (msg[i] == 3) /* Check for ^C? */
- printk(KERN_CRIT "Someone is trying to ^C?\n");
-// kgdb_schedule_breakpoint();
+ if (msg[i] == 3)
+ breakpoint();
if (atomic_read(&in_count) >= IN_BUF_SIZE) {
/* buffer overflow, clear it */
@@ -136,6 +134,21 @@
__setup("kgdboe=", option_setup);
+static int hook(void)
+{
+ /* Un-initalized, don't go further. */
+ if (kgdboe != 1)
+ return 1;
+ return 0;
+}
+
+struct kgdb_serial kgdbeth_serial = {
+ .read_char = eth_getDebugChar,
+ .write_char = eth_putDebugChar,
+ .hook = hook,
+ .flush = eth_flushDebugChar,
+};
+
static int init_kgdboe(void)
{
#ifdef CONFIG_SMP
@@ -144,29 +157,15 @@
return -1;
}
#endif
-// set_debug_traps();
if(!np.remote_ip || netpoll_setup(&np))
return 1;
+ kgdb_serial = &kgdbeth_serial;
kgdboe = 1;
printk(KERN_INFO "kgdb: debugging over ethernet enabled\n");
return 0;
}
-static int hook(void) { printk("Hook called\n"); return 0; }
-static int begin(void) { printk("Begin called\n"); return 0; }
-static int end(void) { printk("End called\n"); return 0; }
-
module_init(init_kgdboe);
-
-struct kgdb_serial kgdbeth_serial = {
- .chunksize = 1,
- .read_char = eth_getDebugChar,
- .write_char = eth_putDebugChar,
- .hook = hook,
- .flush = eth_flushDebugChar,
- .begin_session = begin,
- .end_session = end,
-};
--- a/drivers/serial/kgdb_8250.c Fri Feb 6 16:01:20 2004
+++ b/drivers/serial/kgdb_8250.c Fri Feb 6 16:01:20 2004
@@ -489,7 +489,7 @@
serial_from_rs_table = 1;
}
-struct kgdb_serial kgdb_serial_driver = {
+struct kgdb_serial kgdb8250_serial_driver = {
.read_char = kgdb8250_read_char,
.write_char = kgdb8250_write_char,
.hook = kgdb8250_hook
--- a/include/linux/kgdb.h Fri Feb 6 16:01:20 2004
+++ b/include/linux/kgdb.h Fri Feb 6 16:01:20 2004
@@ -93,16 +93,13 @@
typedef unsigned char threadref[8];
struct kgdb_serial {
- int chunksize;
int (*read_char)(void);
void (*write_char)(int);
void (*flush)(void);
int (*hook)(void);
- void (*begin_session)(void);
- void (*end_session)(void);
};
-extern struct kgdb_serial kgdb_serial_driver;
+extern struct kgdb_serial *kgdb_serial;
extern struct kgdb_arch arch_kgdb_ops;
extern int kgdb_initialized;
--- a/kernel/kgdbstub.c Fri Feb 6 16:01:20 2004
+++ b/kernel/kgdbstub.c Fri Feb 6 16:01:20 2004
@@ -59,9 +59,22 @@
* The following are the stub functions for code which is arch specific
* and can be omitted on some arches
*/
+
+/*
+ * This function will handle the initalization of any architecture specific
+ * hooks. If there is a suitable early output driver, kgdb_serial
+ * can be pointed at it now.
+ */
int __attribute__ ((weak))
kgdb_arch_init(void)
{
+ /* If we have the default serial driver, set that to be the
+ * output now. */
+#ifdef CONFIG_KGDB_8250
+ extern struct kgdb_serial kgdb8250_serial_driver;
+ kgdb_serial = &kgdb8250_serial_driver;
+#endif
+
return 0;
}
@@ -145,7 +158,7 @@
gdb_breakpoint_t kgdb_break[MAX_BREAKPOINTS];
extern int pid_max;
-struct kgdb_serial *kgdb_serial = &kgdb_serial_driver;
+struct kgdb_serial *kgdb_serial;
int kgdb_initialized = 0;
int kgdb_enter = 0;
@@ -279,12 +292,6 @@
send_count = 0;
while ((ch = buffer[count])) {
- if (kgdb_serial->chunksize &&
- send_count >= kgdb_serial->chunksize) {
- if (kgdb_serial->flush)
- kgdb_serial->flush();
- send_count = 0;
- }
kgdb_serial->write_char(ch);
checksum += ch;
count ++;
@@ -666,10 +673,6 @@
return 0;
}
- /* Grab interface locks first */
- if (kgdb_serial->begin_session)
- kgdb_serial->begin_session();
-
/*
* Interrupts will be restored by the 'trap return' code, except when
* single stepping.
@@ -1089,10 +1092,6 @@
atomic_set(&debugger_active, 0);
local_irq_restore(flags);
- /* Release interface locks */
- if (kgdb_serial->end_session)
- kgdb_serial->end_session();
-
return ret;
}
@@ -1151,13 +1150,16 @@
void breakpoint(void)
{
- if (kgdb_initialized) {
- atomic_set(&kgdb_setting_breakpoint, 1);
- wmb();
- BREAKPOINT();
- wmb();
- atomic_set(&kgdb_setting_breakpoint, 0);
+ if (!kgdb_initialized) {
+ printk("calling set_debug_traps\n");
+ set_debug_traps();
}
+
+ atomic_set(&kgdb_setting_breakpoint, 1);
+ wmb();
+ BREAKPOINT();
+ wmb();
+ atomic_set(&kgdb_setting_breakpoint, 0);
}
void kgdb_nmihook(int cpu, void *regs)
@@ -1179,7 +1181,8 @@
return;
}
- /* Let the arch do any initalization it needs to */
+ /* Let the arch do any initalization it needs to, including
+ * pointing to a suitable early output device. */
kgdb_arch_init();
if (!kgdb_serial) {
@@ -1199,11 +1202,11 @@
/*
* Call the breakpoint() routine in GDB to start the debugging
- * session.
+ * session
*/
printk(KERN_CRIT "Waiting for connection from remote gdb... ");
breakpoint() ;
- printk(KERN_CRIT "Connected.\n");
+ printk("Connected.\n");
}
#ifdef CONFIG_KGDB_CONSOLE
--
Tom Rini
http://gate.crashing.org/~trini/
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: BitKeeper repo for KGDB
2004-02-06 23:02 ` Tom Rini
@ 2004-02-09 1:29 ` Matt Mackall
2004-02-09 15:50 ` Tom Rini
0 siblings, 1 reply; 25+ messages in thread
From: Matt Mackall @ 2004-02-09 1:29 UTC (permalink / raw)
To: Tom Rini
Cc: Pavel Machek, akpm, george, amitkale, Andi Kleen, jim.houston,
Kernel Mailing List
On Fri, Feb 06, 2004 at 04:02:54PM -0700, Tom Rini wrote:
> On Fri, Feb 06, 2004 at 11:55:35PM +0100, Pavel Machek wrote:
> > Hi!
> >
> > > > > It's against 2.6 + -netpoll + Amit's patch.
> > > >
> > > > But doesn't -mm have a kgdb over enet driver that does work? It's just
> > > > not been ported to Amit's bits, right?
> > >
> > > OK. Based on this, and some other fixes, I've pushed my first cut of
> > > KGDB over ethernet. It's not quite as robust as I'd like right now (I'm
> > > still getting it just-right for connecting live), and I've got some not
> > > quite finished improvements still locally, but it does work.
> >
> > Is there way to get plain diff (against -mm or against Amit or
> > something?)
>
> I'll post a diff against -mm next week when I'm a bit happier with it,
> but the following is against Amit's version + your patch to port it to
> netpoll:
> if (!netpoll_trap() && len == 8 && !strncmp(msg, "$Hc-1#09", 8))
> - printk(KERN_CRIT "Someone is trying to attach\n");
> -// kgdb_schedule_breakpoint();
> + breakpoint();
>
> for (i = 0; i < len; i++) {
> - if (msg[i] == 3) /* Check for ^C? */
> - printk(KERN_CRIT "Someone is trying to ^C?\n");
> -// kgdb_schedule_breakpoint();
> + if (msg[i] == 3)
> + breakpoint();
The kgdb_schedule_breakpoint stuff in -mm didn't just appear to make
things more complicated, it is in fact necessary. You cannot
reasonably expect to break deep inside the network stack IRQ handler
and then send more packets out the same interface. Expect especially
nasty results on SMP. It only works for the serial case because that
path is a priori known to be lockless.
--
Matt Mackall : http://www.selenic.com : Linux development and consulting
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: BitKeeper repo for KGDB
2004-02-09 1:29 ` Matt Mackall
@ 2004-02-09 15:50 ` Tom Rini
2004-02-09 17:38 ` Matt Mackall
0 siblings, 1 reply; 25+ messages in thread
From: Tom Rini @ 2004-02-09 15:50 UTC (permalink / raw)
To: Matt Mackall
Cc: Pavel Machek, akpm, george, amitkale, Andi Kleen, jim.houston,
Kernel Mailing List
On Sun, Feb 08, 2004 at 07:29:51PM -0600, Matt Mackall wrote:
> On Fri, Feb 06, 2004 at 04:02:54PM -0700, Tom Rini wrote:
> > On Fri, Feb 06, 2004 at 11:55:35PM +0100, Pavel Machek wrote:
> > > Hi!
> > >
> > > > > > It's against 2.6 + -netpoll + Amit's patch.
> > > > >
> > > > > But doesn't -mm have a kgdb over enet driver that does work? It's just
> > > > > not been ported to Amit's bits, right?
> > > >
> > > > OK. Based on this, and some other fixes, I've pushed my first cut of
> > > > KGDB over ethernet. It's not quite as robust as I'd like right now (I'm
> > > > still getting it just-right for connecting live), and I've got some not
> > > > quite finished improvements still locally, but it does work.
> > >
> > > Is there way to get plain diff (against -mm or against Amit or
> > > something?)
> >
> > I'll post a diff against -mm next week when I'm a bit happier with it,
> > but the following is against Amit's version + your patch to port it to
> > netpoll:
>
> > if (!netpoll_trap() && len == 8 && !strncmp(msg, "$Hc-1#09", 8))
> > - printk(KERN_CRIT "Someone is trying to attach\n");
> > -// kgdb_schedule_breakpoint();
> > + breakpoint();
> >
> > for (i = 0; i < len; i++) {
> > - if (msg[i] == 3) /* Check for ^C? */
> > - printk(KERN_CRIT "Someone is trying to ^C?\n");
> > -// kgdb_schedule_breakpoint();
> > + if (msg[i] == 3)
> > + breakpoint();
>
> The kgdb_schedule_breakpoint stuff in -mm didn't just appear to make
> things more complicated, it is in fact necessary. You cannot
> reasonably expect to break deep inside the network stack IRQ handler
> and then send more packets out the same interface. Expect especially
> nasty results on SMP. It only works for the serial case because that
> path is a priori known to be lockless.
Ah, hmm... I don't suppose there's any way to do this w/o touching
every arch's do_IRQ, is there?
--
Tom Rini
http://gate.crashing.org/~trini/
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: BitKeeper repo for KGDB
2004-02-09 15:50 ` Tom Rini
@ 2004-02-09 17:38 ` Matt Mackall
2004-02-10 7:57 ` Amit S. Kale
0 siblings, 1 reply; 25+ messages in thread
From: Matt Mackall @ 2004-02-09 17:38 UTC (permalink / raw)
To: Tom Rini
Cc: Pavel Machek, akpm, george, amitkale, Andi Kleen, jim.houston,
Kernel Mailing List
On Mon, Feb 09, 2004 at 08:50:13AM -0700, Tom Rini wrote:
> On Sun, Feb 08, 2004 at 07:29:51PM -0600, Matt Mackall wrote:
> > On Fri, Feb 06, 2004 at 04:02:54PM -0700, Tom Rini wrote:
> > > if (!netpoll_trap() && len == 8 && !strncmp(msg, "$Hc-1#09", 8))
> > > - printk(KERN_CRIT "Someone is trying to attach\n");
> > > -// kgdb_schedule_breakpoint();
> > > + breakpoint();
> > >
> > > for (i = 0; i < len; i++) {
> > > - if (msg[i] == 3) /* Check for ^C? */
> > > - printk(KERN_CRIT "Someone is trying to ^C?\n");
> > > -// kgdb_schedule_breakpoint();
> > > + if (msg[i] == 3)
> > > + breakpoint();
> >
> > The kgdb_schedule_breakpoint stuff in -mm didn't just appear to make
> > things more complicated, it is in fact necessary. You cannot
> > reasonably expect to break deep inside the network stack IRQ handler
> > and then send more packets out the same interface. Expect especially
> > nasty results on SMP. It only works for the serial case because that
> > path is a priori known to be lockless.
>
> Ah, hmm... I don't suppose there's any way to do this w/o touching
> every arch's do_IRQ, is there?
Probably not. On the other hand, it provides yet more motivation for
an irq handling refactoring in 2.7.
--
Matt Mackall : http://www.selenic.com : Linux development and consulting
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: BitKeeper repo for KGDB
2004-02-09 17:38 ` Matt Mackall
@ 2004-02-10 7:57 ` Amit S. Kale
2004-02-10 8:27 ` Amit S. Kale
2004-02-10 8:46 ` Dave Jones
0 siblings, 2 replies; 25+ messages in thread
From: Amit S. Kale @ 2004-02-10 7:57 UTC (permalink / raw)
To: Matt Mackall, Tom Rini
Cc: Pavel Machek, akpm, george, Andi Kleen, jim.houston,
Kernel Mailing List
http://www.codemonkey.org.uk/projects/bitkeeper/kgdb/kgdb-2004-02-10.diff
has grown over 10MB. Something wrong in generating a diff?
On Monday 09 Feb 2004 11:08 pm, Matt Mackall wrote:
> On Mon, Feb 09, 2004 at 08:50:13AM -0700, Tom Rini wrote:
> > On Sun, Feb 08, 2004 at 07:29:51PM -0600, Matt Mackall wrote:
> > > On Fri, Feb 06, 2004 at 04:02:54PM -0700, Tom Rini wrote:
> > > > if (!netpoll_trap() && len == 8 && !strncmp(msg, "$Hc-1#09", 8))
> > > > - printk(KERN_CRIT "Someone is trying to attach\n");
> > > > -// kgdb_schedule_breakpoint();
> > > > + breakpoint();
> > > >
> > > > for (i = 0; i < len; i++) {
> > > > - if (msg[i] == 3) /* Check for ^C? */
> > > > - printk(KERN_CRIT "Someone is trying to ^C?\n");
> > > > -// kgdb_schedule_breakpoint();
> > > > + if (msg[i] == 3)
> > > > + breakpoint();
> > >
> > > The kgdb_schedule_breakpoint stuff in -mm didn't just appear to make
> > > things more complicated, it is in fact necessary. You cannot
> > > reasonably expect to break deep inside the network stack IRQ handler
> > > and then send more packets out the same interface. Expect especially
> > > nasty results on SMP. It only works for the serial case because that
> > > path is a priori known to be lockless.
> >
> > Ah, hmm... I don't suppose there's any way to do this w/o touching
> > every arch's do_IRQ, is there?
>
> Probably not. On the other hand, it provides yet more motivation for
> an irq handling refactoring in 2.7.
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: BitKeeper repo for KGDB
2004-02-10 7:57 ` Amit S. Kale
@ 2004-02-10 8:27 ` Amit S. Kale
2004-02-10 19:26 ` Tom Rini
2004-02-10 8:46 ` Dave Jones
1 sibling, 1 reply; 25+ messages in thread
From: Amit S. Kale @ 2004-02-10 8:27 UTC (permalink / raw)
To: Matt Mackall, Tom Rini
Cc: Pavel Machek, akpm, george, Andi Kleen, jim.houston,
Kernel Mailing List
Tom,
Can you please post diffs wrt. 2.6.x kernels for the bitkeeper challanged
(me :)?
Thanks.
On Tuesday 10 Feb 2004 1:27 pm, Amit S. Kale wrote:
> http://www.codemonkey.org.uk/projects/bitkeeper/kgdb/kgdb-2004-02-10.diff
> has grown over 10MB. Something wrong in generating a diff?
>
> On Monday 09 Feb 2004 11:08 pm, Matt Mackall wrote:
> > On Mon, Feb 09, 2004 at 08:50:13AM -0700, Tom Rini wrote:
> > > On Sun, Feb 08, 2004 at 07:29:51PM -0600, Matt Mackall wrote:
> > > > On Fri, Feb 06, 2004 at 04:02:54PM -0700, Tom Rini wrote:
> > > > > if (!netpoll_trap() && len == 8 && !strncmp(msg, "$Hc-1#09", 8))
> > > > > - printk(KERN_CRIT "Someone is trying to attach\n");
> > > > > -// kgdb_schedule_breakpoint();
> > > > > + breakpoint();
> > > > >
> > > > > for (i = 0; i < len; i++) {
> > > > > - if (msg[i] == 3) /* Check for ^C? */
> > > > > - printk(KERN_CRIT "Someone is trying to ^C?\n");
> > > > > -// kgdb_schedule_breakpoint();
> > > > > + if (msg[i] == 3)
> > > > > + breakpoint();
> > > >
> > > > The kgdb_schedule_breakpoint stuff in -mm didn't just appear to make
> > > > things more complicated, it is in fact necessary. You cannot
> > > > reasonably expect to break deep inside the network stack IRQ handler
> > > > and then send more packets out the same interface. Expect especially
> > > > nasty results on SMP. It only works for the serial case because that
> > > > path is a priori known to be lockless.
> > >
> > > Ah, hmm... I don't suppose there's any way to do this w/o touching
> > > every arch's do_IRQ, is there?
> >
> > Probably not. On the other hand, it provides yet more motivation for
> > an irq handling refactoring in 2.7.
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: BitKeeper repo for KGDB
2004-02-10 7:57 ` Amit S. Kale
2004-02-10 8:27 ` Amit S. Kale
@ 2004-02-10 8:46 ` Dave Jones
2004-02-10 19:22 ` Tom Rini
1 sibling, 1 reply; 25+ messages in thread
From: Dave Jones @ 2004-02-10 8:46 UTC (permalink / raw)
To: Amit S. Kale
Cc: Matt Mackall, Tom Rini, Pavel Machek, akpm, george, Andi Kleen,
jim.houston, Kernel Mailing List
On Tue, Feb 10, 2004 at 01:27:40PM +0530, Amit S. Kale wrote:
> http://www.codemonkey.org.uk/projects/bitkeeper/kgdb/kgdb-2004-02-10.diff
> has grown over 10MB. Something wrong in generating a diff?
More likely mainline got ahead of the kgdb patch.
http://www.codemonkey.org.uk/projects/bitkeeper/kgdb/ is a diff
generated using bk export -tpatch -hdu -r`bk repogca bk://linux.bkbits.net/linux-2.5`,+
It's a tenth of the size. Look better ?
Dave
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: BitKeeper repo for KGDB
2004-02-10 8:46 ` Dave Jones
@ 2004-02-10 19:22 ` Tom Rini
2004-02-10 19:23 ` Dave Jones
0 siblings, 1 reply; 25+ messages in thread
From: Tom Rini @ 2004-02-10 19:22 UTC (permalink / raw)
To: Dave Jones, Amit S. Kale, Matt Mackall, Pavel Machek, akpm,
george, Andi Kleen, jim.houston, Kernel Mailing List
On Tue, Feb 10, 2004 at 08:46:05AM +0000, Dave Jones wrote:
> On Tue, Feb 10, 2004 at 01:27:40PM +0530, Amit S. Kale wrote:
> > http://www.codemonkey.org.uk/projects/bitkeeper/kgdb/kgdb-2004-02-10.diff
> > has grown over 10MB. Something wrong in generating a diff?
>
> More likely mainline got ahead of the kgdb patch.
That's true. I've stuck on 2.6.2-rc2 just because I'm, er, lazy.
> http://www.codemonkey.org.uk/projects/bitkeeper/kgdb/ is a diff
> generated using bk export -tpatch -hdu -r`bk repogca bk://linux.bkbits.net/linux-2.5`,+
>
> It's a tenth of the size. Look better ?
That looks about right (and much of that is the netpoll stuff).
--
Tom Rini
http://gate.crashing.org/~trini/
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: BitKeeper repo for KGDB
2004-02-10 19:22 ` Tom Rini
@ 2004-02-10 19:23 ` Dave Jones
0 siblings, 0 replies; 25+ messages in thread
From: Dave Jones @ 2004-02-10 19:23 UTC (permalink / raw)
To: Tom Rini
Cc: Amit S. Kale, Matt Mackall, Pavel Machek, akpm, george,
Andi Kleen, jim.houston, Kernel Mailing List
On Tue, Feb 10, 2004 at 12:22:34PM -0700, Tom Rini wrote:
> > generated using bk export -tpatch -hdu -r`bk repogca bk://linux.bkbits.net/linux-2.5`,+
> > It's a tenth of the size. Look better ?
> That looks about right (and much of that is the netpoll stuff).
cool. snapshotting script updated accordingly.
Dave
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: BitKeeper repo for KGDB
2004-02-10 8:27 ` Amit S. Kale
@ 2004-02-10 19:26 ` Tom Rini
2004-02-11 14:35 ` Amit S. Kale
0 siblings, 1 reply; 25+ messages in thread
From: Tom Rini @ 2004-02-10 19:26 UTC (permalink / raw)
To: Amit S. Kale
Cc: Matt Mackall, Pavel Machek, akpm, george, Andi Kleen, jim.houston,
Kernel Mailing List
On Tue, Feb 10, 2004 at 01:57:39PM +0530, Amit S. Kale wrote:
> Tom,
> Can you please post diffs wrt. 2.6.x kernels for the bitkeeper challanged
> (me :)?
I appologize for not getting to this sooner, but I've been doing a lot
of cleanups and such to the code (and not being as well versed in the
gdb protocol as I'd have like to been, spending some time looking into
user-error type bugs). But I'm now at the point where I'm much happier
with how KGDB works wrt breaking in, resuming sessions, etc, so I'm
going to start double checking kgdboe again and hopefully checkin, and
then break out for Andrew all of the stuff I've got. The following is
a patch against what I've pushed last (debug bits and all):
arch/i386/kernel/irq.c | 3
arch/ppc/kernel/irq.c | 5
arch/x86_64/kernel/irq.c | 2
drivers/net/kgdb_eth.c | 10 -
drivers/serial/kgdb_8250.c | 35 +-----
include/linux/kgdb.h | 24 +++-
init/main.c | 2
kernel/Kconfig.kgdb | 2
kernel/kgdbstub.c | 231 ++++++++++++++++++++-------------------------
9 files changed, 143 insertions(+), 171 deletions(-)
--- 1.49/arch/i386/kernel/irq.c Wed Jan 21 10:13:13 2004
+++ edited/arch/i386/kernel/irq.c Tue Feb 10 11:03:49 2004
@@ -34,6 +34,7 @@
#include <linux/proc_fs.h>
#include <linux/seq_file.h>
#include <linux/kallsyms.h>
+#include <linux/kgdb.h>
#include <asm/atomic.h>
#include <asm/io.h>
@@ -507,6 +508,8 @@
spin_unlock(&desc->lock);
irq_exit();
+
+ kgdb_process_breakpoint();
return 1;
}
--- 1.37/arch/ppc/kernel/irq.c Fri Jan 23 14:10:18 2004
+++ edited/arch/ppc/kernel/irq.c Tue Feb 10 11:03:49 2004
@@ -46,6 +46,7 @@
#include <linux/random.h>
#include <linux/seq_file.h>
#include <linux/cpumask.h>
+#include <linux/kgdb.h>
#include <asm/uaccess.h>
#include <asm/bitops.h>
@@ -538,7 +539,9 @@
if (irq != -2 && first)
/* That's not SMP safe ... but who cares ? */
ppc_spurious_interrupts++;
- irq_exit();
+ irq_exit();
+
+ kgdb_process_breakpoint();
}
unsigned long probe_irq_on (void)
--- 1.21/arch/x86_64/kernel/irq.c Wed Dec 31 22:27:45 2003
+++ edited/arch/x86_64/kernel/irq.c Tue Feb 10 11:03:49 2004
@@ -405,6 +405,8 @@
spin_unlock(&desc->lock);
irq_exit();
+
+ kgdb_process_breakpoint();
return 1;
}
--- 1.3/drivers/net/kgdb_eth.c Thu Feb 5 16:05:24 2004
+++ edited/drivers/net/kgdb_eth.c Tue Feb 10 11:03:49 2004
@@ -60,8 +60,6 @@
static atomic_t in_count;
int kgdboe = 0; /* Default to tty mode */
-extern void set_debug_traps(void);
-extern void breakpoint(void);
static void rx_hook(struct netpoll *np, int port, char *msg, int len);
static struct netpoll np = {
@@ -91,6 +89,7 @@
if(out_count && np.dev) {
netpoll_send_udp(&np, out_buf, out_count);
out_count = 0;
+ memset(out_buf, 0, sizeof(out_buf));
}
}
@@ -108,13 +107,10 @@
np->remote_port = port;
/* Is this gdb trying to attach? */
- if (!netpoll_trap() && len == 8 && !strncmp(msg, "$Hc-1#09", 8))
- breakpoint();
+ if (!kgdb_connected && !netpoll_trap())
+ kgdb_schedule_breakpoint();
for (i = 0; i < len; i++) {
- if (msg[i] == 3)
- breakpoint();
-
if (atomic_read(&in_count) >= IN_BUF_SIZE) {
/* buffer overflow, clear it */
in_head = in_tail = 0;
--- 1.3/drivers/serial/kgdb_8250.c Thu Feb 5 16:05:24 2004
+++ edited/drivers/serial/kgdb_8250.c Tue Feb 10 11:23:45 2004
@@ -65,9 +65,6 @@
static atomic_t kgdb8250_buf_in_cnt;
static int kgdb8250_buf_out_inx;
-static int kgdb8250_got_dollar = -3, kgdb8250_got_H = -3,
- kgdb8250_interrupt_iteration = 0;
-
/* Determine serial information. */
static struct serial_state state = {
.magic = SSTATE_MAGIC,
@@ -98,7 +95,6 @@
static void (*serial_outb) (unsigned char val, unsigned long addr);
static unsigned long (*serial_inb) (unsigned long addr);
-extern void set_debug_traps(void); /* GDB routine */
int serial8250_release_irq(int irq);
static int kgdb8250_init(void);
@@ -250,6 +246,12 @@
if (irq != gdb_async_info.line)
return IRQ_NONE;
+ /* If we get an interrupt, then KGDB is trying to connect. */
+ if (!kgdb_connected) {
+ kgdb_schedule_breakpoint();
+ return IRQ_HANDLED;
+ }
+
local_irq_save(flags);
spin_lock(&uart_interrupt_lock);
@@ -265,28 +267,6 @@
continue;
}
- if (atomic_read(&kgdb_killed_or_detached)) {
- if (chr == '$')
- kgdb8250_got_dollar =
- kgdb8250_interrupt_iteration;
- if (kgdb8250_interrupt_iteration ==
- kgdb8250_got_dollar + 1 && chr == 'H')
- kgdb8250_got_H = kgdb8250_interrupt_iteration;
- else if (kgdb8250_interrupt_iteration ==
- kgdb8250_got_H + 1 && chr == 'c') {
- kgdb8250_buf[kgdb8250_buf_in_inx++] = chr;
- atomic_inc(&kgdb8250_buf_in_cnt);
- atomic_set(&kgdb_might_be_resumed, 1);
- wmb();
- breakpoint();
- atomic_set(&kgdb_might_be_resumed, 0);
- kgdb8250_interrupt_iteration = 0;
- kgdb8250_got_dollar = -3;
- kgdb8250_got_H = -3;
- continue;
- }
- }
-
if (atomic_read(&kgdb8250_buf_in_cnt) >= GDB_BUF_SIZE) {
/* buffer overflow, clear it */
kgdb8250_buf_in_inx = 0;
@@ -299,9 +279,6 @@
kgdb8250_buf_in_inx &= (GDB_BUF_SIZE - 1);
atomic_inc(&kgdb8250_buf_in_cnt);
} while (iir & UART_IIR_RDI);
-
- if (atomic_read(&kgdb_killed_or_detached))
- kgdb8250_interrupt_iteration++;
spin_unlock(&uart_interrupt_lock);
local_irq_restore(flags);
--- 1.4/include/linux/kgdb.h Thu Feb 5 16:05:24 2004
+++ edited/include/linux/kgdb.h Tue Feb 10 11:25:25 2004
@@ -11,8 +11,21 @@
#include <asm/atomic.h>
#include <linux/debugger.h>
+/*
+ * This file should not include ANY others. This makes it usable
+ * most anywhere without the fear of include order or inclusion.
+ * TODO: Make it so!
+ *
+ * This file may be included all the time. It is only active if
+ * CONFIG_KGDB is defined, otherwise it stubs out all the macros
+ * and entry points.
+ */
+
+#if defined(CONFIG_KGDB) && !defined(__ASSEMBLY__)
/* To enter the debugger explicitly. */
-void breakpoint(void);
+extern void breakpoint(void);
+extern void kgdb_process_breakpoint(void);
+extern volatile int kgdb_connected;
#ifndef KGDB_MAX_NO_CPUS
#if CONFIG_NR_CPUS > 8
@@ -21,10 +34,8 @@
#define KGDB_MAX_NO_CPUS 8
#endif
-extern atomic_t kgdb_setting_breakpoint;
-extern atomic_t kgdb_killed_or_detached;
-extern atomic_t kgdb_might_be_resumed;
-
+extern volatile int kgdb_connected;
+
extern struct task_struct *kgdb_usethread, *kgdb_contthread;
enum gdb_bptype
@@ -110,4 +121,7 @@
int kgdb_hexToLong(char **ptr, long *longValue);
char *kgdb_mem2hex(char *mem, char *buf, int count, int can_fault);
+#else
+#define kgdb_process_breakpoint() do {} while(0)
+#endif /* KGDB && !__ASSEMBLY__ */
#endif /* _KGDB_H_ */
--- 1.118/init/main.c Tue Jan 27 11:41:03 2004
+++ edited/init/main.c Tue Feb 10 11:03:49 2004
@@ -581,8 +581,8 @@
do_pre_smp_initcalls();
smp_init();
- debugger_entry();
do_basic_setup();
+ debugger_entry();
prepare_namespace();
--- 1.1/kernel/Kconfig.kgdb Thu Jan 29 14:30:40 2004
+++ edited/kernel/Kconfig.kgdb Tue Feb 10 11:03:49 2004
@@ -101,7 +101,7 @@
config KGDB_CONSOLE
bool "KGDB: Console messages through gdb"
- depends on KGDB
+ depends on KGDB && !KGDB_ETH
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.
--- 1.6/kernel/kgdbstub.c Thu Feb 5 16:05:24 2004
+++ edited/kernel/kgdbstub.c Tue Feb 10 12:11:55 2004
@@ -117,7 +117,7 @@
kgdb_arch_handle_exception(int vector, int signo, int err_code, char *InBuffer,
char *outBuffer, struct pt_regs *regs)
{
- return 0;
+ return -1; /* Do not exit from the handler. */
}
int __attribute__ ((weak))
@@ -164,14 +164,12 @@
int kgdb_enter = 0;
static const char hexchars[] = "0123456789abcdef";
-int get_char(char *addr, unsigned char *data, int can_fault);
-int set_char(char *addr, int data, int can_fault);
+static int get_char(char *addr, unsigned char *data, int can_fault);
+static int set_char(char *addr, int data, int can_fault);
spinlock_t slavecpulocks[KGDB_MAX_NO_CPUS];
-volatile int procindebug[KGDB_MAX_NO_CPUS];
-atomic_t kgdb_setting_breakpoint;
-atomic_t kgdb_killed_or_detached;
-atomic_t kgdb_might_be_resumed;
+static volatile int procindebug[KGDB_MAX_NO_CPUS];
+static atomic_t kgdb_setting_breakpoint;
volatile int kgdb_connected;
struct task_struct *kgdb_usethread, *kgdb_contthread;
@@ -221,13 +219,14 @@
{
unsigned char checksum;
unsigned char xmitcsum;
- int i;
int count;
char ch;
do {
/* wait around for the start character, ignore all other characters */
- while ((ch = (kgdb_serial->read_char() & 0x7f)) != '$');
+ while ((ch = (kgdb_serial->read_char() & 0x7f)) != '$')
+ ; /* Spin */
+ kgdb_connected = 1;
checksum = 0;
xmitcsum = -1;
@@ -249,24 +248,17 @@
xmitcsum += hex(kgdb_serial->read_char() & 0x7f);
if (checksum != xmitcsum)
- kgdb_serial->write_char('-'); /* failed checksum */
- else {
- kgdb_serial->write_char('+'); /* successful transfer */
- /* if a sequence char is present, reply the sequence ID */
- if (buffer[2] == ':') {
- kgdb_serial->write_char(buffer[0]);
- kgdb_serial->write_char(buffer[1]);
- /* remove sequence chars from buffer */
- count = strlen(buffer);
- for (i = 3; i <= count; i++)
- buffer[i - 3] = buffer[i];
- }
- }
+ /* Retransmit. */
+ kgdb_serial->write_char('-');
+ else
+ /* ACK. */
+ kgdb_serial->write_char('+');
+
if (kgdb_serial->flush)
kgdb_serial->flush();
}
} while (checksum != xmitcsum);
-
+ printk("%s : %s\n", __func__, buffer);
}
@@ -275,27 +267,25 @@
* Check for gdb connection if asked for.
*/
static void
-putpacket(char *buffer, int checkconnect)
+putpacket(char *buffer)
{
unsigned char checksum;
int count;
char ch;
- static char gdbseq[] = "$Hc-1#09";
- int i;
- int send_count;
+
+ printk("%s : %s\n", __func__, buffer);
/* $<packet info>#<checksum>. */
do {
- kgdb_serial->write_char('$');
checksum = 0;
count = 0;
- send_count = 0;
+ /* Write out the packet. */
+ kgdb_serial->write_char('$');
while ((ch = buffer[count])) {
kgdb_serial->write_char(ch);
checksum += ch;
- count ++;
- send_count ++;
+ count++;
}
kgdb_serial->write_char('#');
@@ -303,31 +293,7 @@
kgdb_serial->write_char(hexchars[checksum % 16]);
if (kgdb_serial->flush)
kgdb_serial->flush();
-
- i = 0;
- while ((ch = kgdb_serial->read_char()) == gdbseq[i++] &&
- checkconnect) {
- if (!gdbseq[i]) {
- kgdb_serial->write_char('+');
- if (kgdb_serial->flush)
- kgdb_serial->flush();
- breakpoint();
-
- /*
- * GDB is available now.
- * Retransmit this packet.
- */
- break;
- }
- }
- if (checkconnect && ch == 3) {
- kgdb_serial->write_char('+');
- if (kgdb_serial->flush)
- kgdb_serial->flush();
- breakpoint();
- }
- } while (( ch & 0x7f) != '+');
-
+ } while ((kgdb_serial->read_char() & 0x7f) != '+');
}
/*
@@ -568,7 +534,10 @@
return -1;
kgdb_break[i].state = bp_disabled;
return 0;
- }
+ } else
+ printk("Breakpoint %d is state %d and addr %08lx\n",
+ i, kgdb_break[i].state,
+ kgdb_break[i].bpt_addr);
}
return -1;
}
@@ -576,6 +545,9 @@
int remove_all_break(void)
{
int i;
+
+ printk("%s\n", __func__);
+
for (i=0; i < MAX_BREAKPOINTS; i++) {
if(kgdb_break[i].state == bp_enabled) {
unsigned long addr = kgdb_break[i].bpt_addr;
@@ -708,20 +680,9 @@
/* Master processor is completely in the debugger */
kgdb_post_master_code(linux_regs, exVector, err_code);
- if (atomic_read(&kgdb_killed_or_detached) &&
- atomic_read(&kgdb_might_be_resumed)) {
- getpacket(remcomInBuffer);
- if(remcomInBuffer[0] == 'H' && remcomInBuffer[1] =='c') {
- remove_all_break();
- atomic_set(&kgdb_killed_or_detached, 0);
- strcpy(remcomOutBuffer, "OK");
- }
- else
- return 1;
- }
- else {
-
- /* reply to host that an exception has occurred */
+ /* If kgdb is connected, then an exception has occured, and
+ * we need to pass something back to GDB. */
+ if (kgdb_connected) {
ptr = remcomOutBuffer;
*ptr++ = 'T';
*ptr++ = hexchars[(signo >> 4) % 16];
@@ -741,10 +702,10 @@
int_to_threadref(&thref, shadow_pid(current->pid));
ptr = pack_threadid(ptr, &thref);
*ptr++ = ';';
- }
- putpacket(remcomOutBuffer, 0);
- kgdb_connected = 1;
-
+
+ putpacket(remcomOutBuffer);
+ }
+
kgdb_usethread = current;
kgdb_usethreadid = shadow_pid(current->pid);
@@ -765,11 +726,28 @@
#endif
switch (remcomInBuffer[0]) {
case '?':
- remcomOutBuffer[0] = 'S';
- remcomOutBuffer[1] = hexchars[signo >> 4];
- remcomOutBuffer[2] = hexchars[signo % 16];
+ /* reply to host that an exception has occurred */
+ ptr = remcomOutBuffer;
+ *ptr++ = 'T';
+ *ptr++ = hexchars[(signo >> 4) % 16];
+ *ptr++ = hexchars[signo % 16];
+ *ptr++ = hexchars[(PC_REGNUM >> 4) % 16];
+ *ptr++ = hexchars[PC_REGNUM % 16];
+ *ptr++ = ':';
+ ptr = kgdb_mem2hex((char *)&linux_regs->PTRACE_PC, ptr,
+ 4, 0);
+ *ptr++ = ';';
+ *ptr++ = hexchars[SP_REGNUM >> 4];
+ *ptr++ = hexchars[SP_REGNUM & 0xf];
+ *ptr++ = ':';
+ ptr = kgdb_mem2hex(((char *)linux_regs) + SP_REGNUM * 4,
+ ptr, 4, 0);
+ *ptr++ = ';';
+ ptr += strlen(strcpy(ptr, "thread:"));
+ int_to_threadref(&thref, shadow_pid(current->pid));
+ ptr = pack_threadid(ptr, &thref);
+ *ptr++ = ';';
break;
-
case 'g': /* return the value of the CPU registers */
thread = kgdb_usethread;
@@ -854,29 +832,19 @@
strcpy(remcomOutBuffer, "E02");
}
break;
-
-
- /* Continue and Single Step are Architecture specific
- * and will not be handled by the generic code.
- */
-
-
- /* kill the program. KGDB should treat this like a
- * continue.
- */
+ /* GDB has told us it is detaching. So we'll remove all of
+ * our breakpoints and get back to 'normal'. */
case 'D':
strcpy(remcomOutBuffer, "OK");
- remove_all_break();
- putpacket(remcomOutBuffer, 0);
- kgdb_connected = 0;
- goto default_handle;
-
+ putpacket(remcomOutBuffer);
+ /* fall through. */
+ /* GDB is telling us to 'kill' the running process. We'll
+ * just stop debugging. */
case 'k':
remove_all_break();
kgdb_connected = 0;
- goto default_handle;
-
- /* query */
+ goto kgdb_exit;
+ /* query */
case 'q':
switch (remcomInBuffer[1]) {
case 's':
@@ -973,7 +941,6 @@
break;
case 'c':
- atomic_set(&kgdb_killed_or_detached, 0);
ptr = &remcomInBuffer[2];
kgdb_hexToLong(&ptr, &threadid);
if (!threadid) {
@@ -1031,11 +998,16 @@
bpt_type);
}
else {
- if (bpt_type == bp_breakpoint)
+ if (bpt_type == bp_breakpoint) {
+ printk("bpt_type == bp_breakpoint");
ret = remove_break(addr);
- else
+ printk(": %d\n", ret);
+ } else {
+ printk("bpt_type != bp_breakpoint");
ret = kgdb_arch_remove_break(addr,
bpt_type);
+ printk(": %d\n", ret);
+ }
}
if (ret == 0)
@@ -1046,16 +1018,12 @@
break;
default:
- default_handle:
- ret = kgdb_arch_handle_exception(exVector, signo,
- err_code, remcomInBuffer,
- remcomOutBuffer, linux_regs);
-
- if(ret >= 0 || remcomInBuffer[0] == 'D' ||
- remcomInBuffer[0] == 'k')
+ if (kgdb_arch_handle_exception(exVector, signo,
+ err_code, remcomInBuffer,
+ remcomOutBuffer,
+ linux_regs) >= 0)
+ /* An error occured. */
goto kgdb_exit;
-
-
} /* switch */
#if KGDB_DEBUG
bust_spinlocks(1);
@@ -1064,7 +1032,7 @@
#endif
/* reply to the request */
- putpacket(remcomOutBuffer, 0);
+ putpacket(remcomOutBuffer);
}
kgdb_exit:
@@ -1088,7 +1056,6 @@
}
/* Free debugger_active */
- atomic_set(&kgdb_killed_or_detached, 1);
atomic_set(&debugger_active, 0);
local_irq_restore(flags);
@@ -1118,21 +1085,9 @@
/* Free debugger_active */
atomic_set(&debugger_active, 0);
- /* This flag is used, if gdb has detached and wants to start
- * another session
- */
- atomic_set(&kgdb_killed_or_detached, 1);
- atomic_set(&kgdb_might_be_resumed, 0);
-
for (i = 0; i < MAX_BREAKPOINTS; i++)
kgdb_break[i].state = bp_disabled;
-
- /*
- * In case GDB is started before us, ack any packets (presumably
- * "$?#xx") sitting there. */
- kgdb_serial->write_char('+');
-
linux_debug_hook = kgdb_handle_exception;
/* We can't do much if this fails */
@@ -1150,10 +1105,8 @@
void breakpoint(void)
{
- if (!kgdb_initialized) {
- printk("calling set_debug_traps\n");
+ if (!kgdb_initialized)
set_debug_traps();
- }
atomic_set(&kgdb_setting_breakpoint, 1);
wmb();
@@ -1209,6 +1162,30 @@
printk("Connected.\n");
}
+/*
+ * Sometimes we need to schedule a breakpoint because we can't break
+ * right where we are.
+ */
+static int kgdb_need_breakpoint[NR_CPUS];
+
+void kgdb_schedule_breakpoint(void)
+{
+ kgdb_need_breakpoint[smp_processor_id()] = 1;
+}
+
+void kgdb_process_breakpoint(void)
+{
+ /*
+ * Handle a breakpoint queued from inside network driver code
+ * to avoid reentrancy issues
+ */
+ if (kgdb_need_breakpoint[smp_processor_id()]) {
+ printk("Making a break\n");
+ kgdb_need_breakpoint[smp_processor_id()] = 0;
+ breakpoint();
+ }
+}
+
#ifdef CONFIG_KGDB_CONSOLE
char kgdbconbuf[BUFMAX];
@@ -1239,7 +1216,7 @@
*bufptr = '\0';
s += wcount;
- putpacket(kgdbconbuf, 1);
+ putpacket(kgdbconbuf);
}
local_irq_restore(flags);
I'll check it in incrementally when I'm done, so it's easier to see
what's what in bkweb.
--
Tom Rini
http://gate.crashing.org/~trini/
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: BitKeeper repo for KGDB
2004-02-10 19:26 ` Tom Rini
@ 2004-02-11 14:35 ` Amit S. Kale
0 siblings, 0 replies; 25+ messages in thread
From: Amit S. Kale @ 2004-02-11 14:35 UTC (permalink / raw)
To: Tom Rini
Cc: Matt Mackall, Pavel Machek, akpm, george, Andi Kleen, jim.houston,
Kernel Mailing List
OOPS!
I started downloading your changes from bitkeeper web interface and didn't
finish that. We have got again out of sync.
I have setup a cvs repository in the meantime. More info at
http://kgdb.sourceforge.net/cvs.html
You can add yourself to kgdb project as a developer. Then you'll be able to
checkin changes yourself.
Thanks.
-Amit
On Wednesday 11 Feb 2004 12:56 am, Tom Rini wrote:
> On Tue, Feb 10, 2004 at 01:57:39PM +0530, Amit S. Kale wrote:
> > Tom,
> > Can you please post diffs wrt. 2.6.x kernels for the bitkeeper challanged
> > (me :)?
>
> I appologize for not getting to this sooner, but I've been doing a lot
> of cleanups and such to the code (and not being as well versed in the
> gdb protocol as I'd have like to been, spending some time looking into
> user-error type bugs). But I'm now at the point where I'm much happier
> with how KGDB works wrt breaking in, resuming sessions, etc, so I'm
> going to start double checking kgdboe again and hopefully checkin, and
> then break out for Andrew all of the stuff I've got. The following is
> a patch against what I've pushed last (debug bits and all):
^ permalink raw reply [flat|nested] 25+ messages in thread
end of thread, other threads:[~2004-02-11 14:36 UTC | newest]
Thread overview: 25+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-01-27 18:40 BitKeeper repo for KGDB Tom Rini
2004-01-27 19:31 ` Sam Ravnborg
2004-01-27 19:46 ` Dave Jones
2004-01-27 20:07 ` Chris Wright
2004-01-27 21:02 ` Tom Rini
2004-01-28 9:50 ` Dave Jones
2004-01-28 16:51 ` Pavel Machek
2004-01-28 17:05 ` Tom Rini
2004-01-28 17:44 ` Pavel Machek
2004-01-28 17:56 ` Tom Rini
2004-01-28 18:04 ` Pavel Machek
2004-02-06 22:35 ` Tom Rini
2004-02-06 22:55 ` Pavel Machek
2004-02-06 23:02 ` Tom Rini
2004-02-09 1:29 ` Matt Mackall
2004-02-09 15:50 ` Tom Rini
2004-02-09 17:38 ` Matt Mackall
2004-02-10 7:57 ` Amit S. Kale
2004-02-10 8:27 ` Amit S. Kale
2004-02-10 19:26 ` Tom Rini
2004-02-11 14:35 ` Amit S. Kale
2004-02-10 8:46 ` Dave Jones
2004-02-10 19:22 ` Tom Rini
2004-02-10 19:23 ` Dave Jones
2004-01-30 18:18 ` Tom Rini
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox