This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
Home Products Support Community News


Re: [Xen-devel] how to debug xen?

" How to debug xen? just use the nsplitd as XenDebugger-HOWTO said? It seems
" quite tricky. I believe lots of people are doing development on xen, so
" usually how to debug it?

This is how I debug xen.  The starting point is reading
I do not use nsplitd.

First, build debug kernels.
For xen, in the xeno-unstable.bk/xen directory add this to arch/x86/Rules.mk
        CFLAGS += -g
    and build xen saying
        make debugger=y
For xenolinux,  in xeno-unstable.bk/linux-2.4.26-xen0
    turn on CONFIG_FRAME_POINTER (in the Kernel Hacking section of
        menuconfig or xconfig)
    in Makefile put -g into CFLAGS_KERNEL (line 52)
        CFLAGS_KERNEL = -g
    and build xenolinux with
        make ARCH=xen bzImage

Second, find a target machine with some serial lines.
I prefer virtual machines and use VMware Workstation 4.5 on Linux (4.0 didn't
work, btw).  In the vmware Machine Settings, config both com1 and com2
to be named pipes with "This end is the client" and "The other end is a
virtual machine".   Run two socat jobs in the background
to convert the pipes to ptys:
    socat UNIX-LISTEN:/tmp/com1pipe,unlink-early,fork pty,link=/tmp/com1 &
    socat UNIX-LISTEN:/tmp/com2pipe,unlink-early,fork pty,link=/tmp/com2 &

Third, boot the target machine and connect the debugger.
Put the debug xen and xenolinux on the machine.  In the grub menu.lst
file, add the serial lines and pdb to the xen command line:
   kernel /boot/xen.gz.debug dom0_mem=100000 ifname=eth0 com1=9600,8n1 
com2=9600,8n1 pdb=com2
Boot it up and connect to the console.  In my vmware setup, I connect
to com1 from the machine hosting VMware with
    kermit -c -l /tmp/com1
Then on com1 type ^A^A^A to make xen listen to console cmds.
At this point type 'h' and see if the 'D' command is listed.  If not,
pdb is missing so make sure the xen being run was built with debugger=y.
Hit 'D' on the console to make xen drop into the debugger.

>From the machine listening to the serial lines, connect to the target machine
with gdb and the xen-syms file and check if was built with -g by trying to
list a function:
    $ gdb xeno-unstable.bk/xen/xen-syms
    (gdb) list do_dom0_op 
    26      extern unsigned int alloc_new_dom_mem(struct domain *,
    unsigned int);
    27      extern long arch_do_dom0_op(dom0_op_t *op, dom0_op_t
    28      extern void arch_getdomaininfo_ctxt(struct domain *,
    full_execution_context_t *);
    30      long do_dom0_op(dom0_op_t *u_dom0_op)
    31      {
    32          long ret = 0;
    33          dom0_op_t curop, *op = &curop;
    35          if ( !IS_PRIV(current) )
    (gdb) target remote /tmp/com2
Now you can debug xen itself.  Note that the breakpoint is in xenolinux
so gdb will be cryptic about the current function and stacktrace.  Put a
breakpoint in xen somewhere and continue to get gdb to a function is can

To debug xenolinux, drop to the debugger:
   (gdb) set pdb_ctx.domain=0
   (gdb) set pdb_ctx.valid=1
   (gdb) add-symbol-file xeno-unstable.bk/linux-2.4.26-xen0/vmlinux
Now you can debug vmlinux itself (except where the xen and linux
symbols clash).

This SF.Net email is sponsored by BEA Weblogic Workshop
FREE Java Enterprise J2EE developer tools!
Get your free copy of BEA WebLogic Workshop 8.1 today.
Xen-devel mailing list