Describe the lock address in a lock announcement message.
(note that some error messages are not announcing the lock,
which is not that nice).
At least the lock order violation message do not announce locks.
That should be improved/fixed
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@14188 a5019735-40e9-0310-863c-91ae7b9d1cf9
diff --git a/NEWS b/NEWS
index b338fd7..079f722 100644
--- a/NEWS
+++ b/NEWS
@@ -18,16 +18,18 @@
the block size - 8. This is e.g. used by sqlite3MemMalloc.
* Helgrind:
- - Helgrind GDB server monitor command 'info locks' giving
- the list of locks, their location, and their status.
- Race condition error message with allocated blocks also show
the thread nr that allocated the racy block.
+ - The message indicating where a lock was first observed now also
+ describes the address/location of the lock.
- Helgrind now understands the Ada task termination rules
and creates a 'H-B relationship' between a terminated task and
its master. This avoids some false positive and avoids big
memory usage when a lot of Ada tasks are created and terminated.
The interceptions are only activated with gnatpro >= 7.3.0w-20140611
or gcc >= ????? (TBD: check when changes pushed to FSF gcc).
+ - Helgrind GDB server monitor command 'info locks' giving
+ the list of locks, their location, and their status.
* Callgrind:
- callgrind_control now supports the --vgdb-prefix argument,
diff --git a/helgrind/hg_addrdescr.h b/helgrind/hg_addrdescr.h
index 67b2bb5..32d7842 100644
--- a/helgrind/hg_addrdescr.h
+++ b/helgrind/hg_addrdescr.h
@@ -39,12 +39,6 @@
VG_(clear_addrinfo). */
extern void HG_(describe_addr) ( Addr a, /*OUT*/AddrInfo* ai );
-/* Prints (using *print) the readable description of addr given in ai.
- "what" identifies the type pointed to by addr (e.g. a lock). */
-extern void HG_(pp_addrdescr) (Bool xml, const HChar* what, Addr addr,
- AddrInfo* ai,
- void(*print)(const HChar *format, ...));
-
/* Get a readable description of addr, then print it using HG_(pp_addrdescr)
using xml False and VG_(printf) to emit the characters.
Returns True if a description was found/printed, False otherwise. */
diff --git a/helgrind/hg_errors.c b/helgrind/hg_errors.c
index c017a91..9a67b77 100644
--- a/helgrind/hg_errors.c
+++ b/helgrind/hg_errors.c
@@ -770,9 +770,15 @@
if (VG_(clo_xml)) {
/* fixme: add announcement */
} else {
- VG_(umsg)( "Lock at %p was first observed\n",
- (void*)lk->guestaddr );
- VG_(pp_ExeContext)( lk->appeared_at );
+ if (lk->appeared_at) {
+ VG_(umsg)( "Lock at %p was first observed\n",
+ (void*)lk->guestaddr );
+ VG_(pp_ExeContext)( lk->appeared_at );
+ } else {
+ VG_(umsg)( "Lock at %p : no stacktrace for first observation\n",
+ (void*)lk->guestaddr );
+ }
+ HG_(get_and_pp_addrdescr) (lk->guestaddr);
VG_(umsg)("\n");
}
}
diff --git a/helgrind/tests/annotate_rwlock.stderr.exp b/helgrind/tests/annotate_rwlock.stderr.exp
index d62d8e4..9392d39 100644
--- a/helgrind/tests/annotate_rwlock.stderr.exp
+++ b/helgrind/tests/annotate_rwlock.stderr.exp
@@ -102,6 +102,7 @@
Lock at 0x........ was first observed
at 0x........: rwlock_init (annotate_rwlock.c:54)
by 0x........: main (annotate_rwlock.c:161)
+ Address 0x........ is 0 bytes inside data symbol "s_rwlock"
Possible data race during write of size 4 at 0x........ by thread #x
Locks held: 1, at address 0x........
diff --git a/helgrind/tests/locked_vs_unlocked1_fwd.stderr.exp b/helgrind/tests/locked_vs_unlocked1_fwd.stderr.exp
index 5834cbd..4319398 100644
--- a/helgrind/tests/locked_vs_unlocked1_fwd.stderr.exp
+++ b/helgrind/tests/locked_vs_unlocked1_fwd.stderr.exp
@@ -19,6 +19,7 @@
by 0x........: child_fn (locked_vs_unlocked1.c:18)
by 0x........: mythread_wrapper (hg_intercepts.c:...)
...
+ Address 0x........ is 0 bytes inside data symbol "mx"
Possible data race during write of size 4 at 0x........ by thread #x
Locks held: none
diff --git a/helgrind/tests/locked_vs_unlocked1_rev.stderr.exp b/helgrind/tests/locked_vs_unlocked1_rev.stderr.exp
index 05e2175..bcf728c 100644
--- a/helgrind/tests/locked_vs_unlocked1_rev.stderr.exp
+++ b/helgrind/tests/locked_vs_unlocked1_rev.stderr.exp
@@ -19,6 +19,7 @@
by 0x........: child_fn (locked_vs_unlocked1.c:18)
by 0x........: mythread_wrapper (hg_intercepts.c:...)
...
+ Address 0x........ is 0 bytes inside data symbol "mx"
Possible data race during write of size 4 at 0x........ by thread #x
Locks held: 1, at address 0x........
diff --git a/helgrind/tests/locked_vs_unlocked2.stderr.exp b/helgrind/tests/locked_vs_unlocked2.stderr.exp
index 6e0e068..b4051fd 100644
--- a/helgrind/tests/locked_vs_unlocked2.stderr.exp
+++ b/helgrind/tests/locked_vs_unlocked2.stderr.exp
@@ -17,14 +17,17 @@
Lock at 0x........ was first observed
at 0x........: pthread_mutex_init (hg_intercepts.c:...)
by 0x........: main (locked_vs_unlocked2.c:58)
+ Address 0x........ is 0 bytes inside data symbol "mx2a"
Lock at 0x........ was first observed
at 0x........: pthread_mutex_init (hg_intercepts.c:...)
by 0x........: main (locked_vs_unlocked2.c:59)
+ Address 0x........ is 0 bytes inside data symbol "mx2b"
Lock at 0x........ was first observed
at 0x........: pthread_mutex_init (hg_intercepts.c:...)
by 0x........: main (locked_vs_unlocked2.c:57)
+ Address 0x........ is 0 bytes inside data symbol "mx1b"
Possible data race during write of size 4 at 0x........ by thread #x
Locks held: 2, at addresses 0x........ 0x........
diff --git a/helgrind/tests/locked_vs_unlocked3.stderr.exp b/helgrind/tests/locked_vs_unlocked3.stderr.exp
index e5f4b5d..6e62ca7 100644
--- a/helgrind/tests/locked_vs_unlocked3.stderr.exp
+++ b/helgrind/tests/locked_vs_unlocked3.stderr.exp
@@ -17,6 +17,7 @@
Lock at 0x........ was first observed
at 0x........: pthread_mutex_init (hg_intercepts.c:...)
by 0x........: main (locked_vs_unlocked3.c:51)
+ Address 0x........ is 0 bytes inside data symbol "mx"
Possible data race during write of size 4 at 0x........ by thread #x
Locks held: none