Skip to contentSkip to conversation

Make kgdb get in sync with it's I/O drivers for the breakpoint

KGDB Tom Rini 3 participants 6 messages Apr 5, 2004 – Apr 6, 2004

Subsystems (2)
lore
Share & tools
lore

Tom Rini

author
#0 lore raw

Hello. The following interdiff, vs current kgdb-2 CVS makes kgdb core and I/O drivers get in sync in order to cause a breakpoint. This kills off the init/main.c change, and makes way for doing things much earlier, if other support exists. What would be left, tangentally, is some sort of queue to register with, so we can handle the case of KGDBOE on a pcmcia card. George? Amit? Comments ?

include/linux/debugger.h +0 -11
@@ -30,12 +30,6 @@
 	kgdb_nmihook(cpu, regs);
 }
 
-void kgdb_entry(void);
-static inline void debugger_entry(void)
-{
-	kgdb_entry();
-}
-
 extern int debugger_step;
 extern atomic_t debugger_active;
 
@@ -55,11 +49,6 @@
 	/* Do nothing */
 }
 
-static inline void debugger_entry(void)
-{
-	/* Do nothing */
-}
-
 #define debugger_step 0
 static const atomic_t debugger_active = { 0 };
 
include/linux/kgdb.h +3 -0
@@ -101,6 +94,7 @@
 /* Thread reference */
 typedef unsigned char threadref[8];
 
+/* Interface stuff. */
 struct kgdb_serial {
 	int (*read_char) (void);
 	void (*write_char) (int);
@@ -111,10 +105,12 @@
 extern struct kgdb_serial *kgdb_serial;
 extern struct kgdb_arch arch_kgdb_ops;
 extern int kgdb_initialized;
+extern int kgdb_break_early;
 
 struct uart_port;
 
 extern void kgdb8250_add_port(int i, struct uart_port *serial_req);
+extern int init_kgdboe(void);
 
 int kgdb_hex2long(char **ptr, long *longValue);
 char *kgdb_mem2hex(char *mem, char *buf, int count);
init/main.c +0 -2
@@ -42,7 +42,6 @@
 #include <linux/cpu.h>
 #include <linux/efi.h>
 #include <linux/unistd.h>
-#include <linux/debugger.h>
 
 #include <asm/io.h>
 #include <asm/bugs.h>
@@ -604,7 +603,6 @@
 
 	smp_init();
 	do_basic_setup();
-	debugger_entry();
 
 	prepare_namespace();
 
kernel/kgdb.c +70 -61

196 lines not on this page · raw message

drivers/net/kgdb_eth.c +11 -13
@@ -38,7 +38,7 @@
 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 */
+static int configured;
 
 static void rx_hook(struct netpoll *np, int port, char *msg, int len);
 
@@ -50,9 +50,8 @@
 	.remote_port = 6442,
 	.remote_mac = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff},
 };
-static int configured;
 
-int eth_getDebugChar(void)
+static int eth_getDebugChar(void)
 {
 	int chr;
 
@@ -65,7 +64,7 @@
 	return chr;
 }
 
-void eth_flushDebugChar(void)
+static void eth_flushDebugChar(void)
 {
 	if (out_count && np.dev) {
 		netpoll_send_udp(&np, out_buf, out_count);
@@ -74,7 +73,7 @@
 	}
 }
 
-void eth_putDebugChar(int chr)
+static void eth_putDebugChar(int chr)
 {
 	out_buf[out_count++] = chr;
 	if (out_count == OUT_BUF_SIZE)
@@ -110,18 +109,18 @@
 	}
 }
 
+/* We must be passed configuration options. */
 static int option_setup(char *opt)
 {
 	configured = !netpoll_parse_options(&np, opt);
-	return !configured;
+	return 0;
 }
-
 __setup("kgdboe=", option_setup);
 
 static int hook(void)
 {
-	/* Un-initalized, don't go further. */
-	if (kgdboe != 1)
+	/* We haven't been configured, giveup. */
+	if (!configured)
 		return 1;
 
 	netpoll_set_trap(1);
@@ -138,14 +137,13 @@
 
-static int init_kgdboe(void)
+int init_kgdboe(void)
 {
 	if (!configured || netpoll_setup(&np))
 		return 1;
 
-	kgdb_serial = &kgdbeth_serial;
-	kgdboe = 1;
+	if (!kgdb_serial)
+		kgdb_serial = &kgdbeth_serial;
 	printk(KERN_INFO "kgdb: debugging over ethernet enabled\n");
 
 	return 0;
 }
-
 module_init(init_kgdboe);
drivers/serial/kgdb_8250.c +55 -14

116 lines not on this page · raw message

Signature · 2 lines
Tom Rini
http://gate.crashing.org/~trini/
#1 lore raw
Quoted 4 lines · Tom Rini

Hello. The following interdiff, vs current kgdb-2 CVS makes kgdb core and I/O drivers get in sync in order to cause a breakpoint. This kills off the init/main.c change, and makes way for doing things much earlier, if other support exists.

And it works perfectly for me too (with the pcmcia net card, debug started by sysrq+g).

There are however a couple of cleanups and a compile fix attached.

Quoted 3 lines

What would be left, tangentally, is some sort
of queue to register with, so we can handle the case of KGDBOE on a pcmcia card. George? Amit? Comments ?

Maybe this could be done in a more kgdb-independent way in the netpoll layer. There is already some code there who waits for the carrier on a net card. Maybe this could be extended to also wait for the network card to appear...

Stelian.

serial/kgdb_8250.c renamed from serial/kgdb_8250.c.ORIG +6 -3
@@ -63,6 +63,9 @@
 static atomic_t kgdb8250_buf_in_cnt;
 static int kgdb8250_buf_out_inx;
 
+/* forward decl */
+struct kgdb_serial kgdb8250_serial_driver;
+
 /* Determine serial information. */
 static struct serial_state state = {
 	.magic = SSTATE_MAGIC,
@@ -131,7 +134,7 @@
 /*
  * Wait until the interface can accept a char, then write it.
  */
-void
+static void
 kgdb_put_debug_char(int chr)
 {
 	while (!(serial_inb(kgdb8250_port + (UART_LSR << reg_shift)) &
@@ -170,7 +173,7 @@
  * Empty the receive buffer first, then look at the interface hardware.
  */
 
-int
+static int
 kgdb_get_debug_char(void)
 {
 	int retchr;
@@ -393,7 +396,7 @@
 }
 module_init(kgdb8250_hookup_irq);
 
-int
+static int
 kgdb_hook_io(void)
 {
 	/* If we've already been initialized, return. */
Signature · 1 line
Stelian Pop <[email protected]>
author
#2 lore raw
Quoted 9 lines · Stelian Pop
Quoted 4 lines · Tom Rini

Hello. The following interdiff, vs current kgdb-2 CVS makes kgdb core and I/O drivers get in sync in order to cause a breakpoint. This kills off the init/main.c change, and makes way for doing things much earlier, if other support exists.

And it works perfectly for me too (with the pcmcia net card, debug started by sysrq+g).

Great!

Quoted 2 lines

There are however a couple of cleanups and a compile fix attached.

Whoops, thanks.

Quoted 8 lines
Quoted 3 lines

What would be left, tangentally, is some sort
of queue to register with, so we can handle the case of KGDBOE on a pcmcia card. George? Amit? Comments ?

Maybe this could be done in a more kgdb-independent way in the netpoll layer. There is already some code there who waits for the carrier on a net card. Maybe this could be extended to also wait for the network card to appear...

I was thinking about that as well. But what I'm guessing happens now is that netpoll_setup(&np) fails causing us init_kgdboe to fail. If we're going to queue up the signal and wait for an eth0, what would it return to let us known it'll be ready 'someday' ?

Signature · 2 lines
Tom Rini
http://gate.crashing.org/~trini/
#3 lore raw
Quoted 7 lines · Tom Rini
Quoted 4 lines

Maybe this could be done in a more kgdb-independent way in the netpoll layer. There is already some code there who waits for the carrier on a net card. Maybe this could be extended to also wait for the network card to appear...

I was thinking about that as well. But what I'm guessing happens now is that netpoll_setup(&np) fails causing us init_kgdboe to fail.

Yup.

Quoted 3 lines

If we're
going to queue up the signal and wait for an eth0, what would it return to let us known it'll be ready 'someday' ?

What about adding a
void (*netpoll_up)(struct netpoll *)
callback into the netpoll struct ?

Using this, netpoll_setup() would return immediately, doing its job in background, and will signal the caller using the 'netpoll_up' function when the card is ready to go...

Stelian.

Signature · 1 line
Stelian Pop <[email protected]>
#4 lore raw
In reply to Tom Rini
Quoted 6 lines · Tom Rini

Hello. The following interdiff, vs current kgdb-2 CVS makes kgdb core and I/O drivers get in sync in order to cause a breakpoint. This kills off the init/main.c change, and makes way for doing things much earlier, if other support exists. What would be left, tangentally, is some sort of queue to register with, so we can handle the case of KGDBOE on a pcmcia card. George? Amit? Comments ?

Well a simple but dumb way is to poll using the timer list, i.e. set up a timer at the first entry were things "might" work and if the driver is not yet, do a timer to come back in 1 tick, and keep doing it for each tick until it is available. This puts it all on the kgdb side.

The other way is with a call back list which would be managed by common OE code.
This would put most of the code in that area. I tend to like call back lists
that one registers for by passing in a structure which contains a "list_head" member. That way there is no memory allocation on either end. The manager, on a register call, just puts the new structure in its call back list. The struct would have the list_head member and a function member, and the function would be called with the struct address as its only parameter. This allows for an expanded struct if more complex info is needed. ~

Signature · 3 lines
George Anzinger   [email protected]
High-res-timers:  http://sourceforge.net/projects/high-res-timers/
Preemption patch: http://www.kernel.org/pub/linux/kernel/people/rml
author
#5 lore raw
Quoted 13 lines · George Anzinger
Quoted 6 lines · Tom Rini

Hello. The following interdiff, vs current kgdb-2 CVS makes kgdb core and I/O drivers get in sync in order to cause a breakpoint. This kills off the init/main.c change, and makes way for doing things much earlier, if other support exists. What would be left, tangentally, is some sort of queue to register with, so we can handle the case of KGDBOE on a pcmcia card. George? Amit? Comments ?

Well a simple but dumb way is to poll using the timer list, i.e. set up a timer at the first entry were things "might" work and if the driver is not yet, do a timer to come back in 1 tick, and keep doing it for each tick until it is available. This puts it all on the kgdb side.

Quoted 9 lines

The other way is with a call back list which would be managed by common OE code. This would put most of the code in that area. I tend to like call
back lists that one registers for by passing in a structure which contains
a "list_head" member. That way there is no memory allocation on either end. The manager, on a register call, just puts the new structure in its call back list. The struct would have the list_head member and a function member, and the function would be called with the struct address as its only parameter. This allows for an expanded struct if more complex info is needed.

Setting aside this problem for a minute (since what I posted does get the job done, just not 100% clean), what do you think about the rest of the changes?

Signature · 2 lines
Tom Rini
http://gate.crashing.org/~trini/