ia64/xen-unstable

view docs/pdb.txt @ 1191:2d19a1a32eea

bitkeeper revision 1.805 (405855d4miA78lKONuhS5MJEPyuuhQ)

console_client.py:
Fix Python console module for direct use.
author kaf24@scramble.cl.cam.ac.uk
date Wed Mar 17 13:42:44 2004 +0000 (2004-03-17)
parents 53b906cc1cba
children 0c707d7680c9
line source
1 Pervasive Debugging
2 ===================
4 040205 Alex Ho (alex.ho at cl.cam.ac.uk)
6 Introduction
7 ------------
9 The pervasive debugging project is leveraging Xen to
10 debug distributed systems. We have added a gdb stub
11 to Xen to allow for remote debugging of both Xen and
12 guest operating systems. More information about the
13 pervasive debugger is available at: http://www.cl.cam.ac.uk/netos/pdb
16 Implementation
17 --------------
19 The gdb stub communicates with gdb running over a serial line.
20 The main entry point is pdb_handle_exception() which is invoked
21 from: pdb_key_pressed() ('D' on the console)
22 do_int3_exception() (interrupt 3: breakpoint exception)
23 do_debug() (interrupt 1: debug exception)
25 This accepts characters from the serial port and passes gdb
26 commands to pdb_process_command() which implements the gdb stub
27 interface. This file draws heavily from the kgdb project and
28 sample gdbstub provided with gdb.
30 The stub can examine registers, single step and continue, and
31 read and write memory (in Xen, a domain, or a Linux process'
32 address space). The debugger does not currently trace the
33 current process, so all bets are off if context switch occurs
34 in the domain.
37 Setup
38 -----
40 +-------+ telnet +-----------+ serial +-------+
41 | GDB |--------| nsplitd |--------| Xen |
42 +-------+ +-----------+ +-------+
44 To run pdb, Xen must be appropriately configured and
45 a suitable serial interface attached to the target machine.
46 GDB and nsplitd can run on the same machine.
48 Xen Configuration
50 Add the "pdb=xxx" option to your Xen boot command line
51 where xxx is one of the following values:
52 com1 gdb stub should communicate on com1
53 com1H gdb stub should communicate on com1 (with high bit set)
54 com2 gdb stub should communicate on com2
55 com2H gdb stub should communicate on com2 (with high bit set)
57 Symbolic debugging infomration is quite helpful too:
58 xeno.bk/xen/arch/i386/Rules.mk
59 add -g to CFLAGS to compile Xen with symbols
60 xeno.bk/xenolinux-2.4.24-sparse/arch/xeno/Makefile
61 add -g to CFLAGS to compile XenoLinux with symbols
63 You may also want to consider dedicating a register to the
64 frame pointer (disable the -fomit-frame-pointer compile flag).
66 When booting Xen and domain 0, look for the console text
67 "Initializing pervasive debugger (PDB)" just before DOM0 starts up.
69 Serial Port Configuration
71 pdb expects to communicate with gdb using the serial port. Since
72 this port is often shared with the machine's console output, pdb can
73 discriminate its communication by setting the high bit of each char.
75 A new tool has been added to the source tree which splits
76 the serial output from a remote machine into two streams:
77 one stream (without the high bit) is the console and
78 one stream (with the high bit stripped) is the pdb communication.
80 See: xeno.bk/tools/nsplitd
82 Note: nsplitd was originally written for the Nemesis project
83 at Cambridge.
85 Usage:
86 %telnet <hostname> <port>
87 This is the console of the remote machine. You will probably
88 want to set telnet in char mode (or create a .telnetrc file).
89 <hostname> and <port> are for your instance of nsplitd.
90 You should be able to press 'h' to display a list of keyboard
91 handlers. In particular, you should see:
92 key 'D' (ascii '44') => enter pervasive debugger
94 After nsplitd accepts a connection on <port>, it starts listening
95 on port <port + 1>. Characters sent to the <port + 1> will have the
96 high bit set and vice versa for characters received.
98 Note: if you are not using a serial console and can dedicate your
99 serial line to pdb messages, then edit pdb_put_char and pdb_get_char
100 in pdb-stub.c to remove the high bit tests.
102 GDB 6.0
103 pdb has been tested with gdb 6.0. It should also work with
104 earlier versions.
107 Usage
108 -----
110 1. Boot Xen and XenoLinux
111 2. Interrupt Xen by pressing 'D' at the console
112 You should see the console message:
113 pdb_handle_exception [0x88][0xfc5c9d88]
114 At this point Xen is waiting for gdb commands on the serial line.
115 3. Attach with gdb
116 (gdb) file xeno.bk/xen/xen
117 Reading symbols from xeno.bk/xen/xen...done.
118 (gdb) target remote <hostname>:<port + 1> /* contact nsplitd */
119 Remote debugging using serial.srg:12131
120 continue_cpu_idle_loop () at current.h:10
121 warning: shared library handler failed to enable breakpoint
122 (gdb) break __enter_scheduler
123 Breakpoint 1 at 0xfc510a94: file schedule.c, line 330.
124 (gdb) cont
125 Continuing.
127 Program received signal SIGTRAP, Trace/breakpoint trap.
128 __enter_scheduler () at schedule.c:330
129 (gdb) step
130 (gdb) step
131 (gdb) print next /* the variable prev has been optimized away! */
132 $1 = (struct task_struct *) 0x0
133 (gdb) delete
134 Delete all breakpoints? (y or n) y
135 4. You can add additional symbols to gdb
136 (gdb) add-sym xenolinux-2.4.24/vmlinux
137 add symbol table from file "xenolinux-2.4.24/vmlinux" at
138 (y or n) y
139 Reading symbols from xenolinux-2.4.24/vmlinux...done.
140 (gdb) x/s cpu_vendor_names[0]
141 0xc01530d2 <cpdext+62898>: "Intel"
142 (gdb) break free_uid
143 Breakpoint 2 at 0xc0012250
144 (gdb) cont
145 Continuing. /* run a command in domain 0 */
147 Program received signal SIGTRAP, Trace/breakpoint trap.
148 free_uid (up=0xbffff738) at user.c:77
150 (gdb) print *up
151 $2 = {__count = {counter = 0}, processes = {counter = 135190120}, files = {
152 counter = 0}, next = 0x395, pprev = 0xbffff878, uid = 134701041}
153 (gdb) finish
154 Run till exit from #0 free_uid (up=0xbffff738) at user.c:77
156 Program received signal SIGTRAP, Trace/breakpoint trap.
157 release_task (p=0xc2da0000) at exit.c:51
158 (gdb) print *p
159 $3 = {state = 4, flags = 4, sigpending = 0, addr_limit = {seg = 3221225472},
160 exec_domain = 0xc016a040, need_resched = 0, ptrace = 0, lock_depth = -1,
161 counter = 1, nice = 0, policy = 0, mm = 0x0, processor = 0,
162 cpus_runnable = 1, cpus_allowed = 4294967295, run_list = {next = 0x0,
163 prev = 0x0}, sleep_time = 18995, next_task = 0xc017c000,
164 prev_task = 0xc2f94000, active_mm = 0x0, local_pages = {next = 0xc2da0054,
165 prev = 0xc2da0054}, allocation_order = 0, nr_local_pages = 0,
166 binfmt = 0xc016c6a0, exit_code = 0, exit_signal = 17, pdeath_signal = 0,
167 personality = 0, did_exec = -1, task_dumpable = 1, pid = 917, pgrp = 914,
168 tty_old_pgrp = 0, session = 914, tgid = 917, leader = 0,
169 p_opptr = 0xc2f94000, p_pptr = 0xc2f94000, p_cptr = 0x0, p_ysptr = 0x0,
170 p_osptr = 0x0, thread_group = {next = 0xc2da00a8, prev = 0xc2da00a8},
171 pidhash_next = 0x0, pidhash_pprev = 0xc01900b8, wait_chldexit = {
172 lock = <incomplete type>, task_list = {next = 0xc2da00b8,
173 prev = 0xc2da00b8}}, vfork_done = 0x0, rt_priority = 0,
174 it_real_value = 0, it_prof_value = 0, it_virt_value = 0, it_real_incr = 0,
175 it_prof_incr = 0, it_virt_incr = 0, real_timer = {list = {next = 0x0,
176 prev = 0x0}, expires = 18950, data = 3269066752,
177 function = 0xc000ce30 <it_real_fn>}, times = {tms_utime = 0,
178 tms_stime = 0, tms_cutime = 0, tms_cstime = 0}, start_time = 18989,
179 per_cpu_utime = {1}, per_cpu_stime = {310}, min_flt = 13, maj_flt = 104,
180 nswap = 0, cmin_flt = 0, cmaj_flt = 0, cnswap = 0, swappable = -1, uid = 0,
181 euid = 0, suid = 0, fsuid = 0, gid = 0, egid = 0, sgid = 0, fsgid = 0,
182 ngroups = 7, groups = {0, 1, 2, 3, 4, 6, 10, 0 <repeats 25 times>},
183 cap_effective = 4294967039, cap_inheritable = 0, cap_permitted = 4294967039,
184 keep_capabilities = 0, user = 0xc016b18c, rlim = {{rlim_cur = 4294967295,
185 rlim_max = 4294967295}, {rlim_cur = 4294967295, rlim_max = 4294967295}, {
186 rlim_cur = 4294967295, rlim_max = 4294967295}, {rlim_cur = 8388608,
187 rlim_max = 4294967295}, {rlim_cur = 0, rlim_max = 4294967295}, {
188 rlim_cur = 4294967295, rlim_max = 4294967295}, {rlim_cur = 512,
189 rlim_max = 512}, {rlim_cur = 1024, rlim_max = 1024}, {
190 rlim_cur = 4294967295, rlim_max = 4294967295}, {rlim_cur = 4294967295,
191 rlim_max = 4294967295}, {rlim_cur = 4294967295, rlim_max = 4294967295}},
192 used_math = 0, comm = "id\000h\000og\000\000\000\000\000\000\000\000",
193 link_count = 0, total_link_count = 1, tty = 0xc3ed1000, locks = 0,
194 semundo = 0x0, semsleeping = 0x0, thread = {esp0 = 3269074944,
195 eip = 3221249046, esp = 3269074792, fs = 0, gs = 0, io_pl = 3, debugreg = {
196 0, 0, 0, 0, 0, 0, 0, 0}, cr2 = 0, trap_no = 0, error_code = 0, i387 = {
197 fsave = {cwd = 2098047, swd = 125632512, twd = 1073944696, fip = 2091,
198 fcs = -1073745032, foo = 2099, fos = 8064, st_space = {
199 0 <repeats 20 times>}, status = 0}, fxsave = {cwd = 895, swd = 32,
200 twd = 0, fop = 1917, fip = 1073944696, fcs = 2091, foo = -1073745032,
201 fos = 2099, mxcsr = 8064, reserved = 0, st_space = {
202 0 <repeats 24 times>, 1449431204, -1774489361, 16383, 0, 1,
203 -1891252224, 16404, 0}, xmm_space = {0 <repeats 32 times>},
204 padding = {0 <repeats 56 times>}}, soft = {cwd = 2098047,
205 swd = 125632512, twd = 1073944696, fip = 2091, fcs = -1073745032,
206 foo = 2099, fos = 8064, st_space = {0 <repeats 20 times>},
207 ftop = 0 '\0', changed = 0 '\0', lookahead = 0 '\0',
208 no_update = 0 '\0', rm = 0 '\0', alimit = 0 '\0', info = 0x0,
209 entry_eip = 0}}, vm86_info = 0x0, screen_bitmap = 0, v86flags = 0,
210 v86mask = 0, saved_esp0 = 0}, fs = 0x0, files = 0x0, namespace = 0x0,
211 sigmask_lock = <incomplete type>, sig = 0x0, blocked = {sig = {0, 0}},
212 pending = {head = 0x0, tail = 0xc2da04f8, signal = {sig = {0, 0}}},
213 sas_ss_sp = 0, sas_ss_size = 0, notifier = 0, notifier_data = 0x0,
214 notifier_mask = 0x0, parent_exec_id = 7, self_exec_id = 8,
215 alloc_lock = <incomplete type>, journal_info = 0x0}