Debugging HLFS - proposal

Kevin Day thekevinday at gmail.com
Sat Sep 2 18:18:52 PDT 2006


While I have been doing numerous optimization experiments, I've
recently come up with an idea for debugging.

First of all, gdb has been quite popular in the past, but I have had
nothing but problems getting gdb to work, it even segfaults, and when
it works, it doesn't catch most of the segfaults that happen.

I am not sure why this happens, but I have come across a better
alternative: valgrind (http://www.valgrind.org/).

I have been able to catch (and easily at that) every single abort or
segfault that happens and produce a detailed log of what went on in
during runtime that lead to the segfault/abort/crash + the precise
amount of bytes leaked or not leaked.

Unlike gdb, valgrind is actively maintained today.

I believe it might be very beneficial to adding valgrind to the
toolchain stage.  This would allow use to do something like "valgrind
make" on every package.

The entire system install process could be checked during this method,
but it does in fact slow down the install time.

Even though I am just starting to use this program, I am seeing a
pattern that is possibly pointing to uClibc as a cause for a large
number of the system problems.

There are much more debugging options available than the simple memory
check, and I can make notes on all of the commands as I learn them.

Here is an example of the output I get from running "valgrind make" in
the middle of nowhere. (not in any source):

==9745== Memcheck, a memory error detector.
==9745== Copyright (C) 2002-2006, and GNU GPL'd, by Julian Seward et al.
==9745== Using LibVEX rev 1606, a library for dynamic binary translation.
==9745== Copyright (C) 2004-2006, and GNU GPL'd, by OpenWorks LLP.
==9745== Using valgrind-3.2.0, a dynamic binary instrumentation framework.
==9745== Copyright (C) 2000-2006, and GNU GPL'd, by Julian Seward et al.
==9745== For more details, rerun with: -v
==9745==
==9745== Conditional jump or move depends on uninitialised value(s)
==9745==    at 0x4003C2B: _dl_get_ready_to_run (in /lib/ld-uClibc-0.9.28.so)
==9745==    by 0x4004492: (within /lib/ld-uClibc-0.9.28.so)
==9745==    by 0x40008C4: _start (in /lib/ld-uClibc-0.9.28.so)
==9745==
==9745== Conditional jump or move depends on uninitialised value(s)
==9745==    at 0x4002E85: _dl_load_shared_library (in /lib/ld-uClibc-0.9.28.so)
==9745==    by 0x4003560: _dl_get_ready_to_run (in /lib/ld-uClibc-0.9.28.so)
==9745==    by 0x4004492: (within /lib/ld-uClibc-0.9.28.so)
==9745==    by 0x40008C4: _start (in /lib/ld-uClibc-0.9.28.so)
==9745==
==9745== Conditional jump or move depends on uninitialised value(s)
==9745==    at 0x4002ED6: _dl_load_shared_library (in /lib/ld-uClibc-0.9.28.so)
==9745==    by 0x4003560: _dl_get_ready_to_run (in /lib/ld-uClibc-0.9.28.so)
==9745==    by 0x4004492: (within /lib/ld-uClibc-0.9.28.so)
==9745==    by 0x40008C4: _start (in /lib/ld-uClibc-0.9.28.so)
==9745==
==9745== Conditional jump or move depends on uninitialised value(s)
==9745==    at 0x40017F5: _dl_fixup (in /lib/ld-uClibc-0.9.28.so)
==9745==    by 0x40038EB: _dl_get_ready_to_run (in /lib/ld-uClibc-0.9.28.so)
==9745==    by 0x4004492: (within /lib/ld-uClibc-0.9.28.so)
==9745==    by 0x40008C4: _start (in /lib/ld-uClibc-0.9.28.so)
==9745==
==9745== Conditional jump or move depends on uninitialised value(s)
==9745==    at 0x400182A: _dl_fixup (in /lib/ld-uClibc-0.9.28.so)
==9745==    by 0x40038EB: _dl_get_ready_to_run (in /lib/ld-uClibc-0.9.28.so)
==9745==    by 0x4004492: (within /lib/ld-uClibc-0.9.28.so)
==9745==    by 0x40008C4: _start (in /lib/ld-uClibc-0.9.28.so)
==9745==
==9745== Conditional jump or move depends on uninitialised value(s)
==9745==    at 0x4001888: _dl_fixup (in /lib/ld-uClibc-0.9.28.so)
==9745==    by 0x40038EB: _dl_get_ready_to_run (in /lib/ld-uClibc-0.9.28.so)
==9745==    by 0x4004492: (within /lib/ld-uClibc-0.9.28.so)
==9745==    by 0x40008C4: _start (in /lib/ld-uClibc-0.9.28.so)
==9745==
==9745== Conditional jump or move depends on uninitialised value(s)
==9745==    at 0x40039CB: _dl_get_ready_to_run (in /lib/ld-uClibc-0.9.28.so)
==9745==    by 0x4004492: (within /lib/ld-uClibc-0.9.28.so)
==9745==    by 0x40008C4: _start (in /lib/ld-uClibc-0.9.28.so)
make: *** No targets specified and no makefile found.  Stop.
==9745==
==9745== ERROR SUMMARY: 9 errors from 7 contexts (suppressed: 0 from 0)
==9745== malloc/free: in use at exit: 39,412 bytes in 1,299 blocks.
==9745== malloc/free: 5,664 allocs, 4,365 frees, 1,701,496 bytes allocated.
==9745== For counts of detected errors, rerun with: -v
==9745== searching for pointers to 1,299 not-freed blocks.
==9745== checked 107,604 bytes.
==9745==
==9745== LEAK SUMMARY:
==9745==    definitely lost: 0 bytes in 0 blocks.
==9745==      possibly lost: 0 bytes in 0 blocks.
==9745==    still reachable: 39,412 bytes in 1,299 blocks.
==9745==         suppressed: 0 bytes in 0 blocks.
==9745== Reachable blocks (those to which a pointer was found) are not shown.
==9745== To see them, rerun with: --show-reachable=yes


-- 
Kevin Day



More information about the hlfs-dev mailing list