ia64/xen-unstable

changeset 1262:5f6a6c6c2100

bitkeeper revision 1.825.3.19 (406af2832chWiChrFa3ASPjsElqg3Q)

pdb documentation
author ach61@labyrinth.cl.cam.ac.uk
date Wed Mar 31 16:32:03 2004 +0000 (2004-03-31)
parents 109663e1ac8d
children 09b8b95eb976
files docs/pdb.txt xen/arch/i386/pdb-stub.c
line diff
     1.1 --- a/docs/pdb.txt	Wed Mar 31 16:15:50 2004 +0000
     1.2 +++ b/docs/pdb.txt	Wed Mar 31 16:32:03 2004 +0000
     1.3 @@ -1,7 +1,7 @@
     1.4  Pervasive Debugging 
     1.5  ===================
     1.6  
     1.7 -040205 Alex Ho (alex.ho at cl.cam.ac.uk)
     1.8 +Alex Ho (alex.ho at cl.cam.ac.uk)
     1.9  
    1.10  Introduction
    1.11  ------------
    1.12 @@ -79,12 +79,32 @@ Serial Port Configuration
    1.13  
    1.14    See:  xeno.bk/tools/nsplitd
    1.15  
    1.16 +  nsplitd configuration
    1.17 +  ---------------------
    1.18 +  hostname$ more /etc/xinetd.d/nsplit
    1.19 +  service nsplit1
    1.20 +  {
    1.21 +        socket_type             = stream
    1.22 +        protocol                = tcp
    1.23 +        wait                    = no
    1.24 +        user                    = wanda
    1.25 +        server                  = /usr/sbin/in.nsplitd
    1.26 +        server_args             = serial.cl.cam.ac.uk:wcons00
    1.27 +        disable                 = no
    1.28 +        only_from               = 128.232.0.0/17 127.0.0.1
    1.29 +  }
    1.30 +
    1.31 +  hostname$ egrep 'wcons00|nsplit1' /etc/services
    1.32 +  wcons00         9600/tcp        # Wanda remote console
    1.33 +  nsplit1         12010/tcp       # Nemesis console splitter ports.
    1.34 +
    1.35    Note: nsplitd was originally written for the Nemesis project
    1.36    at Cambridge.
    1.37  
    1.38 -  After nsplitd accepts a connection on <port>, it starts listening
    1.39 -  on port <port + 1>.  Characters sent to the <port + 1> will have the
    1.40 -  high bit set and vice versa for characters received.
    1.41 +  After nsplitd accepts a connection on <port> (12010 in the above
    1.42 +  example), it starts listening on port <port + 1>.  Characters sent 
    1.43 +  to the <port + 1> will have the high bit set and vice versa for 
    1.44 +  characters received.
    1.45  
    1.46    You can connect to the nsplitd using
    1.47    'tools/xenctl/lib/console_client.py <host> <port>'
    1.48 @@ -100,8 +120,9 @@ Usage
    1.49  1. Boot Xen and Linux
    1.50  2. Interrupt Xen by pressing 'D' at the console
    1.51     You should see the console message: 
    1.52 -   pdb_handle_exception [0x88][0xfc5c9d88]
    1.53 -   At this point Xen is waiting for gdb commands on the serial line.
    1.54 +   (XEN) pdb_handle_exception [0x88][0x101000:0xfc5e72ac]
    1.55 +   At this point Xen is frozen and the pdb stub is waiting for gdb commands 
    1.56 +   on the serial line.
    1.57  3. Attach with gdb
    1.58     (gdb) file xeno.bk/xen/xen
    1.59     Reading symbols from xeno.bk/xen/xen...done.
    1.60 @@ -146,60 +167,107 @@ 4. You can add additional symbols to gdb
    1.61     Program received signal SIGTRAP, Trace/breakpoint trap.
    1.62     release_task (p=0xc2da0000) at exit.c:51
    1.63     (gdb) print *p
    1.64 -$3 = {state = 4, flags = 4, sigpending = 0, addr_limit = {seg = 3221225472}, 
    1.65 -  exec_domain = 0xc016a040, need_resched = 0, ptrace = 0, lock_depth = -1, 
    1.66 -  counter = 1, nice = 0, policy = 0, mm = 0x0, processor = 0, 
    1.67 -  cpus_runnable = 1, cpus_allowed = 4294967295, run_list = {next = 0x0, 
    1.68 -    prev = 0x0}, sleep_time = 18995, next_task = 0xc017c000, 
    1.69 -  prev_task = 0xc2f94000, active_mm = 0x0, local_pages = {next = 0xc2da0054, 
    1.70 -    prev = 0xc2da0054}, allocation_order = 0, nr_local_pages = 0, 
    1.71 -  binfmt = 0xc016c6a0, exit_code = 0, exit_signal = 17, pdeath_signal = 0, 
    1.72 -  personality = 0, did_exec = -1, task_dumpable = 1, pid = 917, pgrp = 914, 
    1.73 -  tty_old_pgrp = 0, session = 914, tgid = 917, leader = 0, 
    1.74 -  p_opptr = 0xc2f94000, p_pptr = 0xc2f94000, p_cptr = 0x0, p_ysptr = 0x0, 
    1.75 -  p_osptr = 0x0, thread_group = {next = 0xc2da00a8, prev = 0xc2da00a8}, 
    1.76 -  pidhash_next = 0x0, pidhash_pprev = 0xc01900b8, wait_chldexit = {
    1.77 -    lock = <incomplete type>, task_list = {next = 0xc2da00b8, 
    1.78 -      prev = 0xc2da00b8}}, vfork_done = 0x0, rt_priority = 0, 
    1.79 -  it_real_value = 0, it_prof_value = 0, it_virt_value = 0, it_real_incr = 0, 
    1.80 -  it_prof_incr = 0, it_virt_incr = 0, real_timer = {list = {next = 0x0, 
    1.81 -      prev = 0x0}, expires = 18950, data = 3269066752, 
    1.82 -    function = 0xc000ce30 <it_real_fn>}, times = {tms_utime = 0, 
    1.83 -    tms_stime = 0, tms_cutime = 0, tms_cstime = 0}, start_time = 18989, 
    1.84 -  per_cpu_utime = {1}, per_cpu_stime = {310}, min_flt = 13, maj_flt = 104, 
    1.85 -  nswap = 0, cmin_flt = 0, cmaj_flt = 0, cnswap = 0, swappable = -1, uid = 0, 
    1.86 -  euid = 0, suid = 0, fsuid = 0, gid = 0, egid = 0, sgid = 0, fsgid = 0, 
    1.87 -  ngroups = 7, groups = {0, 1, 2, 3, 4, 6, 10, 0 <repeats 25 times>}, 
    1.88 -  cap_effective = 4294967039, cap_inheritable = 0, cap_permitted = 4294967039, 
    1.89 -  keep_capabilities = 0, user = 0xc016b18c, rlim = {{rlim_cur = 4294967295, 
    1.90 -      rlim_max = 4294967295}, {rlim_cur = 4294967295, rlim_max = 4294967295}, {
    1.91 -      rlim_cur = 4294967295, rlim_max = 4294967295}, {rlim_cur = 8388608, 
    1.92 -      rlim_max = 4294967295}, {rlim_cur = 0, rlim_max = 4294967295}, {
    1.93 -      rlim_cur = 4294967295, rlim_max = 4294967295}, {rlim_cur = 512, 
    1.94 -      rlim_max = 512}, {rlim_cur = 1024, rlim_max = 1024}, {
    1.95 -      rlim_cur = 4294967295, rlim_max = 4294967295}, {rlim_cur = 4294967295, 
    1.96 -      rlim_max = 4294967295}, {rlim_cur = 4294967295, rlim_max = 4294967295}}, 
    1.97 -  used_math = 0, comm = "id\000h\000og\000\000\000\000\000\000\000\000", 
    1.98 -  link_count = 0, total_link_count = 1, tty = 0xc3ed1000, locks = 0, 
    1.99 -  semundo = 0x0, semsleeping = 0x0, thread = {esp0 = 3269074944, 
   1.100 -    eip = 3221249046, esp = 3269074792, fs = 0, gs = 0, io_pl = 3, debugreg = {
   1.101 -      0, 0, 0, 0, 0, 0, 0, 0}, cr2 = 0, trap_no = 0, error_code = 0, i387 = {
   1.102 -      fsave = {cwd = 2098047, swd = 125632512, twd = 1073944696, fip = 2091, 
   1.103 -        fcs = -1073745032, foo = 2099, fos = 8064, st_space = {
   1.104 -          0 <repeats 20 times>}, status = 0}, fxsave = {cwd = 895, swd = 32, 
   1.105 -        twd = 0, fop = 1917, fip = 1073944696, fcs = 2091, foo = -1073745032, 
   1.106 -        fos = 2099, mxcsr = 8064, reserved = 0, st_space = {
   1.107 -          0 <repeats 24 times>, 1449431204, -1774489361, 16383, 0, 1, 
   1.108 -          -1891252224, 16404, 0}, xmm_space = {0 <repeats 32 times>}, 
   1.109 -        padding = {0 <repeats 56 times>}}, soft = {cwd = 2098047, 
   1.110 -        swd = 125632512, twd = 1073944696, fip = 2091, fcs = -1073745032, 
   1.111 -        foo = 2099, fos = 8064, st_space = {0 <repeats 20 times>}, 
   1.112 -        ftop = 0 '\0', changed = 0 '\0', lookahead = 0 '\0', 
   1.113 -        no_update = 0 '\0', rm = 0 '\0', alimit = 0 '\0', info = 0x0, 
   1.114 -        entry_eip = 0}}, vm86_info = 0x0, screen_bitmap = 0, v86flags = 0, 
   1.115 -    v86mask = 0, saved_esp0 = 0}, fs = 0x0, files = 0x0, namespace = 0x0, 
   1.116 -  sigmask_lock = <incomplete type>, sig = 0x0, blocked = {sig = {0, 0}}, 
   1.117 -  pending = {head = 0x0, tail = 0xc2da04f8, signal = {sig = {0, 0}}}, 
   1.118 -  sas_ss_sp = 0, sas_ss_size = 0, notifier = 0, notifier_data = 0x0, 
   1.119 -  notifier_mask = 0x0, parent_exec_id = 7, self_exec_id = 8, 
   1.120 -  alloc_lock = <incomplete type>, journal_info = 0x0}
   1.121 +   $3 = {state = 4, flags = 4, sigpending = 0, addr_limit = {seg = 3221225472},
   1.122 +     exec_domain = 0xc016a040, need_resched = 0, ptrace = 0, lock_depth = -1, 
   1.123 +     counter = 1, nice = 0, policy = 0, mm = 0x0, processor = 0, 
   1.124 +     cpus_runnable = 1, cpus_allowed = 4294967295, run_list = {next = 0x0, 
   1.125 +       prev = 0x0}, sleep_time = 18995, next_task = 0xc017c000, 
   1.126 +     prev_task = 0xc2f94000, active_mm = 0x0, local_pages = {next = 0xc2da0054,
   1.127 +       prev = 0xc2da0054}, allocation_order = 0, nr_local_pages = 0, 
   1.128 +     ...
   1.129 +5. To resume Xen, enter the "continue" command to gdb.
   1.130 +   This sends the packet $c#63 along the serial channel.
   1.131 +
   1.132 +   (gdb) cont
   1.133 +   Continuing.
   1.134 +
   1.135 +Debugging Multiple Domains & Processes
   1.136 +--------------------------------------
   1.137 +
   1.138 +pdb supports debugging multiple domains & processes.  You can switch
   1.139 +between different domains and processes within domains and examine
   1.140 +variables in each.
   1.141 +
   1.142 +The pdb context identifies the current debug target.  It is stored
   1.143 +in the xen variable pdb_ctx and defaults to xen.
   1.144 +
   1.145 +   target    pdb_ctx.domain    pdb_ctx.process
   1.146 +   ------    --------------    ---------------
   1.147 +    xen           -1                 -1
   1.148 +  guest os      0,1,2,...            -1
   1.149 +   process      0,1,2,...          0,1,2,...
   1.150 +
   1.151 +Unfortunately, gdb doesn't understand debugging multiple process
   1.152 +simultaneously (we're working on it), so at present you are limited 
   1.153 +to just one set of symbols for symbolic debugging.  When debugging
   1.154 +processes, pdb currently supports just Linux 2.4.
   1.155 +
   1.156 +   define setup
   1.157 +      file xeno-clone/xeno.bk/xen/xen
   1.158 +      add-sym xeno-clone/xenolinux-2.4.25/vmlinux
   1.159 +      add-sym ~ach61/a.out
   1.160 +   end
   1.161 +
   1.162 +
   1.163 +1. Connect with gdb as before.  A couple of Linux-specific 
   1.164 +   symbols need to be defined.
   1.165 +
   1.166 +   (gdb) target remote <hostname>:<port + 1>              /* contact nsplitd */
   1.167 +   Remote debugging using serial.srg:12131
   1.168 +   continue_cpu_idle_loop () at current.h:10
   1.169 +   warning: shared library handler failed to enable breakpoint
   1.170 +   (gdb) set pdb_pidhash_addr = &pidhash
   1.171 +   (gdb) set pdb_init_task_union_addr = &init_task_union
   1.172 +
   1.173 +2. The pdb context defaults to Xen and we can read Xen's memory.
   1.174 +   An attempt to access domain 0 memory fails.
   1.175 +  
   1.176 +   (gdb) print pdb_ctx
   1.177 +   $1 = {valid = 0, domain = -1, process = -1, ptbr = 1052672}
   1.178 +   (gdb) print hexchars
   1.179 +   $2 = "0123456789abcdef"
   1.180 +   (gdb) print cpu_vendor_names
   1.181 +   Cannot access memory at address 0xc0191f80
   1.182 +
   1.183 +3. Now we change to domain 0.  In addition to changing pdb_ctx.domain,
   1.184 +   we need to change pdb_ctx.valid to signal pdb of the change.
   1.185 +   It is now possible to examine Xen and Linux memory.
   1.186 +
   1.187 +   (gdb) set pdb_ctx.domain=0
   1.188 +   (gdb) set pdb_ctx.valid=1
   1.189 +   (gdb) print hexchars
   1.190 +   $3 = "0123456789abcdef"
   1.191 +   (gdb) print cpu_vendor_names
   1.192 +   $4 = {0xc0158b46 "Intel", 0xc0158c37 "Cyrix", 0xc0158b55 "AMD", 
   1.193 +     0xc0158c3d "UMC", 0xc0158c41 "NexGen", 0xc0158c48 "Centaur", 
   1.194 +     0xc0158c50 "Rise", 0xc0158c55 "Transmeta"}
   1.195 +
   1.196 +4. Now change to a process within domain 0.  Again, we need to
   1.197 +   change pdb_ctx.valid in addition to pdb_ctx.process.
   1.198 +
   1.199 +   (gdb) set pdb_ctx.process=962
   1.200 +   (gdb) set pdb_ctx.valid =1
   1.201 +   (gdb) print pdb_ctx
   1.202 +   $1 = {valid = 0, domain = 0, process = 962, ptbr = 52998144}
   1.203 +   (gdb) print aho_a
   1.204 +   $2 = 20
   1.205 +
   1.206 +5. Now we can read the same variable from another process running
   1.207 +   the same executable in another domain.
   1.208 +
   1.209 +   (gdb) set pdb_ctx.domain=1
   1.210 +   (gdb) set pdb_ctx.process=1210
   1.211 +   (gdb) set pdb_ctx.valid=1
   1.212 +   (gdb) print pdb_ctx
   1.213 +   $3 = {valid = 0, domain = 1, process = 1210, ptbr = 70574080}
   1.214 +   (gdb) print aho_a
   1.215 +   $4 = 27
   1.216 +
   1.217 +
   1.218 +
   1.219 +
   1.220 +Changes
   1.221 +-------
   1.222 +
   1.223 +04.02.05 aho creation
   1.224 +04.03.31 aho add description on debugging multiple domains
     2.1 --- a/xen/arch/i386/pdb-stub.c	Wed Mar 31 16:15:50 2004 +0000
     2.2 +++ b/xen/arch/i386/pdb-stub.c	Wed Mar 31 16:32:03 2004 +0000
     2.3 @@ -7,7 +7,7 @@
     2.4   * 2004
     2.5   * university of cambridge computer laboratory
     2.6   *
     2.7 - * code adapted originally from kgdb & nemesis
     2.8 + * code adapted originally from kgdb, nemesis, & gdbserver
     2.9   */
    2.10  
    2.11  #include <xen/lib.h>
    2.12 @@ -21,8 +21,8 @@
    2.13  #include <xen/list.h>
    2.14  #include <xen/serial.h>
    2.15  
    2.16 -#undef DEBUG_TRACE
    2.17 -#ifdef DEBUG_TRACE
    2.18 +#undef PDB_DEBUG_TRACE
    2.19 +#ifdef PDB_DEBUG_TRACE
    2.20  #define TRC(_x) _x
    2.21  #else
    2.22  #define TRC(_x)