On Wed, 2006-08-30 at 06:47 -0700, Furqan Ahmed Ghulam Shabbir wrote:
> Hi,
>  I have tried to work with kgdb using serial but wasn't able
>  to do that due to errors now I am trying to setup kgdb with
>  ethernet. I successfully applied the all patches
>  
>     and configured with ethernet support for kgdb with make
>  menuconfig. then i gave make bzImage command and placed 
> both System.map and bzImage to the target machine's boot
> directory. Then I have made an entry in grub.conf file as
> 
> title 2.6.13-kgdb(eth)
> root (hd0,0)
> kernel /boot/vmlinuz-2.6.13-kgdb ro root=/dev/hdb1 [EMAIL 
> PROTECTED]/,@192.168.1.116/console=ttyS1,115200
> (i have tried with this line also "console" at next line)
> kernel /boot/vmlinuz-2.6.13-kgdb ro root=/dev/hdb1 [EMAIL 
> PROTECTED]/,@192.168.1.116/
> console=ttyS1,115200

I'm not having any problems with kgbd on 2.6.13. I'm using an enhanced
kgdboe.c (attached) that allows for kgdboe to be configured after 
booting. This works for us because we rename the interfaces during
the rc scripts. I cat into /proc/kgdboe at the end of our rc scripts
with:
---------------------------------------------------------------------
#
#
# Enable kgdb if compiled in the kernel
#
if [[ -e /proc/sys/kgdboe ]]; then
        echo "rc.local: Initialize kgdb";
        echo "rc.local:
[EMAIL PROTECTED]/mgmt,[EMAIL PROTECTED]/00:0F:90:D5:36:C4
> /proc/sys/kgdboe";
        echo
"[EMAIL PROTECTED]/mgmt,[EMAIL PROTECTED]/00:0F:90:D5:36:C4"
> /proc/sys/kgdboe;fi
#
--------------------------------------------------------------------

If that doesn't work you could add a debug printf/KGDB_DEBUG()
at the packet routines like I did. It only takes about an hour
to populate the Ethernet packet path with an ample supply of
debug to clearly see what's going down. I wonder if we shouldn't
have them available as KGDB_DEBUG(8, msg) code that's normally
optimized out but available to dudes like yourself when things
don't work right.

-piet

> 
> 
> to be able to boot with newly copied bzImage and specified parameters in 
> console of target machine
> as
>    [EMAIL PROTECTED]/,@192.168.0.118/
>  (target/development)
>    then I have started gdb at development machine by 
> issuing the command gdb ./vmlinux.
>     
>    now at gdb prompt, i have given the command 
> target remote udp:192.168.0.116:6443
>  At this stage, I am getting an error that 
> "ignoring packet error".
> 
> 
>    please help me on this regard. 
>    Thanks 
>    
> 
> 
> 
> 
> 
> ______________________________________________________________________
> Want to be your own boss? Learn how on Yahoo! Small Business. 
> -------------------------------------------------------------------------
> Using Tomcat but need to do more? Need to support web services, security?
> Get stuff done quickly with pre-integrated technology to make your job easier
> Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
> http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
> _______________________________________________ Kgdb-bugreport mailing list 
> [email protected] 
> https://lists.sourceforge.net/lists/listinfo/kgdb-bugreport
-- 
Piet Delaney
BlueLane Teck
W: (408) 200-5256; [EMAIL PROTECTED]
H: (408) 243-8872; [EMAIL PROTECTED]

/*
 * drivers/net/kgdboe.c
 *
 * A network interface for GDB.
 * Based upon 'gdbserial' by David Grothe <[EMAIL PROTECTED]>
 * and Scott Foehner <[EMAIL PROTECTED]>
 *
 * Maintainers: Amit S. Kale <[EMAIL PROTECTED]> and
 * 		Tom Rini <[EMAIL PROTECTED]>
 *
 * 2004 (c) Amit S. Kale <[EMAIL PROTECTED]>
 * 2004-2005 (c) MontaVista Software, Inc.
 * 2005 (c) Wind River Systems, Inc.
 *
 * Other folks:
 * San Mehat <[EMAIL PROTECTED]>
 * Robert Walsh <[EMAIL PROTECTED]>
 * wangdi <[EMAIL PROTECTED]>.
 * Matt Mackall <[EMAIL PROTECTED]>
 * Pavel Machek <[EMAIL PROTECTED]>
 * Jason Wessel <[EMAIL PROTECTED]>
 *
 * This file is licensed under the terms of the GNU General Public License
 * version 2. This program is licensed "as is" without any warranty of any
 * kind, whether express or implied.
 *
 * Changes:
 * 3/10/05 - Jason Wessel <[EMAIL PROTECTED]>
 * - Added ability to compile/load as module
 *
 * Known problems:
 * - There is no way to deny the unloading of the module
 *   if KGDB is connected, but an attempt is made to handle it
 */

#include <linux/kernel.h>
#include <linux/interrupt.h>
#include <linux/string.h>
#include <linux/kgdb.h>
#include <linux/netpoll.h>
#include <linux/init.h>

#include <asm/atomic.h>

#define IN_BUF_SIZE 512		/* power of 2, please */
#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;
static atomic_t in_count;
/* 0 = unconfigured, 1 = netpoll options parsed, 2 = fully configured. */
static int configured;

static void rx_hook(struct netpoll *np, int port, char *msg, int len);
static void eth_pre_exception_handler(void);
static void eth_post_exception_handler(void);
static int eth_get_char(void);
static void eth_flush_buf(void);
static void eth_put_char(int chr);
int init_kgdboe(void);

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},
};

MODULE_DESCRIPTION("KGDB driver for network interfaces");
MODULE_LICENSE("GPL");
static char config[256];
module_param_string(kgdboe, config, 256, 0);
MODULE_PARM_DESC(kgdboe, " [EMAIL PROTECTED]/[dev],"
		 "[tgt-port]@<tgt-ip>/<tgt-macaddr>\n");

static struct kgdb_io local_kgdb_io_ops = {
	.read_char = eth_get_char,
	.write_char = eth_put_char,
	.init = init_kgdboe,
	.flush = eth_flush_buf,
	.pre_exception = eth_pre_exception_handler,
	.post_exception = eth_post_exception_handler
};

static void eth_pre_exception_handler(void)
{
	netpoll_set_trap(1);
}

static void eth_post_exception_handler(void)
{
	netpoll_set_trap(0);
}

static int eth_get_char(void)
{
	int chr;

	while (atomic_read(&in_count) == 0)
		netpoll_poll(&np);

	chr = in_buf[in_tail++];
	in_tail &= (IN_BUF_SIZE - 1);
	atomic_dec(&in_count);
	return chr;
}

static void eth_flush_buf(void)
{
	if (out_count && np.dev) {
		netpoll_send_udp(&np, out_buf, out_count);
		memset(out_buf, 0, sizeof(out_buf));
		out_count = 0;
	}
}

static void eth_put_char(int chr)
{
	out_buf[out_count++] = chr;
	if (out_count == OUT_BUF_SIZE)
		eth_flush_buf();
}

static void rx_hook(struct netpoll *np, int port, char *msg, int len)
{
	int i;

	np->remote_port = port;

	/*
	 * This could be GDB trying to attach.  But it could also be GDB
	 * finishing up a session, with kgdb_connected=0 but GDB sending
	 * an ACK for the final packet.  To make sure we don't try and
	 * make a breakpoint when GDB is leaving, make sure that if
	 * !kgdb_connected the only len == 1 packet we allow is ^C.
	 */
	if (!kgdb_connected && (len != 1 || msg[0] == 3) &&
	    !atomic_read(&kgdb_setting_breakpoint))
		tasklet_schedule(&kgdb_tasklet_breakpoint);

	for (i = 0; i < len; i++) {
		if (msg[i] == 3)
			tasklet_schedule(&kgdb_tasklet_breakpoint);

		if (atomic_read(&in_count) >= IN_BUF_SIZE) {
			/* buffer overflow, clear it */
			in_head = in_tail = 0;
			atomic_set(&in_count, 0);
			break;
		}
		in_buf[in_head++] = msg[i];
		in_head &= (IN_BUF_SIZE - 1);
		atomic_inc(&in_count);
	}
}

static int option_setup(char *opt)
{
	configured = !netpoll_parse_options(&np, opt);
	return 0;
}

__setup("kgdboe=", option_setup);

int init_kgdboe(void)
{
	/* Already done? */
	if (configured == 2)
		return 0;

	if (strlen(config))
		option_setup(config);

	if (!configured) {
		printk("kgdboe: configuration incorrect - kgdboe not "
		       "loaded.\n");
		printk("  Usage: [EMAIL PROTECTED]/[dev],[tgt-port]"
		       "@<tgt-ip>/[tgt-macaddr]\n");
		return -EINVAL;
	}

	if (netpoll_setup(&np)) {
		printk("kgdboe: netpoll_setup failed kgdboe failed\n");
		return -EINVAL;
	}

	if (kgdb_register_io_module(&local_kgdb_io_ops))
		return -EINVAL;

	printk(KERN_INFO "kgdboe: debugging over ethernet enabled\n");

	configured = 2;

	return 0;
}

static void cleanup_kgdboe(void)
{
	netpoll_cleanup(&np);
	configured = 0;

	kgdb_unregister_io_module(&local_kgdb_io_ops);
}

module_init(init_kgdboe);
module_exit(cleanup_kgdboe);
-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Kgdb-bugreport mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/kgdb-bugreport

Reply via email to