0
votes

I am beginning to learn C from here. I was learning to use valgrind in Chapter-5, Exercise-4. The problem is explained in source-code window-17 on this page.

Upon Valgrind'ing the file (ex4.c), my output lacks from the Valgrind output shown on this page in the following ways;

  1. ??? instead of _itoa_word (_itoa.c:195)

  2. Location of line numbers in C library files are not identified. Instead, the path to the shared library file (.so) is given.

An example giving a comparison of the two outputs is shown below.

WHAT I EXPECT

==3082== Use of uninitialised value of size 8

==3082== at 0x4E730EB: _itoa_word (_itoa.c:195)

==3082== by 0x4E743D8: vfprintf (vfprintf.c:1613)

==3082== by 0x4E7E6F9: printf (printf.c:35)

==3082== by 0x40052B: main (ex4.c:11)


WHAT I GET

==14647== at 0x407D256: ??? (in /lib/tls/i686/cmov/libc-2.11.1.so)

==14647== by 0x4080B89: vfprintf (in /lib/tls/i686/cmov/libc-2.11.1.so)

==14647== by 0x40882BF: printf (in /lib/tls/i686/cmov/libc-2.11.1.so)

==14647== by 0x8048401: main (ex4.c:9)

Please tell me how can I correct my valgrind output. I am using Ubuntu-10.10, 32 bit version. I installed Valgrind-3.8.1 using source. My gcc version is 4.3.3 and glibc version 2.11.1

1
Please show us the code YOU have written/compiled. If it is not exactly what is on the link, it is hard to help - Mosby
@Mosby I have used exactly the same code of ex4.c file on the page c.learncodethehardway.org/book/… - Abhinav
Your libc seems to be missing the symbol you need. Try installing the libc6-dbg package (sudo aptitude install libc6-dbg)? - Mike Andrews
@gubblebozer Thanks ... it works great ... - Abhinav

1 Answers

1
votes

Some Linux distributions come with libraries that have had their symbols stripped out. The resultant libraries are much smaller, but lack the function names you need to debug them in gdb or valgrind.

You can usually find a package that has the debug symbols for each one of these libraries. On Ubuntu, for example, it's the library's package name with a "-dbg" suffix. For the C library libc6, it's libc6-dbg. Install it with:

sudo aptitude install libc6-dbg