Maybe I am missing something, but

I can't seem to get a decent symbolic dump with valgrind even when I use
--read-var-info=yes

--- quote from the valgrind manual ----
 --read-var-info=<yes|no> [default: no]

    When enabled, Valgrind will read information about variable types and
locations from DWARF3 debug info. This slows Valgrind down and makes it use
more memory, but for the tools that can take advantage of it (Memcheck,
Helgrind, DRD) it can result in more precise error messages. For example,
here are some standard errors issued by Memcheck:

    ==15516== Uninitialised byte(s) found during client check request
    ==15516==    at 0x400633: croak (varinfo1.c:28)
    ==15516==    by 0x4006B2: main (varinfo1.c:55)
    ==15516==  Address 0x60103b is 7 bytes inside data symbol "global_i2"
    ==15516==
    ==15516== Uninitialised byte(s) found during client check request
    ==15516==    at 0x400633: croak (varinfo1.c:28)
    ==15516==    by 0x4006BC: main (varinfo1.c:56)
    ==15516==  Address 0x7fefffefc is on thread 1's stack

    And here are the same errors with --read-var-info=yes:

    ==15522== Uninitialised byte(s) found during client check request
    ==15522==    at 0x400633: croak (varinfo1.c:28)
    ==15522==    by 0x4006B2: main (varinfo1.c:55)
    ==15522==  Location 0x60103b is 0 bytes inside global_i2[7],
    ==15522==  a global variable declared at varinfo1.c:41
    ==15522==
    ==15522== Uninitialised byte(s) found during client check request
    ==15522==    at 0x400633: croak (varinfo1.c:28)
    ==15522==    by 0x4006BC: main (varinfo1.c:56)
    ==15522==  Location 0x7fefffefc is 0 bytes inside local var "local"
    ==15522==  declared at varinfo1.c:46, in frame #1 of thread 1


--- end quote ---


But in real world, here is what happens.

ishikawa@debian-vbox-ci:~/repos/valgrind$ gcc --version
gcc (Debian 4.7.3-4) 4.7.3
Copyright (C) 2012 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Here is the test program to see if symbolic name of the
memory area is printed by valgrind.

ishikawa@debian-vbox-ci:~/repos/valgrind$ cat test-split-dwarf.c
/*
 * gcc-4.8 -g -gsplit-dwarf -Wl,--gdb-index test-split-dwarf.c
 * then run the binary under valgrind.
 * Compare the output from valgrind when compile command is
 * simply
 * gcc test-gsplit-dwarf
 *
 */
#include <stdio.h>
#include <stdlib.h>


char *p;

int test()
{
  return p[10];
}

main() {
  int uninitialized_int10[10];
  int uninit_int1;
  int init_int2;
  init_int2 = 2;

  p = malloc(10);
  printf ("%d\n", test());

  if(uninitialized_int10[3])
    printf ("%d\n", uninitialized_int10[3]);

  if(uninit_int1)
    printf("%d, %d\n", init_int2, uninit_int1);

  * ((int *) 0) = 1;

  exit(EXIT_SUCCESS);
}
ishikawa@debian-vbox-ci:~/repos/valgrind$ gcc -g -g3 test-split-dwarf.c
ishikawa@debian-vbox-ci:~/repos/valgrind$ valgrind --version
valgrind-3.9.0.SVN

The line wrap is artifact of the e-mail client.

ishikawa@debian-vbox-ci:~/repos/valgrind$ valgrind --read-var-info=yes
--track-origins=yes ./a.out
==13189== Memcheck, a memory error detector
==13189== Copyright (C) 2002-2012, and GNU GPL'd, by Julian Seward et al.
==13189== Using Valgrind-3.9.0.SVN and LibVEX; rerun with -h for copyright info
==13189== Command: ./a.out
==13189==
==13189== Invalid read of size 1
==13189==    at 0x80484E7: test (test-split-dwarf.c:17)
==13189==    by 0x8048515: main (test-split-dwarf.c:27)
==13189==  Address 0x41fd032 is 0 bytes after a block of size 10 alloc'd
==13189==    at 0x4029FD0: malloc (vg_replace_malloc.c:291)
==13189==    by 0x804850B: main (test-split-dwarf.c:26)
==13189==
0
==13189== Conditional jump or move depends on uninitialised value(s)
==13189==    at 0x804852C: main (test-split-dwarf.c:29)
==13189==  Uninitialised value was created by a stack allocation
==13189==    at 0x80484F5: main (test-split-dwarf.c:20)
==13189==
==13189== Use of uninitialised value of size 4
==13189==    at 0x408EC4B: _itoa_word (_itoa.c:179)
==13189==    by 0x4092819: vfprintf (vfprintf.c:1648)
==13189==    by 0x4098F8E: printf (printf.c:34)
==13189==    by 0x8048541: main (test-split-dwarf.c:30)
==13189==  Uninitialised value was created by a stack allocation
==13189==    at 0x80484F5: main (test-split-dwarf.c:20)
==13189==
==13189== Conditional jump or move depends on uninitialised value(s)
==13189==    at 0x408EC53: _itoa_word (_itoa.c:179)
==13189==    by 0x4092819: vfprintf (vfprintf.c:1648)
==13189==    by 0x4098F8E: printf (printf.c:34)
==13189==    by 0x8048541: main (test-split-dwarf.c:30)
==13189==  Uninitialised value was created by a stack allocation
==13189==    at 0x80484F5: main (test-split-dwarf.c:20)
==13189==
==13189== Conditional jump or move depends on uninitialised value(s)
==13189==    at 0x408F99D: vfprintf (vfprintf.c:1648)
==13189==    by 0x4098F8E: printf (printf.c:34)
==13189==    by 0x8048541: main (test-split-dwarf.c:30)
==13189==  Uninitialised value was created by a stack allocation
==13189==    at 0x80484F5: main (test-split-dwarf.c:20)
==13189==
==13189== Conditional jump or move depends on uninitialised value(s)
==13189==    at 0x408FA19: vfprintf (vfprintf.c:1648)
==13189==    by 0x4098F8E: printf (printf.c:34)
==13189==    by 0x8048541: main (test-split-dwarf.c:30)
==13189==  Uninitialised value was created by a stack allocation
==13189==    at 0x80484F5: main (test-split-dwarf.c:20)
==13189==
==13189== Conditional jump or move depends on uninitialised value(s)
==13189==    at 0x40924EB: vfprintf (vfprintf.c:1648)
==13189==    by 0x4098F8E: printf (printf.c:34)
==13189==    by 0x8048541: main (test-split-dwarf.c:30)
==13189==  Uninitialised value was created by a stack allocation
==13189==    at 0x80484F5: main (test-split-dwarf.c:20)
==13189==
==13189== Conditional jump or move depends on uninitialised value(s)
==13189==    at 0x408FA70: vfprintf (vfprintf.c:1648)
==13189==    by 0x4098F8E: printf (printf.c:34)
==13189==    by 0x8048541: main (test-split-dwarf.c:30)
==13189==  Uninitialised value was created by a stack allocation
==13189==    at 0x80484F5: main (test-split-dwarf.c:20)
==13189==
==13189== Conditional jump or move depends on uninitialised value(s)
==13189==    at 0x408FAA9: vfprintf (vfprintf.c:1648)
==13189==    by 0x4098F8E: printf (printf.c:34)
==13189==    by 0x8048541: main (test-split-dwarf.c:30)
==13189==  Uninitialised value was created by a stack allocation
==13189==    at 0x80484F5: main (test-split-dwarf.c:20)
==13189==
134514130
==13189== Conditional jump or move depends on uninitialised value(s)
==13189==    at 0x8048547: main (test-split-dwarf.c:32)
==13189==  Uninitialised value was created by a stack allocation
==13189==    at 0x80484F5: main (test-split-dwarf.c:20)
==13189==
==13189== Use of uninitialised value of size 4
==13189==    at 0x408EC4B: _itoa_word (_itoa.c:179)
==13189==    by 0x4092819: vfprintf (vfprintf.c:1648)
==13189==    by 0x4098F8E: printf (printf.c:34)
==13189==    by 0x8048564: main (test-split-dwarf.c:33)
==13189==  Uninitialised value was created by a stack allocation
==13189==    at 0x80484F5: main (test-split-dwarf.c:20)
==13189==
==13189== Conditional jump or move depends on uninitialised value(s)
==13189==    at 0x408EC53: _itoa_word (_itoa.c:179)
==13189==    by 0x4092819: vfprintf (vfprintf.c:1648)
==13189==    by 0x4098F8E: printf (printf.c:34)
==13189==    by 0x8048564: main (test-split-dwarf.c:33)
==13189==  Uninitialised value was created by a stack allocation
==13189==    at 0x80484F5: main (test-split-dwarf.c:20)
==13189==
==13189== Conditional jump or move depends on uninitialised value(s)
==13189==    at 0x408F99D: vfprintf (vfprintf.c:1648)
==13189==    by 0x4098F8E: printf (printf.c:34)
==13189==    by 0x8048564: main (test-split-dwarf.c:33)
==13189==  Uninitialised value was created by a stack allocation
==13189==    at 0x80484F5: main (test-split-dwarf.c:20)
==13189==
==13189== Conditional jump or move depends on uninitialised value(s)
==13189==    at 0x408FA19: vfprintf (vfprintf.c:1648)
==13189==    by 0x4098F8E: printf (printf.c:34)
==13189==    by 0x8048564: main (test-split-dwarf.c:33)
==13189==  Uninitialised value was created by a stack allocation
==13189==    at 0x80484F5: main (test-split-dwarf.c:20)
==13189==
==13189== Conditional jump or move depends on uninitialised value(s)
==13189==    at 0x40924EB: vfprintf (vfprintf.c:1648)
==13189==    by 0x4098F8E: printf (printf.c:34)
==13189==    by 0x8048564: main (test-split-dwarf.c:33)
==13189==  Uninitialised value was created by a stack allocation
==13189==    at 0x80484F5: main (test-split-dwarf.c:20)
==13189==
==13189== Conditional jump or move depends on uninitialised value(s)
==13189==    at 0x408FA70: vfprintf (vfprintf.c:1648)
==13189==    by 0x4098F8E: printf (printf.c:34)
==13189==    by 0x8048564: main (test-split-dwarf.c:33)
==13189==  Uninitialised value was created by a stack allocation
==13189==    at 0x80484F5: main (test-split-dwarf.c:20)
==13189==
==13189== Conditional jump or move depends on uninitialised value(s)
==13189==    at 0x408FAA9: vfprintf (vfprintf.c:1648)
==13189==    by 0x4098F8E: printf (printf.c:34)
==13189==    by 0x8048564: main (test-split-dwarf.c:33)
==13189==  Uninitialised value was created by a stack allocation
==13189==    at 0x80484F5: main (test-split-dwarf.c:20)
==13189==
2, 134514059
==13189== Invalid write of size 4
==13189==    at 0x804856A: main (test-split-dwarf.c:35)
==13189==  Address 0x0 is not stack'd, malloc'd or (recently) free'd
==13189==
==13189==
==13189== Process terminating with default action of signal 11 (SIGSEGV)
==13189==  Access not within mapped region at address 0x0
==13189==    at 0x804856A: main (test-split-dwarf.c:35)
==13189==  If you believe this happened as a result of a stack
==13189==  overflow in your program's main thread (unlikely but
==13189==  possible), you can try to increase the size of the
==13189==  main thread stack using the --main-stacksize= flag.
==13189==  The main thread stack size used in this run was 8388608.
==13189==
==13189== HEAP SUMMARY:
==13189==     in use at exit: 10 bytes in 1 blocks
==13189==   total heap usage: 1 allocs, 0 frees, 10 bytes allocated
==13189==
==13189== LEAK SUMMARY:
==13189==    definitely lost: 0 bytes in 0 blocks
==13189==    indirectly lost: 0 bytes in 0 blocks
==13189==      possibly lost: 0 bytes in 0 blocks
==13189==    still reachable: 10 bytes in 1 blocks
==13189==         suppressed: 0 bytes in 0 blocks
==13189== Rerun with --leak-check=full to see details of leaked memory
==13189==
==13189== For counts of detected and suppressed errors, rerun with: -v
==13189== ERROR SUMMARY: 50 errors from 18 contexts (suppressed: 2 from 2)
Segmentation fault
ishikawa@debian-vbox-ci:~/repos/valgrind$

I wish valgrind prints the warnings by referring to the variable names if
possible. But it didn't. Why?

TIA

------------------------------------------------------------------------------
Learn the latest--Visual Studio 2012, SharePoint 2013, SQL 2012, more!
Discover the easy way to master current and previous Microsoft technologies
and advance your career. Get an incredible 1,500+ hours of step-by-step
tutorial videos with LearnDevNow. Subscribe today and save!
http://pubads.g.doubleclick.net/gampad/clk?id=58041391&iu=/4140/ostg.clktrk
_______________________________________________
Valgrind-users mailing list
Valgrind-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/valgrind-users

Reply via email to