Switched to VG_(get_data_description)() for descriptions of addresses in error reports.

git-svn-id: svn://svn.valgrind.org/valgrind/trunk@7585 a5019735-40e9-0310-863c-91ae7b9d1cf9
diff --git a/exp-drd/drd_error.c b/exp-drd/drd_error.c
index 05bf4a4..20d3aff 100644
--- a/exp-drd/drd_error.c
+++ b/exp-drd/drd_error.c
@@ -220,13 +220,20 @@
 void drd_report_data_race2(Error* const err, const DataRaceErrInfo* const dri)
 {
    AddrInfo ai;
-   Char descr[256];
+   Char descr1[256];
+   Char descr2[256];
 
    tl_assert(dri);
    tl_assert(dri->addr);
    tl_assert(dri->size > 0);
-   describe_addr_text(dri->addr, dri->size,
-                      &ai, descr, sizeof(descr));
+
+   descr1[0] = 0;
+   descr2[0] = 0;
+   VG_(get_data_description)(descr1, descr2, sizeof(descr1), dri->addr);
+   if (descr1[0] == 0)
+   {
+      describe_addr(dri->addr, dri->size, &ai);
+   }
    VG_(message)(Vg_UserMsg,
                 "Conflicting %s by %s at 0x%08lx size %ld",
                 dri->access_type == eStore ? "store" : "load",
@@ -234,11 +241,19 @@
                 dri->addr,
                 dri->size);
    VG_(pp_ExeContext)(VG_(get_error_where)(err));
-   VG_(message)(Vg_UserMsg, "Allocation context: %s", descr);
-   if (ai.akind == eMallocd && ai.lastchange)
+   if (descr1[0])
+   {
+      VG_(message)(Vg_UserMsg, "%s", descr1);
+      VG_(message)(Vg_UserMsg, "%s", descr2);
+   }
+   else if (ai.akind == eMallocd && ai.lastchange)
    {
       VG_(pp_ExeContext)(ai.lastchange);
    }
+   else
+   {
+      VG_(message)(Vg_UserMsg, "Allocation context: unknown.\n");
+   }
    thread_report_conflicting_segments(VgThreadIdToDrdThreadId(dri->tid),
                                       dri->addr, dri->size, dri->access_type);
 }
diff --git a/exp-drd/drd_error.h b/exp-drd/drd_error.h
index 1ef243e..e459034 100644
--- a/exp-drd/drd_error.h
+++ b/exp-drd/drd_error.h
@@ -27,7 +27,7 @@
 #define __DRD_ERROR_H
 
 
-#include "pub_drd_bitmap.h"         // BmAccessTypeT
+#include "pub_drd_bitmap.h"     // BmAccessTypeT
 #include "drd_thread.h"         // DrdThreadId
 #include "pub_tool_basics.h"    // SizeT
 #include "pub_tool_debuginfo.h" // SegInfo
diff --git a/exp-drd/tests/filter_stderr b/exp-drd/tests/filter_stderr
index fd86472..aebffc0 100755
--- a/exp-drd/tests/filter_stderr
+++ b/exp-drd/tests/filter_stderr
@@ -11,7 +11,6 @@
 sed \
 -e "/^exp-drd, a data race detector\.$/d" \
 -e "s/^Allocation context: stack of thread \([0-9]*\), offset -[0-9]*$/Allocation context: stack of thread \1, offset .../" \
--e "s/^Allocation context: .*$/Allocation context: unknown/" \
 -e "s/(tc20_verifywrap.c:261)/(tc20_verifywrap.c:262)/" \
 -e "/^NOTE: This is an Experimental-Class Valgrind Tool.$/d"  \
 -e "/^Copyright (C) 2006-200., and GNU GPL'd, by Bart Van Assche.$/d" \
diff --git a/exp-drd/tests/fp_race.stderr.exp b/exp-drd/tests/fp_race.stderr.exp
index c9afafd..153ce96 100644
--- a/exp-drd/tests/fp_race.stderr.exp
+++ b/exp-drd/tests/fp_race.stderr.exp
@@ -1,7 +1,8 @@
 
 Conflicting load by main at 0x........ size 8
    at 0x........: main (fp_race.c:?)
-Allocation context: unknown
+Location 0x........ is 0 bytes inside local var "s_d3"
+declared at fp_race.c:47, in frame #0 of thread 1
 Other segment start (thread_func)
    (thread finished, call stack no longer available)
 Other segment end (thread_func)
@@ -9,7 +10,8 @@
 
 Conflicting store by main at 0x........ size 8
    at 0x........: main (fp_race.c:?)
-Allocation context: unknown
+Location 0x........ is 0 bytes inside local var "s_d3"
+declared at fp_race.c:47, in frame #0 of thread 1
 Other segment start (thread_func)
    (thread finished, call stack no longer available)
 Other segment end (thread_func)
diff --git a/exp-drd/tests/hg03_inherit.stderr.exp b/exp-drd/tests/hg03_inherit.stderr.exp
index 274c6a7..3102848 100644
--- a/exp-drd/tests/hg03_inherit.stderr.exp
+++ b/exp-drd/tests/hg03_inherit.stderr.exp
@@ -5,7 +5,8 @@
    by 0x........: vg_thread_wrapper (drd_intercepts.c:?)
    by 0x........: start_thread (in libpthread-?.?.so)
    by 0x........: clone (in /...libc...)
-Allocation context: unknown
+Location 0x........ is 0 bytes inside shared[1],
+declared at hg03_inherit.c:11, in frame #0 of thread 3
 Other segment start (thread 1)
    at 0x........: pthread_join (drd_intercepts.c:?)
    by 0x........: main (hg03_inherit.c:49)
@@ -19,7 +20,8 @@
    by 0x........: vg_thread_wrapper (drd_intercepts.c:?)
    by 0x........: start_thread (in libpthread-?.?.so)
    by 0x........: clone (in /...libc...)
-Allocation context: unknown
+Location 0x........ is 0 bytes inside shared[1],
+declared at hg03_inherit.c:11, in frame #0 of thread 3
 Other segment start (thread 1)
    at 0x........: pthread_join (drd_intercepts.c:?)
    by 0x........: main (hg03_inherit.c:49)
diff --git a/exp-drd/tests/hg04_race.stderr.exp b/exp-drd/tests/hg04_race.stderr.exp
index c713aff..8679d06 100644
--- a/exp-drd/tests/hg04_race.stderr.exp
+++ b/exp-drd/tests/hg04_race.stderr.exp
@@ -5,7 +5,8 @@
    by 0x........: vg_thread_wrapper (drd_intercepts.c:?)
    by 0x........: start_thread (in libpthread-?.?.so)
    by 0x........: clone (in /...libc...)
-Allocation context: unknown
+Location 0x........ is 0 bytes inside local var "shared"
+declared at hg04_race.c:6, in frame #0 of thread 2
 Other segment start (thread 2)
    (thread finished, call stack no longer available)
 Other segment end (thread 2)
@@ -16,7 +17,8 @@
    by 0x........: vg_thread_wrapper (drd_intercepts.c:?)
    by 0x........: start_thread (in libpthread-?.?.so)
    by 0x........: clone (in /...libc...)
-Allocation context: unknown
+Location 0x........ is 0 bytes inside local var "shared"
+declared at hg04_race.c:6, in frame #0 of thread 2
 Other segment start (thread 2)
    (thread finished, call stack no longer available)
 Other segment end (thread 2)
diff --git a/exp-drd/tests/hg05_race2.stderr.exp b/exp-drd/tests/hg05_race2.stderr.exp
index da70ded..743a78f 100644
--- a/exp-drd/tests/hg05_race2.stderr.exp
+++ b/exp-drd/tests/hg05_race2.stderr.exp
@@ -5,7 +5,8 @@
    by 0x........: vg_thread_wrapper (drd_intercepts.c:?)
    by 0x........: start_thread (in libpthread-?.?.so)
    by 0x........: clone (in /...libc...)
-Allocation context: unknown
+Location 0x........ is 0 bytes inside foo.poot[5].plop[11],
+declared at hg05_race2.c:24, in frame #4 of thread 1
 Other segment start (thread 2)
    (thread finished, call stack no longer available)
 Other segment end (thread 2)
@@ -16,7 +17,8 @@
    by 0x........: vg_thread_wrapper (drd_intercepts.c:?)
    by 0x........: start_thread (in libpthread-?.?.so)
    by 0x........: clone (in /...libc...)
-Allocation context: unknown
+Location 0x........ is 0 bytes inside foo.poot[5].plop[11],
+declared at hg05_race2.c:24, in frame #4 of thread 1
 Other segment start (thread 2)
    (thread finished, call stack no longer available)
 Other segment end (thread 2)
diff --git a/exp-drd/tests/rwlock_race.stderr.exp b/exp-drd/tests/rwlock_race.stderr.exp
index 8bf1411..fdcfccc 100644
--- a/exp-drd/tests/rwlock_race.stderr.exp
+++ b/exp-drd/tests/rwlock_race.stderr.exp
@@ -5,7 +5,8 @@
    by 0x........: vg_thread_wrapper (drd_intercepts.c:?)
    by 0x........: start_thread (in libpthread-?.?.so)
    by 0x........: clone (in /...libc...)
-Allocation context: unknown
+Location 0x........ is 0 bytes inside local var "s_racy"
+declared at rwlock_race.c:17, in frame #0 of thread 2
 Other segment start (thread 2)
    (thread finished, call stack no longer available)
 Other segment end (thread 2)
@@ -16,7 +17,8 @@
    by 0x........: vg_thread_wrapper (drd_intercepts.c:?)
    by 0x........: start_thread (in libpthread-?.?.so)
    by 0x........: clone (in /...libc...)
-Allocation context: unknown
+Location 0x........ is 0 bytes inside local var "s_racy"
+declared at rwlock_race.c:17, in frame #0 of thread 2
 Other segment start (thread 2)
    (thread finished, call stack no longer available)
 Other segment end (thread 2)
diff --git a/exp-drd/tests/sem_as_mutex.stderr.exp b/exp-drd/tests/sem_as_mutex.stderr.exp
index 8c39609..8a28a5f 100644
--- a/exp-drd/tests/sem_as_mutex.stderr.exp
+++ b/exp-drd/tests/sem_as_mutex.stderr.exp
@@ -1,7 +1,8 @@
 
 Conflicting load by main at 0x........ size 8
    at 0x........: main (sem_as_mutex.c:?)
-Allocation context: unknown
+Location 0x........ is 0 bytes inside local var "s_d3"
+declared at sem_as_mutex.c:48, in frame #0 of thread 1
 Other segment start (thread_func)
    (thread finished, call stack no longer available)
 Other segment end (thread_func)
@@ -9,7 +10,8 @@
 
 Conflicting store by main at 0x........ size 8
    at 0x........: main (sem_as_mutex.c:?)
-Allocation context: unknown
+Location 0x........ is 0 bytes inside local var "s_d3"
+declared at sem_as_mutex.c:48, in frame #0 of thread 1
 Other segment start (thread_func)
    (thread finished, call stack no longer available)
 Other segment end (thread_func)
diff --git a/exp-drd/tests/tc01_simple_race.stderr.exp b/exp-drd/tests/tc01_simple_race.stderr.exp
index 8a2b91a..abe4f21 100644
--- a/exp-drd/tests/tc01_simple_race.stderr.exp
+++ b/exp-drd/tests/tc01_simple_race.stderr.exp
@@ -1,7 +1,8 @@
 
 Conflicting load by thread 1 at 0x........ size 4
    at 0x........: main (tc01_simple_race.c:28)
-Allocation context: unknown
+Location 0x........ is 0 bytes inside global var "x"
+declared at tc01_simple_race.c:9
 Other segment start (thread 2)
    (thread finished, call stack no longer available)
 Other segment end (thread 2)
@@ -9,7 +10,8 @@
 
 Conflicting store by thread 1 at 0x........ size 4
    at 0x........: main (tc01_simple_race.c:28)
-Allocation context: unknown
+Location 0x........ is 0 bytes inside global var "x"
+declared at tc01_simple_race.c:9
 Other segment start (thread 2)
    (thread finished, call stack no longer available)
 Other segment end (thread 2)
diff --git a/exp-drd/tests/tc16_byterace.stderr.exp b/exp-drd/tests/tc16_byterace.stderr.exp
index 84db3ce..35bfc96 100644
--- a/exp-drd/tests/tc16_byterace.stderr.exp
+++ b/exp-drd/tests/tc16_byterace.stderr.exp
@@ -1,7 +1,8 @@
 
 Conflicting load by thread 1 at 0x........ size 1
    at 0x........: main (tc16_byterace.c:34)
-Allocation context: unknown
+Location 0x........ is 0 bytes inside bytes[4],
+a global variable declared at tc16_byterace.c:7
 Other segment start (thread 2)
    (thread finished, call stack no longer available)
 Other segment end (thread 2)
@@ -9,7 +10,8 @@
 
 Conflicting store by thread 1 at 0x........ size 1
    at 0x........: main (tc16_byterace.c:34)
-Allocation context: unknown
+Location 0x........ is 0 bytes inside bytes[4],
+a global variable declared at tc16_byterace.c:7
 Other segment start (thread 2)
    (thread finished, call stack no longer available)
 Other segment end (thread 2)
diff --git a/exp-drd/tests/tc20_verifywrap.stderr.exp b/exp-drd/tests/tc20_verifywrap.stderr.exp
index 40b607d..1ea635c 100644
--- a/exp-drd/tests/tc20_verifywrap.stderr.exp
+++ b/exp-drd/tests/tc20_verifywrap.stderr.exp
@@ -7,7 +7,8 @@
 
 Conflicting store by thread 1 at 0x........ size 2
    at 0x........: main (tc20_verifywrap.c:78)
-Allocation context: unknown
+Location 0x........ is 0 bytes inside global var "unprotected"
+declared at tc20_verifywrap.c:27
 Other segment start (thread 2)
    (thread finished, call stack no longer available)
 Other segment end (thread 2)
diff --git a/exp-drd/tests/tc20_verifywrap2.stderr.exp b/exp-drd/tests/tc20_verifywrap2.stderr.exp
index 4ac981c..f7fe3a5 100644
--- a/exp-drd/tests/tc20_verifywrap2.stderr.exp
+++ b/exp-drd/tests/tc20_verifywrap2.stderr.exp
@@ -7,7 +7,8 @@
 
 Conflicting store by thread 1 at 0x........ size 2
    at 0x........: main (tc20_verifywrap.c:78)
-Allocation context: unknown
+Location 0x........ is 0 bytes inside global var "unprotected"
+declared at tc20_verifywrap.c:27
 Other segment start (thread 2)
    (thread finished, call stack no longer available)
 Other segment end (thread 2)