Gentoo Archives: gentoo-doc-cvs

From: Shyam Mani <fox2mike@×××××××××××.org>
To: gentoo-doc-cvs@l.g.o
Subject: [gentoo-doc-cvs] cvs commit: debugging-howto.xml
Date: Wed, 13 Jul 2005 18:59:03
Message-Id: 200507131857.j6DIvhMx013945@robin.gentoo.org
1 fox2mike 05/07/13 18:58:31
2
3 Modified: xml/htdocs/doc/en/draft debugging-howto.xml
4 Log:
5 dmesh patch from Chris White aka PUNK ;)
6
7 Revision Changes Path
8 1.2 +120 -5 xml/htdocs/doc/en/draft/debugging-howto.xml
9
10 file : http://www.gentoo.org/cgi-bin/viewcvs.cgi/xml/htdocs/doc/en/draft/debugging-howto.xml?rev=1.2&content-type=text/x-cvsweb-markup&cvsroot=gentoo
11 plain: http://www.gentoo.org/cgi-bin/viewcvs.cgi/xml/htdocs/doc/en/draft/debugging-howto.xml?rev=1.2&content-type=text/plain&cvsroot=gentoo
12 diff : http://www.gentoo.org/cgi-bin/viewcvs.cgi/xml/htdocs/doc/en/draft/debugging-howto.xml.diff?r1=1.1&r2=1.2&cvsroot=gentoo
13
14 Index: debugging-howto.xml
15 ===================================================================
16 RCS file: /var/cvsroot/gentoo/xml/htdocs/doc/en/draft/debugging-howto.xml,v
17 retrieving revision 1.1
18 retrieving revision 1.2
19 diff -u -r1.1 -r1.2
20 --- debugging-howto.xml 13 Jul 2005 05:55:39 -0000 1.1
21 +++ debugging-howto.xml 13 Jul 2005 18:58:31 -0000 1.2
22 @@ -1,6 +1,6 @@
23 <?xml version="1.0" encoding="UTF-8"?>
24 <!DOCTYPE guide SYSTEM "/dtd/guide.dtd">
25 -<!-- $Header: /var/cvsroot/gentoo/xml/htdocs/doc/en/draft/debugging-howto.xml,v 1.1 2005/07/13 05:55:39 fox2mike Exp $ -->
26 +<!-- $Header: /var/cvsroot/gentoo/xml/htdocs/doc/en/draft/debugging-howto.xml,v 1.2 2005/07/13 18:58:31 fox2mike Exp $ -->
27
28 <guide link="/doc/en/debugging-howto.xml">
29 <title>Gentoo Linux Debugging Guide</title>
30 @@ -406,10 +406,125 @@
31 <body>
32
33 <p>
34 -Now we've taken care of finding run time bugs. These bugs prove to be
35 -problematic when you try and run your programs. However, run time errors are
36 -the least of your concerns if your program won't compile at all. Let's take a
37 -look at how to address <c>emerge</c> compile errors.
38 +<c>strace</c> is a great way at seeing what the kernel is doing to with the filesystem.
39 +Another program exists to help users see what the kernel is doing, and help with
40 +kernel debugging. This program is called <c>dmesg</c>
41 +</p>
42 +
43 +</body>
44 +</section>
45 +</chapter>
46 +
47 +<chapter>
48 +<title>Kernel Debugging With dmesg</title>
49 +<section>
50 +<title>dmesg Introduction</title>
51 +<body>
52 +
53 +<p>
54 +<c>dmesg</c> is a system program created with debugging kernel operation. It
55 +basically reads the kernel messages and keeps them in buffer, letting the user
56 +see them later on. Here's an example of what a dmesg output looks like:
57 +</p>
58 +
59 +<pre caption="dmesg sample output">
60 +SIS5513: IDE controller at PCI slot 0000:00:02.5
61 +SIS5513: chipset revision 208
62 +SIS5513: not 100% native mode: will probe irqs later
63 +SIS5513: SiS 961 MuTIOL IDE UDMA100 controller
64 +ide0: BM-DMA at 0x4000-0x4007, BIOS settings: hda:DMA, hdb:DMA
65 +ide1: BM-DMA at 0x4008-0x400f, BIOS settings: hdc:DMA, hdd:DMA
66 +Probing IDE interface ide0...
67 +input: ImPS/2 Generic Wheel Mouse on isa0060/serio1
68 +hda: WDC WD800BB-60CJA0, ATA DISK drive
69 +hdb: CD-RW 52X24, ATAPI CD/DVD-ROM drive
70 +ide0 at 0x1f0-0x1f7,0x3f6 on irq 14
71 +Probing IDE interface ide1...
72 +hdc: SAMSUNG DVD-ROM SD-616T, ATAPI CD/DVD-ROM drive
73 +hdd: Maxtor 92049U6, ATA DISK drive
74 +ide1 at 0x170-0x177,0x376 on irq 15
75 +hda: max request size: 128KiB
76 +hda: 156301488 sectors (80026 MB) w/2048KiB Cache, CHS=65535/16/63,
77 +UDMA(100)
78 +hda: cache flushes not supported
79 +hda: hda1
80 +hdd: max request size: 128KiB
81 +hdd: 39882528 sectors (20419 MB) w/2048KiB Cache, CHS=39566/16/63,
82 +UDMA(66)
83 +hdd: cache flushes not supported
84 +hdd: unknown partition table
85 +hdb: ATAPI 52X CD-ROM CD-R/RW drive, 2048kB Cache, UDMA(33)
86 +Uniform CD-ROM driver Revision: 3.20
87 +hdc: ATAPI 48X DVD-ROM drive, 512kB Cache, UDMA(33)
88 +ide-floppy driver 0.99.newide
89 +libata version 1.11 loaded.
90 +usbmon: debugs is not available
91 +</pre>
92 +
93 +<p>
94 +The dmesg displayed here is my machine's bootup. You can see harddrives and
95 +input devices being initialized. While what you see here seems relatively
96 +harmless, <c>dmesg</c> is also good at showing when things go wrong. Let's take
97 +for example an IPAQ 1945 I have. After a couple of minutes of inactivity, the
98 +device powers off. Now, I have the device connected into the USB port in the
99 +front of my system. Now, I want to copy over some files using libsynCE, so I go
100 +ahead and initiate a connection:
101 +</p>
102 +
103 +<pre caption="IPAQ connection attempt">
104 +# <i>synce-serial-start</i>
105 +/usr/sbin/pppd: In file /etc/ppp/peers/synce-device: unrecognized option
106 +'/dev/tts/USB0'
107 +
108 +synce-serial-start was unable to start the PPP daemon!
109 +</pre>
110 +
111 +<p>
112 +The connection fails, as we see here, and we assume that only the screen is in
113 +powersave mode, and that maybe the connection is faulty. In order to see what
114 +truly happened, we can use <c>dmesg</c>. Now, <c>dmesg</c> tends to give a
115 +rather large ammount of output. One can use the <c>tail</c> command to help
116 +keep the output down:
117 +</p>
118 +
119 +<pre caption="Adjusting the output ammount with tail">
120 +$ <i>dmesg | tail -n 4</i>
121 +usb 1-1.2: PocketPC PDA converter now attached to ttyUSB0
122 +usb 1-1.2: USB disconnect, address 11
123 +PocketPC PDA ttyUSB0: PocketPC PDA converter now disconnected from ttyUSB0
124 +ipaq 1-1.2:1.0: device disconnected
125 +</pre>
126 +
127 +<p>
128 +This gives us the last 4 lines of the dmesg output. Now, this is enough to give
129 +us some information on the situation. It seems that in the first 2 lines, the
130 +pocketpc is recognized as connected. However, in the last 2 lines, it appears
131 +to have been disconnected. With this information we check the pocketpc again,
132 +and find out it is powered off, and now know about the powersave mode. We can
133 +use this information to turn the feature off, or be aware of it next time.
134 +While this is a somewhat simple example, it does go to show how well dmesg can
135 +work. However, in more complex examples (such as kernel bugs), the entire dmesg
136 +output may be required. To obtain that, simple redirect to a log file as such:
137 +</p>
138 +
139 +<pre caption="Saving dmesg output to a log">
140 +$ <i>dmesg > dmesg.log</i>
141 +</pre>
142 +
143 +<p>
144 +You can then attach this to a bug report, or post it online somewhere for
145 +collaborative debugging sessions.
146 +</p>
147 +
148 +</body>
149 +</section>
150 +<section>
151 +<title>Conclusion</title>
152 +<body>
153 +
154 +<p>
155 +Now that we've taken a look at a few ways to debug runtime and kernel errors,
156 +let's take a look at how to handle emerge errors.
157 </p>
158
159 </body>
160
161
162
163 --
164 gentoo-doc-cvs@g.o mailing list