Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 20 Apr 2000 09:37:09 -0700
From:      Julian Elischer <julian@elischer.org>
To:        "NandaKumar P.K." <p_k_nandan@yahoo.com>
Cc:        freebsd-hackers@freebsd.org
Subject:   Re: Remote kernel debugging
Message-ID:  <38FF3235.446B9B3D@elischer.org>
References:  <20000420084459.11675.qmail@web1901.mail.yahoo.com>

next in thread | previous in thread | raw e-mail | index | archive | help
What you should be doing depends on
what kernel you are using.. I presume 4.0 or 5.0 as you use 0x80
as the flag for sio0.
Here's what I do:

Some of this, you have done, but I repeat the instructins for others
to find in the archives :-)

Don't forget there are two debuggers,
DDB, which has a human readable interface and ALWAYS COMES OUT
ON THE CONSOLE DEVICE, and the gdb robot.
In this case you wish to use the gdb robot, but boot -d puts you 
straight into the DDB. If you wish to switch to gdb,
the easiest thing to do in DDB is
'gdb' 
this switches the mode of the next kernel break,
and then 
's' 
single step 1 instruction.. which will do that break.
the dgb robot is now in charge. It will be talking out COM1
at 9600 baud. It will wait in this state indefinitly for
gdb to come along, so do this first. Gdb on the  other hand
will time out if it doesn't find a robot to talk to withing 
about 30 seconds.

Now you need to run gdb IN THE BUILD DIRECTORY
of the /sys tree on the 2nd machine, where you should have the
following .gdbinit file:

file kernel.debug
set remotebaud 9600
target remote  /dev/cuaa0

gdb should start up and detect the messages from the 
robot. Both kernel.debug, and kernel (the stripped version)
should be present in this directory.
You don't need to copy kernel.debug to the remote machine,
just copy 'kernel' as it's already been stripped.


NandaKumar P.K. wrote:
> 
> Hi,
> 
> We were trying to debug the SCSI CAM driver using
> remote gdb, but we were not able to establish the
> connection between the target machine and host
> machine.
> 
> The host and the target machine were connected using a
> null modem cable which was tested using Pcplus utility
> in DOS. In both the machines the cable is connected to
> the COM1 port.
> 
> The steps which we followed were as follows.
> In the host machine
> 1. Made a copy of the GENERIC kernel called MYKERNEL.
> 2. The follwing additions were made to MYKERNEL
>   options DDB
>   device sio0 at isa? port "IO_COM1" flags 0x080

In fact options 0xc0 may be better.

> 3. Compiled using config -g and installed MYKERNEL .

No don't install it on the host.. just on the target.

> 4. Made a copy of the kernel , kernel.debug

not needed

> 5. Copied the kernel.debug to the target machine.
No just copy 'kernel'. Kernel.debug is only needed by the 'gdb'
program to read teh symbols.


> 
> In the target machine
> 1. Strip -x kernel.debug & then reboot.

no, just take 'kernel' from the build directory in the first place..
They are both in the build directory.. kernel is always there
but kernel.bebug is only made when -g is used..

> 2. At the boot prompt ,loaded kernel.debug
No, just boot the simple stripped kernel

> 3. Opened the debugger using boot -d

ok

> 
> In the host machine
> 1. cd /usr/src/sys/compile/MYKERNEL

ok

> 2. gdb -k kernel

no, kernel has nothing to do with it..
either use the .gdbinit file I supplied above
and just type 'gdb', or
just type 'gdb' and type in the following manually
file kernel.debug
set remotebaud 9600
target remote  /dev/cuaa0

> 3. (kgdb) target remote /dev/cuaa0

this is ok but you have specified the wrong file for symbols.

> 
> In the target
> 1.db>gdb
> 2. s

yes.

> 
> Now the following error message was displayed in the
> host
>  Ignoring packet error,continuing..
>  Ignoring packet error,continuing..
>  Ignoring packet error,continuing..
>  Could'nt establish connection to remote target
>  Malformed response to offset query,timeout
> 
> Using the same cable i was able to set the serial
> console on the machine and were able to find the
> printf messages coming on the other machine. I also
> found some characters sent by the host machine when
> the target
> remote /dev/cuaa0 command is given. I had the terminal
> emulation package pcplus on the other machine. But i
> couldn't find any character sent by the target machine
> when 's' is pressed there. So i have a doubt regarding
> my target machine's setting is not O.K. But i am not
> able to find the problem there. Any help will be
> deeply appreciated.

If you are on 3.x you will need to set the serial console
to com1 as well, as the gdb will talk on the serial console.
i.e. 

flags 0x30

> 
> Regards,
> Nandan
> 
> __________________________________________________
> Do You Yahoo!?
> Send online invitations with Yahoo! Invites.
> http://invites.yahoo.com
> 
> To Unsubscribe: send mail to majordomo@FreeBSD.org
> with "unsubscribe freebsd-hackers" in the body of the message

-- 
      __--_|\  Julian Elischer
     /       \ julian@elischer.org
    (   OZ    ) World tour 2000
---> X_.---._/  presently in:  Perth
            v


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-hackers" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?38FF3235.446B9B3D>