This file is indexed.

/usr/share/doc/user-mode-linux-doc/html/debugging.html is in user-mode-linux-doc 20060501-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"
    "http://www.w3.org/TR/REC-html40/loose.dtd">
<html>
<head>
   <meta content="text/html; charset=iso-8859-1" http-equiv="Content-Type">
<title>Kernel debugging</title>
</head>
<body alink="#FF0000" vlink="#55188A" link="#0000EF" bgcolor="#FFFFFF" text="#000099">
<table border="0">
<tr align="left">
<td valign="top">
<table border="0">

<tr align="left"><td valign="top" >
<img src="uml-small.png" height="171" width="120"/> 
</td></tr>

<tr align="left"><td valign="top" bgcolor="#e0e0e0">
<font size="-1"><a href="index.html">Site Home Page</a></font>
<br>
              <font size="-1"><a href="http://uml.harlowhill.com">The UML Wiki</a></font>
<br>
              <font size="-1"><a href="http://usermodelinux.org">UML Community Site</a></font>
<br>
              <font size="-1"><a href="roadmap.html">The UML roadmap</a></font>
<br>
              <font size="-1"><a href="uses.html">What it's good for</a></font>
<br>
              <font size="-1"><a href="case-studies.html">Case Studies</a></font>
<br>
              <font size="-1"><a href="kernel.html">Kernel Capabilities</a></font>
<br>
              <font size="-1"><a href="http://user-mode-linux.sourceforge.net/dl-sf.html">Downloading it</a></font>
<br>
              <font size="-1"><a href="run.html">Running it</a></font>
<br>
              <font size="-1"><a href="compile.html">Compiling</a></font>
<br>
              <font size="-1"><a href="install.html">Installation</a></font>
<br>
              <font size="-1"><a href="skas.html">Skas Mode</a></font>
<br>
              <font size="-1"><a href="patches.html">Incremental Patches</a></font>
<br>
              <font size="-1"><a href="tests.html">Test Suite</a></font>
<br>
              <font size="-1"><a href="devanon.html">Host memory use</a></font>
<br>
              <font size="-1"><a href="fs_making.html">Building filesystems</a></font>
<br>
              <font size="-1"><a href="faq.html">Troubles</a></font>
<br>
              <font size="-1"><a href="contrib.html">User Contributions</a></font>
<br>
              <font size="-1"><a href="links.html">Related Links</a></font>
<br>
              <font size="-1"><a href="todo.html">The ToDo list</a></font>
<br>
              <font size="-1"><a href="projects.html">Projects</a></font>
<br>
              <font size="-1"><a href="diary.html">Diary</a></font>
<br>
              <font size="-1"><a href="thanks.html">Thanks</a></font>
<br>
              <font size="-1"><a href="contacts.html">Contacts</a></font>
</td></tr>

<tr align="left"><td valign="top" bgcolor="#e0e0e0">Tutorials<br>
<font size="-1"><a href="UserModeLinux-HOWTO.html">The HOWTO (html)</a></font>
<br>
              <font size="-1"><a href="UserModeLinux-HOWTO.txt.gz">The HOWTO (text)</a></font>
<br>
              <font size="-1"><a href="hostfs.html">Host file access</a></font>
<br>
              <font size="-1"><a href="input.html">Device inputs</a></font>
<br>
              <font size="-1"><a href="shared_fs.html">Sharing filesystems</a></font>
<br>
              <font size="-1"><a href="fs.html">Creating filesystems</a></font>
<br>
              <font size="-1"><a href="resize.html">Resizing filesystems</a></font>
<br>
              <font size="-1"><a href="networking.html">Virtual Networking</a></font>
<br>
              <font size="-1"><a href="mconsole.html">Management Console</a></font>
<br>
              <font size="-1"><a href="debugging.html">Kernel Debugging</a></font>
<br>
              <font size="-1"><a href="honeypots.html">UML Honeypots</a></font>
<br>
              <font size="-1"><a href="gprof.html">gprof and gcov</a></font>
<br>
              <font size="-1"><a href="xtut.html">Running X</a></font>
<br>
              <font size="-1"><a href="trouble.html">Diagnosing problems</a></font>
<br>
              <font size="-1"><a href="config.html">Configuration</a></font>
<br>
              <font size="-1"><a href="slack_readme.html">Installing Slackware</a></font>
<br>
              <font size="-1"><a href="arch-port.html">Porting UML</a></font>
<br>
              <font size="-1"><a href="iomem.html">IO memory emulation</a></font>
<br>
              <font size="-1"><a href="2G-2G.html">UML on 2G/2G hosts</a></font>
<br>
              <font size="-1"><a href="http://user-mode-linux.sourceforge.net/lksct/index.html">Adding a UML system call</a></font>
<br>
              <font size="-1"><a href="nesting.html">Running nested UMLs</a></font>
</td></tr>

<tr align="left"><td valign="top" bgcolor="#e0e0e0">How you can help<br>
<font size="-1"><a href="help-gen.html">Overview</a></font>
<br>
              <font size="-1"><a href="help-doc.html">Documentation</a></font>
<br>
              <font size="-1"><a href="help-userspace.html">Utilities</a></font>
<br>
              <font size="-1"><a href="help-kernel-v1.html">Kernel bugs</a></font>
<br>
              <font size="-1"><a href="projects.html">Kernel projects</a></font>
</td></tr>

<tr align="left"><td valign="top" bgcolor="#e0e0e0">Screenshots<br>
<font size="-1"><a href="net.html">A virtual network</a></font>
<br>
              <font size="-1"><a href="x.html">An X session</a></font>
</td></tr>

<tr align="left"><td valign="top" bgcolor="#e0e0e0">Transcripts<br>
<font size="-1"><a href="login.html">A login session</a></font>
<br>
              <font size="-1"><a href="debug-session.html">A debugging session</a></font>
<br>
              <font size="-1"><a href="slackinst.html">Slackware installation</a></font>
</td></tr>

<tr align="left"><td valign="top" bgcolor="#e0e0e0">Reference<br>
<font size="-1"><a href="switches.html">Kernel switches</a></font>
<br>
              <font size="-1"><a href="slack_readme.html">Slackware README</a></font>
</td></tr>

<tr align="left"><td valign="top" bgcolor="#e0e0e0">Papers<br>
<font size="-1"><a href="http://user-mode-linux.sourceforge.net/als2000/index.html">ALS 2000 paper (html)</a></font>
<br>
              <font size="-1"><a href="http://user-mode-linux.sourceforge.net/als2000.tex">ALS 2000 paper (TeX)</a></font>
<br>
              <font size="-1"><a href="http://user-mode-linux.sourceforge.net/slides/als2000/slides.html">ALS 2000 slides</a></font>
<br>
              <font size="-1"><a href="http://user-mode-linux.sourceforge.net/slides/lca2001/lca.html">LCA 2001 slides</a></font>
<br>
              <font size="-1"><a href="http://user-mode-linux.sourceforge.net/slides/ols2001/index.html">OLS 2001 paper (html)</a></font>
<br>
              <font size="-1"><a href="http://user-mode-linux.sourceforge.net/ols2001.tex">OLS 2001 paper (TeX)</a></font>
<br>
              <font size="-1"><a href="http://user-mode-linux.sourceforge.net/als2001/index.html">ALS 2001 paper (html)</a></font>
<br>
              <font size="-1"><a href="http://user-mode-linux.sourceforge.net/als2001.tex">ALS 2001 paper (TeX)</a></font>
<br>
              <font size="-1"><a href="http://user-mode-linux.sourceforge.net/slides/ists2002/umlsec.htm">UML security (html)</a></font>
<br>
              <font size="-1"><a href="http://user-mode-linux.sourceforge.net/slides/lca2002/lca2002.htm">LCA 2002 (html)</a></font>
<br>
              <font size="-1"><a href="http://user-mode-linux.sourceforge.net/slides/wvu2002/wvu2002.htm">WVU 2002 (html)</a></font>
<br>
              <font size="-1"><a href="http://user-mode-linux.sourceforge.net/slides/ists_rt/ists_rt.htm">Security Roundtable (html)</a></font>
<br>
              <font size="-1"><a href="http://user-mode-linux.sourceforge.net/slides/ols2002/ols2002.html">OLS 2002 slides</a></font>
<br>
              <font size="-1"><a href="http://user-mode-linux.sourceforge.net/slides/lwe2005/LWE2005.html">LWE 2005 slides</a></font>
</td></tr>

<tr align="left"><td valign="top" bgcolor="#e0e0e0">Fun and Games<br>
<font size="-1"><a href="http://user-mode-linux.sourceforge.net/cgi-bin/hangman">Kernel Hangman</a></font>
<br>
              <font size="-1"><a href="sdotm.html">Disaster of the Month</a></font>
</td></tr>

</table>
</td>
<td valign="top" align="left">

<center>
            <h3>Kernel debugging</h3>
          </center>
This page describes kernel debugging with UML running in tt mode (go
<a href="skas.html">here</a> for the details on
skas and tt mode).  Kernel debugging in skas mode is described 
<a href="debugging-skas.html">here</a>.
<p>
Since the UML runs as a normal Linux process, it is
possible to debug it with gdb almost like any other process.  It is
slightly different because the kernel's threads are already being
ptraced for system call interception, so gdb can't ptrace them.
However, a mechanism has been added to work around that problem.
<p>
In order to debug the kernel, you need build it from source.  See 
<a href="compile.html">this page</a> for
information on doing that.  Make sure that you enable CONFIG_DEBUGSYM
and CONFIG_PT_PROXY during the config.  These will compile the kernel
with -g, and enable the ptrace proxy so that gdb works with UML,
respectively.
<p>

<a name="Starting the kernel under gdb"/><table width="100%" bgcolor="#e0e0e0">
            <tr>
              <td>
                <b>
                  <font color="black">Starting the kernel under gdb</font>
                </b>
              </td>
            </tr>
          </table>
          <blockquote head="Starting the kernel under gdb">
You can have the kernel running under the control of gdb from the
beginning by putting 'debug' on the command line.  You will get an
xterm with gdb running inside it.  The kernel will send some commands
to gdb which will leave it stopped at the beginning of start_kernel.
At this point, you can get things going with 'next', 'step', or 'cont'.
<p>
There is a transcript of a debugging session <a href="debug-session.html">here</a>, with breakpoints being set in the
scheduler and in an interrupt handler.
</blockquote>

<a name="Examining sleeping processes"/><table width="100%" bgcolor="#e0e0e0">
            <tr>
              <td>
                <b>
                  <font color="black">Examining sleeping processes</font>
                </b>
              </td>
            </tr>
          </table>
          <blockquote head="Examining sleeping processes">
Not every bug is evident in the currently running process.  Sometimes,
processes hang in the kernel when they shouldn't because they've
deadlocked on a semaphore or something similar.  In this case, when
you ^C gdb and get a backtrace, you will see the idle thread, which
isn't very relevant.
<p>
What you want is the stack of whatever process is sleeping when it
shouldn't be.  You need to figure out which process that is, which is
generally fairly easy.  Then you need to get its host process id,
which you can do either by looking at ps on the host or at
task.thread.extern_pid in gdb.
<p>
Now what you do is this:
<ul>
<li>
detach from the current thread
<blockquote>
                  <tt>
                    <font color="#000000" where="UML gdb">(UML gdb)  det</font>
                  </tt>
                </blockquote>
</li>
<li>
attach to the thread you are interested in
<blockquote>
                  <tt>
                    <font color="#000000" where="UML gdb">(UML gdb)  att &lt;host pid&gt;</font>
                  </tt>
                </blockquote>
</li>
<li>
look at its stack and anything else of interest
<blockquote>
                  <tt>
                    <font color="#000000" where="UML gdb">(UML gdb)  bt</font>
                  </tt>
                </blockquote>
Note that you can't do anything at this point that requires that a
process execute, e.g. calling a function
</li>
<li>
when you're done looking at that process, reattach to the current thread
and continue it
<blockquote>
                  <tt>
                    <font color="#000000" where="UML gdb">(UML gdb)  
att 1
</font>
                  </tt>
                </blockquote>
<blockquote>
                  <tt>
                    <font color="#000000" where="UML gdb">(UML gdb)  
c
</font>
                  </tt>
                </blockquote>
Here, specifying any pid which is not the process id of a UML thread
will cause gdb to reattach to the current thread.  I commonly use 1,
but any other invalid pid would work.
</li>
</ul>
</blockquote>

<a name="Running ddd on UML"/><table width="100%" bgcolor="#e0e0e0">
            <tr>
              <td>
                <b>
                  <font color="black">Running ddd on UML</font>
                </b>
              </td>
            </tr>
          </table>
          <blockquote head="Running ddd on UML">
ddd works on UML, but requires a special kludge.  The process goes
like this:
<ul>
<li>
Start ddd
<blockquote>
                  <tt>
                    <font color="#000000" where="host">host% ddd linux</font>
                  </tt>
                </blockquote>
</li>
<li>
With ps, get the pid of the gdb that ddd started.  You can ask the gdb
to tell you, but for some reason that confuses things and causes a hang.
</li>
<li>
run UML with 'debug=parent gdb-pid=&lt;pid&gt;' added to the command line
- it will just sit there after you hit return
</li>
<li>
type 'att 1' to the ddd gdb and you will see something like
<tt>
                  <pre>
                    <font size="-1">
0xa013dc51 in __kill ()
<br>
(gdb) 
</font>
                  </pre>
                </tt>
</li>
<li>
At this point, type 'c', UML will boot up, and you can use ddd just as
you do on any other process.
</li>
</ul>
</blockquote>

<a name="Debugging modules"/><table width="100%" bgcolor="#e0e0e0">
            <tr>
              <td>
                <b>
                  <font color="black">Debugging modules</font>
                </b>
              </td>
            </tr>
          </table>
          <blockquote head="Debugging modules">
gdb has support for debugging code which is dynamically loaded into
the process.  This support is what is needed to debug kernel modules
under UML.
<br>
Using that support is somewhat complicated.  You have to tell gdb what
object file you just loaded into UML and where in memory it is.  Then,
it can read the symbol table, and figure out where all the symbols are
from the load address that you provided.  It gets more interesting
when you load the module again (i.e. after an rmmod).  You have to
tell gdb to forget about all its symbols, including the main UML ones
for some reason, then load then all back in again.
<br>
There's an easy way and a hard way to do this.  The easy way is to use
the umlgdb expect script written by Chandan Kudige.  It basically
automates the process for you.
<br>
First, you must tell it where your modules are.  There is a list in
the script that looks like this:
<tt>
              <pre>
                <font size="-1">
set MODULE_PATHS {
&quot;fat&quot; &quot;/usr/src/uml/linux-2.4.18/fs/fat/fat.o&quot;
&quot;isofs&quot; &quot;/usr/src/uml/linux-2.4.18/fs/isofs/isofs.o&quot;
&quot;minix&quot; &quot;/usr/src/uml/linux-2.4.18/fs/minix/minix.o&quot;
}
</font>
              </pre>
            </tt>
You change that to list the names and paths of the modules that you
are going to debug.  Then you run it from the toplevel directory of
your UML pool and it basically tells you what to do:

<tt>
              <pre>
                <font size="-1">

            ******** GDB pid is 21903 ********
Start UML as: ./linux &lt;kernel switches&gt; debug gdb-pid=21903



GNU gdb 5.0rh-5 Red Hat Linux 7.1
Copyright 2001 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type &quot;show copying&quot; to see the conditions.
There is absolutely no warranty for GDB.  Type &quot;show warranty&quot; for details.
This GDB was configured as &quot;i386-redhat-linux&quot;...
(gdb) b sys_init_module
Breakpoint 1 at 0xa0011923: file module.c, line 349.
(gdb) att 1
</font>
              </pre>
            </tt>
After you run UML and it sits there doing nothing, you hit return at
the 'att 1' and continue it:
<tt>
              <pre>
                <font size="-1">
Attaching to program: /home/jdike/linux/2.4/um/./linux, process 1
0xa00f4221 in __kill ()
<font color="#000000" where="UML gdb">(UML gdb)  c</font>
Continuing.
</font>
              </pre>
            </tt>
At this point, you debug normally.  When you insmod something, the
expect magic will kick in and you'll see something like:
<tt>
              <pre>
                <font size="-1">
 *** Module hostfs loaded *** 
Breakpoint 1, sys_init_module (name_user=0x805abb0 &quot;hostfs&quot;, 
    mod_user=0x8070e00) at module.c:349
349             char *name, *n_name, *name_tmp = NULL;
<font color="#000000" where="UML gdb">(UML gdb)  finish</font>
Run till exit from #0  sys_init_module (name_user=0x805abb0 &quot;hostfs&quot;, 
    mod_user=0x8070e00) at module.c:349
0xa00e2e23 in execute_syscall (r=0xa8140284) at syscall_kern.c:411
411             else res = EXECUTE_SYSCALL(syscall, regs);
Value returned is $1 = 0
<font color="#000000" where="UML gdb">(UML gdb)  
p/x (int)module_list + module_list-&gt;size_of_struct
</font>
$2 = 0xa9021054
<font color="#000000" where="UML gdb">(UML gdb)  symbol-file ./linux</font>
Load new symbol table from &quot;./linux&quot;? (y or n) y
Reading symbols from ./linux...
done.
<font color="#000000" where="UML gdb">(UML gdb)  
add-symbol-file /home/jdike/linux/2.4/um/arch/um/fs/hostfs/hostfs.o 0xa9021054
</font>
add symbol table from file &quot;/home/jdike/linux/2.4/um/arch/um/fs/hostfs/hostfs.o&quot; at
        .text_addr = 0xa9021054
<font color="#000000"> (y or n) y</font>

Reading symbols from /home/jdike/linux/2.4/um/arch/um/fs/hostfs/hostfs.o...
done.
<font color="#000000" where="UML gdb">(UML gdb)  p *module_list</font>
$1 = {size_of_struct = 84, next = 0xa0178720, name = 0xa9022de0 &quot;hostfs&quot;, 
  size = 9016, uc = {usecount = {counter = 0}, pad = 0}, flags = 1, 
  nsyms = 57, ndeps = 0, syms = 0xa9023170, deps = 0x0, refs = 0x0, 
  init = 0xa90221f0 &lt;init_hostfs&gt;, cleanup = 0xa902222c &lt;exit_hostfs&gt;, 
  ex_table_start = 0x0, ex_table_end = 0x0, persist_start = 0x0, 
  persist_end = 0x0, can_unload = 0, runsize = 0, kallsyms_start = 0x0, 
  kallsyms_end = 0x0, 
  archdata_start = 0x1b855 &lt;Address 0x1b855 out of bounds&gt;, 
  archdata_end = 0xe5890000 &lt;Address 0xe5890000 out of bounds&gt;, 
  kernel_data = 0xf689c35d &lt;Address 0xf689c35d out of bounds&gt;}
&gt;&gt; Finished loading symbols for hostfs ...
</font>
              </pre>
            </tt>
That's the easy way.  It's highly recommended.  The umlgdb script is
available in the <a href="dl-sf#UML utilities">UML
utilities tarball</a> in tools/umlgdb/umlgdb. The 
hard way is described below in case you're interested in what's going
on.
<br>
Boot the kernel under the debugger and load the module with insmod or
modprobe.  With gdb, do:
<blockquote>
              <tt>
                <font color="#000000" where="UML gdb">(UML gdb)  p module_list</font>
              </tt>
            </blockquote>
This is a list of modules that have been loaded into the kernel, with
the most recently loaded module first.  Normally, the module you want
is at module_list.  If it's not, walk down the next links, looking at
the name fields until find the module you want to debug.  Take the
address of that structure, and add module.size_of_struct (which in
2.4.10 kernels is 96 (0x60)) to it.  Gdb can make this hard addition for 
you :-):
<blockquote>
              <tt>
                <font color="#000000" where="UML gdb">(UML gdb)  
printf &quot;%#x\n&quot;, (int)module_list module_list-&gt;size_of_struct
</font>
              </tt>
            </blockquote>
The offset from the module start occasionally changes (before 2.4.0, it
was module.size_of_struct + 4), so it's a good idea to check the init and
cleanup addresses once in a while, as describe below.
Now do:
<blockquote>
              <tt>
                <font color="#000000" where="UML gdb">(UML gdb)  
add-symbol-file /path/to/module/on/host that_address
</font>
              </tt>
            </blockquote>
Tell gdb you really want to do it, and you're in business.
<br>
If there's any doubt that you got the offset right, like breakpoints
appear not to work, or they're appearing in the wrong place, you can
check it by looking at the module structure.  The init and cleanup
fields should look like:
<tt>
              <pre>
                <font size="-1">
init = 0x588066b0 &lt;init_hostfs&gt;, cleanup = 0x588066c0 &lt;exit_hostfs&gt;
</font>
              </pre>
            </tt>
with no offsets on the symbol names.  If the names are right, but they
are offset, then the offset tells you how much you need to add to the
address you gave to add-symbol-file.
<p>
When you want to load in a new version of the module, you need to get
gdb to forget about the old one.  The only way I've found to do that
is to tell gdb to forget about all symbols that it knows about:
<blockquote>
              <tt>
                <font color="#000000" where="UML gdb">(UML gdb)  symbol-file</font>
              </tt>
            </blockquote>
Then reload the symbols from the kernel binary:
<blockquote>
              <tt>
                <font color="#000000" where="UML gdb">(UML gdb)  symbol-file /path/to/kernel</font>
              </tt>
            </blockquote>
and repeat the process above.  You'll also need to re-enable breakpoints.
They were disabled when you dumped all the symbols because gdb
couldn't figure out where they should go.
</blockquote>

<a name="Attaching gdb to the kernel"/><table width="100%" bgcolor="#e0e0e0">
            <tr>
              <td>
                <b>
                  <font color="black">Attaching gdb to the kernel</font>
                </b>
              </td>
            </tr>
          </table>
          <blockquote head="Attaching gdb to the kernel">
If you don't have the kernel running under gdb, you can attach gdb to
it later by sending the tracing thread a SIGUSR1.  The first line of
the console output identifies its pid:
<tt>
              <pre>
                <font size="-1">tracing thread pid = 20093</font>
              </pre>
            </tt>
When you send it the signal:
<blockquote>
              <tt>
                <font color="#000000" where="host">host% kill -USR1 20093</font>
              </tt>
            </blockquote>
you will get an xterm with gdb running in it.
<p>
If you have the mconsole compiled into UML, then the mconsole client
can be used to start gdb:
<blockquote>
              <tt>
                <font color="#000000" where="mconsole">(mconsole)  (mconsole) config gdb=xterm</font>
              </tt>
            </blockquote>
will fire up an xterm with gdb running in it.
</blockquote>

<a name="Using alternate debuggers"/><table width="100%" bgcolor="#e0e0e0">
            <tr>
              <td>
                <b>
                  <font color="black">Using alternate debuggers</font>
                </b>
              </td>
            </tr>
          </table>
          <blockquote head="Using alternate debuggers">
UML has support for attaching to an already running debugger rather than 
starting gdb itself.  This is present in  <a href="http://sourceforge.net/cvs/?group_id=429">CVS</a>  as of 
17 Apr 2001.  I sent it to Alan for inclusion in 
the ac tree, and it will be in my 2.4.4 release.
<p>
This is useful when gdb is a subprocess of some UI, such as emacs or ddd.  It 
can also be used to run debuggers other than gdb on UML.  Below is an example
of using strace as an alternate debugger.
<p>
To do this, you need to get the pid of the debugger and pass it in with the
'gdb-pid=&lt;pid&gt;' switch along with the 'debug' switch.
<p>
If you are using gdb under some UI, then tell it to 'att 1', and you'll find
yourself attached to UML.
<p>
If you are using something other than gdb as your debugger, then you'll need
to get it to do the equivalent of 'att 1' if it doesn't do it automatically.
<p>
An example of an alternate debugger is strace.  You can strace the actual
kernel as follows:
<ul>
<li>
Run the following in a shell
<blockquote>
                  <tt>
                    <font color="#000000" where="host">host% 
sh -c 'echo pid=$$; echo -n hit return; read x; exec strace -p 1 -o strace.out'
</font>
                  </tt>
                </blockquote>
</li>
<li>
Run UML with 'debug' and 'gdb-pid=&lt;pid&gt;' with the pid printed out by the
previous command
</li>
<li>
Hit return in the shell, and UML will start running, and strace output will
start accumulating in the output file.
</li>
</ul>
Note that this is different from running
<blockquote>
              <tt>
                <font color="#000000" where="host">host% strace ./linux</font>
              </tt>
            </blockquote>
That will strace only the main UML thread, the tracing thread, which doesn't
do any of the actual kernel work.  It just oversees the virtual machine.  In
contrast, using strace as described above will show you the low-level activity
of the virtual machine.
</blockquote>

</td>
</tr>
</table>

<center>
<font size="-1">Hosted at </font>
    <a href="http://sourceforge.net">
    <img src="http://sourceforge.net/sflogo.php?group_id=429" width="88" height="31" border="0" alt="SourceForge Logo">
    </a>
</center>
</body>
</html>