/[gentoo]/xml/htdocs/doc/en/draft/debugging-howto.xml
Gentoo

Diff of /xml/htdocs/doc/en/draft/debugging-howto.xml

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 1.1 Revision 1.2
1<?xml version="1.0" encoding="UTF-8"?> 1<?xml version="1.0" encoding="UTF-8"?>
2<!DOCTYPE guide SYSTEM "/dtd/guide.dtd"> 2<!DOCTYPE guide SYSTEM "/dtd/guide.dtd">
3<!-- $Header: /var/cvsroot/gentoo/xml/htdocs/doc/en/draft/debugging-howto.xml,v 1.1 2005/07/13 05:55:39 fox2mike Exp $ --> 3<!-- $Header: /var/cvsroot/gentoo/xml/htdocs/doc/en/draft/debugging-howto.xml,v 1.2 2005/07/13 18:58:31 fox2mike Exp $ -->
4 4
5<guide link="/doc/en/debugging-howto.xml"> 5<guide link="/doc/en/debugging-howto.xml">
6<title>Gentoo Linux Debugging Guide</title> 6<title>Gentoo Linux Debugging Guide</title>
7 7
8<author title="Author"> 8<author title="Author">
404<section> 404<section>
405<title>Conclusion</title> 405<title>Conclusion</title>
406<body> 406<body>
407 407
408<p> 408<p>
409Now we've taken care of finding run time bugs. These bugs prove to be 409<c>strace</c> is a great way at seeing what the kernel is doing to with the filesystem.
410problematic when you try and run your programs. However, run time errors are 410Another program exists to help users see what the kernel is doing, and help with
411the least of your concerns if your program won't compile at all. Let's take a 411kernel debugging. This program is called <c>dmesg</c>
412look at how to address <c>emerge</c> compile errors. 412</p>
413
414</body>
415</section>
416</chapter>
417
418<chapter>
419<title>Kernel Debugging With dmesg</title>
420<section>
421<title>dmesg Introduction</title>
422<body>
423
424<p>
425<c>dmesg</c> is a system program created with debugging kernel operation. It
426basically reads the kernel messages and keeps them in buffer, letting the user
427see them later on. Here's an example of what a dmesg output looks like:
428</p>
429
430<pre caption="dmesg sample output">
431SIS5513: IDE controller at PCI slot 0000:00:02.5
432SIS5513: chipset revision 208
433SIS5513: not 100% native mode: will probe irqs later
434SIS5513: SiS 961 MuTIOL IDE UDMA100 controller
435ide0: BM-DMA at 0x4000-0x4007, BIOS settings: hda:DMA, hdb:DMA
436ide1: BM-DMA at 0x4008-0x400f, BIOS settings: hdc:DMA, hdd:DMA
437Probing IDE interface ide0...
438input: ImPS/2 Generic Wheel Mouse on isa0060/serio1
439hda: WDC WD800BB-60CJA0, ATA DISK drive
440hdb: CD-RW 52X24, ATAPI CD/DVD-ROM drive
441ide0 at 0x1f0-0x1f7,0x3f6 on irq 14
442Probing IDE interface ide1...
443hdc: SAMSUNG DVD-ROM SD-616T, ATAPI CD/DVD-ROM drive
444hdd: Maxtor 92049U6, ATA DISK drive
445ide1 at 0x170-0x177,0x376 on irq 15
446hda: max request size: 128KiB
447hda: 156301488 sectors (80026 MB) w/2048KiB Cache, CHS=65535/16/63,
448UDMA(100)
449hda: cache flushes not supported
450hda: hda1
451hdd: max request size: 128KiB
452hdd: 39882528 sectors (20419 MB) w/2048KiB Cache, CHS=39566/16/63,
453UDMA(66)
454hdd: cache flushes not supported
455hdd: unknown partition table
456hdb: ATAPI 52X CD-ROM CD-R/RW drive, 2048kB Cache, UDMA(33)
457Uniform CD-ROM driver Revision: 3.20
458hdc: ATAPI 48X DVD-ROM drive, 512kB Cache, UDMA(33)
459ide-floppy driver 0.99.newide
460libata version 1.11 loaded.
461usbmon: debugs is not available
462</pre>
463
464<p>
465The dmesg displayed here is my machine's bootup. You can see harddrives and
466input devices being initialized. While what you see here seems relatively
467harmless, <c>dmesg</c> is also good at showing when things go wrong. Let's take
468for example an IPAQ 1945 I have. After a couple of minutes of inactivity, the
469device powers off. Now, I have the device connected into the USB port in the
470front of my system. Now, I want to copy over some files using libsynCE, so I go
471ahead and initiate a connection:
472</p>
473
474<pre caption="IPAQ connection attempt">
475# <i>synce-serial-start</i>
476/usr/sbin/pppd: In file /etc/ppp/peers/synce-device: unrecognized option
477'/dev/tts/USB0'
478
479synce-serial-start was unable to start the PPP daemon!
480</pre>
481
482<p>
483The connection fails, as we see here, and we assume that only the screen is in
484powersave mode, and that maybe the connection is faulty. In order to see what
485truly happened, we can use <c>dmesg</c>. Now, <c>dmesg</c> tends to give a
486rather large ammount of output. One can use the <c>tail</c> command to help
487keep the output down:
488</p>
489
490<pre caption="Adjusting the output ammount with tail">
491$ <i>dmesg | tail -n 4</i>
492usb 1-1.2: PocketPC PDA converter now attached to ttyUSB0
493usb 1-1.2: USB disconnect, address 11
494PocketPC PDA ttyUSB0: PocketPC PDA converter now disconnected from ttyUSB0
495ipaq 1-1.2:1.0: device disconnected
496</pre>
497
498<p>
499This gives us the last 4 lines of the dmesg output. Now, this is enough to give
500us some information on the situation. It seems that in the first 2 lines, the
501pocketpc is recognized as connected. However, in the last 2 lines, it appears
502to have been disconnected. With this information we check the pocketpc again,
503and find out it is powered off, and now know about the powersave mode. We can
504use this information to turn the feature off, or be aware of it next time.
505While this is a somewhat simple example, it does go to show how well dmesg can
506work. However, in more complex examples (such as kernel bugs), the entire dmesg
507output may be required. To obtain that, simple redirect to a log file as such:
508</p>
509
510<pre caption="Saving dmesg output to a log">
511$ <i>dmesg > dmesg.log</i>
512</pre>
513
514<p>
515You can then attach this to a bug report, or post it online somewhere for
516collaborative debugging sessions.
517</p>
518
519</body>
520</section>
521<section>
522<title>Conclusion</title>
523<body>
524
525<p>
526Now that we've taken a look at a few ways to debug runtime and kernel errors,
527let's take a look at how to handle emerge errors.
413</p> 528</p>
414 529
415</body> 530</body>
416</section> 531</section>
417</chapter> 532</chapter>

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.2

  ViewVC Help
Powered by ViewVC 1.1.20