Re: New kernel newbie column is up

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



hi,

El Wed, Aug 12, 2009 at 04:25:50AM +1000 Microbit_Ubuntu ha dit:

> On Tue, 2009-08-11 at 13:03 -0400, Robert P. J. Day wrote:
> > Kernel and module debugging with gdb:  http://cli.gs/LHaA4a.
> 
> The article is quite interesting, however it seems hard to scratch
> together relevant (should read : not outdated thus wrong) on debugging
> kernel modules on a *remote* target..
> 
> I've been scouring away for yonks here and I don't seem to be getting
> anywhere in a hurry :-(
> I've recompiled my target's kernel with remote KGDB enabled, (sysfs et
> al for possible manual configuration), full debug on the kernel - just
> in case - but trying to pass kernel command argument using kgdbwait
> (preceded with kgdboc=ttyS0,115200 eg. or kgdbcon etc) doesn't seem to
> get the booting to halt and wait for the gdbmod debugger....
> (I've also tried the sysrq-g break and consorts, no avail either).
> 
> I've had a close look at the kernel/kgdb.c source - added some extra
> temp debug messages to try to track code flow and it seems I'm not even
> entering these funcs.
> 
> Is there anyone here that can shed some more light on this black magic
> cursed trick ? I'm using gdbmod-2.4 btw.
> 
> So, basically : I'm continuing trying to find out if there is a way to
> step through kernel module code invoked on a remote (ARM) target by
> insmod/modprobe. (gdbmod 2.4 claims it automatically picks up when
> module is inserted, but at this stage the kernel just happily boots up
> and chugs away, ignoring the wait for remote debugger...?.)
> 
> kgdb's URL has docs (kgdb_docu_full-2.4) but - as per usual - they're
> either just plain wrong (eg. the syntax doesn't comply whatsoever with
> the Documentation -> Docbook kgdb explained syntax) or others don't seem
> to correlate with one another. It seems almost like a 'brute force' test
> of all permutations of these various "solutions" is perhaps soon the
> only way to remain sane.. :-)
> 
> Googling other resources seems to just bring up unanswered posts on
> forums here and there where people seem to be just as confused as I
> am :-)
> 
> In short, if anyone drops around here and has done this before (kernel =
> 2.6.29.4, using built in remote kgdb), I would love to hear from them to
> see if perhaps they've got a suggestion.
> I don't mind doing the hard work to learn it properly - but it's always
> more enjoyable when one is actually working towards something fruitful
> in the end... !

some time ago i had a similar (the same?) problem, trying to debug an
ARM device using kgdb. in my case the problem was that the serial port
driver (AMBA PL010) lacked the poll_get_char() and poll_put_char()
operations, which seem to be necessary for debugging over console.

if you happen to use a device with AMBA PL010 try again after applying
the patch below. otherwise you might want to check if the driver of
your serial port implements the poll functions

diff --git a/drivers/serial/amba-pl010.c b/drivers/serial/amba-pl010.c
index 58a4879..4b27537 100644
--- a/drivers/serial/amba-pl010.c
+++ b/drivers/serial/amba-pl010.c
@@ -308,6 +308,32 @@ static void pl010_break_ctl(struct uart_port *port, int break_state)
 	spin_unlock_irqrestore(&uap->port.lock, flags);
 }
 
+#ifdef CONFIG_CONSOLE_POLL
+static int pl010_get_poll_char(struct uart_port *port)
+{
+	struct uart_amba_port *uap = (struct uart_amba_port *)port;
+	unsigned int status;
+
+	do {
+		status = readb(uap->port.membase + UART01x_FR);
+	} while (!UART_RX_DATA(status))
+
+	return readb(uap->port.membase + UART01x_DR);
+}
+
+static void pl010_put_poll_char(struct uart_port *port,
+				unsigned char ch)
+{
+	struct uart_amba_port *uap = (struct uart_amba_port *)port;
+
+	while (!UART_TX_READY(readb(uap->port.membase + UART01x_FR)))
+		barrier();
+
+	writeb(ch, uap->port.membase + UART01x_DR);
+}
+
+#endif /* CONFIG_CONSOLE_POLL */
+
 static int pl010_startup(struct uart_port *port)
 {
 	struct uart_amba_port *uap = (struct uart_amba_port *)port;
@@ -536,6 +562,10 @@ static struct uart_ops amba_pl010_pops = {
 	.request_port	= pl010_request_port,
 	.config_port	= pl010_config_port,
 	.verify_port	= pl010_verify_port,
+#ifdef CONFIG_CONSOLE_POLL
+	.poll_get_char = pl010_get_poll_char,
+	.poll_put_char = pl010_put_poll_char,
+#endif
 };
 
 static struct uart_amba_port *amba_ports[UART_NR];

-- 
Matthias Kaehlcke
Embedded Linux Engineer
Barcelona

    Tant qu'il y aura sur terre des hommes pour qui existe un concept
    d' 'honneur national', la menace d'une nouvelle guerre subsistera
                              (B. Traven)
                                                                 .''`.
    using free software / Debian GNU/Linux | http://debian.org  : :'  :
                                                                `. `'`
gpg --keyserver pgp.mit.edu --recv-keys 47D8E5D4                  `-

--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecartis@xxxxxxxxxxxx
Please read the FAQ at http://kernelnewbies.org/FAQ


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux