blob: b50d48ed20c4034dea6faa962f8858314df99040 [file] [log] [blame]
sewardjf98e1c02008-10-25 16:22:41 +00001
2/*--------------------------------------------------------------------*/
3/*--- Basic definitions for all of Helgrind. ---*/
4/*--- hg_basics.h ---*/
5/*--------------------------------------------------------------------*/
6
7/*
8 This file is part of Helgrind, a Valgrind tool for detecting errors
9 in threaded programs.
10
Elliott Hughesed398002017-06-21 14:41:24 -070011 Copyright (C) 2007-2017 OpenWorks Ltd
sewardjf98e1c02008-10-25 16:22:41 +000012 info@open-works.co.uk
13
14 This program is free software; you can redistribute it and/or
15 modify it under the terms of the GNU General Public License as
16 published by the Free Software Foundation; either version 2 of the
17 License, or (at your option) any later version.
18
19 This program is distributed in the hope that it will be useful, but
20 WITHOUT ANY WARRANTY; without even the implied warranty of
21 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
22 General Public License for more details.
23
24 You should have received a copy of the GNU General Public License
25 along with this program; if not, write to the Free Software
26 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
27 02111-1307, USA.
28
29 The GNU General Public License is contained in the file COPYING.
30*/
31
32#ifndef __HG_BASICS_H
33#define __HG_BASICS_H
34
35
36/*----------------------------------------------------------------*/
37/*--- Very basic stuff ---*/
38/*----------------------------------------------------------------*/
39
40#define HG_(str) VGAPPEND(vgHelgrind_,str)
41
florian19f91bb2012-11-10 22:29:54 +000042void* HG_(zalloc) ( const HChar* cc, SizeT n );
43void HG_(free) ( void* p );
44HChar* HG_(strdup) ( const HChar* cc, const HChar* s );
sewardjf98e1c02008-10-25 16:22:41 +000045
46static inline Bool HG_(is_sane_ThreadId) ( ThreadId coretid ) {
47 return coretid >= 0 && coretid < VG_N_THREADS;
48}
49
50
51/*----------------------------------------------------------------*/
52/*--- Command line options ---*/
53/*----------------------------------------------------------------*/
54
55/* Flags for controlling for which events sanity checking is done */
56#define SCE_THREADS (1<<0) // Sanity check at thread create/join
57#define SCE_LOCKS (1<<1) // Sanity check at lock events
58#define SCE_BIGRANGE (1<<2) // Sanity check at big mem range events
59#define SCE_ACCESS (1<<3) // Sanity check at mem accesses
60#define SCE_LAOG (1<<4) // Sanity check at significant LAOG events
61
62#define SCE_BIGRANGE_T 256 // big mem range minimum size
63
64
65/* Enable/disable lock order checking. Sometimes it produces a lot of
66 errors, possibly genuine, which nevertheless can be very
67 annoying. */
68extern Bool HG_(clo_track_lockorders);
69
70/* When comparing race errors for equality, should the race address be
71 taken into account? For users, no, but for verification purposes
72 (regtesting) this is sometimes important. */
73extern Bool HG_(clo_cmp_race_err_addrs);
74
sewardj23f12002009-07-24 08:45:08 +000075/* Controls how much history to collect, in order to show conflicting
76 accesses. There are three levels:
sewardj849b0ed2008-12-21 10:43:10 +000077
sewardj23f12002009-07-24 08:45:08 +000078 0: "none": don't collect any history. Fastest, but means we can
79 only show one of the two stacks in a race.
80
sewardjf3861392009-08-02 10:16:03 +000081 1: "approx": collect one stack trace per (notional) segment, that
sewardj23f12002009-07-24 08:45:08 +000082 is, collect a stack trace for a thread every time its vector
florianad4e9792015-07-05 21:53:33 +000083 clock changes. This facilitates showing the bounds of the
sewardj23f12002009-07-24 08:45:08 +000084 conflicting segment(s), with relatively small overhead.
85
86 2: "full": collect a stack trace every time the constraints for a
87 location change. This facilitates showing both stack traces in
88 a race, although can be very expensive in time and space
89 (depends on the rate that threads "drag" locations across
90 vector-clock-change boundaries ("dragovers"). This involves
91 collecting and storing large numbers of call stacks just in case
92 we might need to show them later, and so is expensive (although
93 very useful). */
94extern UWord HG_(clo_history_level);
95
96/* When doing "full" history collection, this determines the size of
97 the conflicting-access cache, measured in terms of maximum possible
98 number of elements in the previous-access map. Must be between 10k
99 amd 10 million. Default is 1 million. */
sewardj849b0ed2008-12-21 10:43:10 +0000100extern UWord HG_(clo_conflict_cache_size);
sewardjf98e1c02008-10-25 16:22:41 +0000101
102/* Sanity check level. This is an or-ing of
103 SCE_{THREADS,LOCKS,BIGRANGE,ACCESS,LAOG}. */
florian5e5cb002015-08-03 21:21:42 +0000104extern UWord HG_(clo_sanity_flags);
sewardjf98e1c02008-10-25 16:22:41 +0000105
sewardj622fe492011-03-11 21:06:59 +0000106/* Treat heap frees as if the memory was written immediately prior to
107 the free. This shakes out races in which memory is referenced by
108 one thread, and freed by another, and there's no observable
109 synchronisation event to guarantee that the reference happens
110 before the free. */
111extern Bool HG_(clo_free_is_write);
sewardjf98e1c02008-10-25 16:22:41 +0000112
sewardjffce8152011-06-24 10:09:41 +0000113/* Controls the application of VTS pruning. There are three levels:
114
115 0: "never": VTS pruning is never done
116
117 1: "auto": (the default): VTS pruning is sometimes done after VTS
118 GCs, just frequently enough to keep space use under control, as
119 determined by heuristics in libhb_core.c.
120
121 2: "always": VTS pruning is done after every VTS GC. This is
122 mostly a big time waster, but minimises space use. */
123extern UWord HG_(clo_vts_pruning);
124
125/* When False, race checking ignores memory references which are to
126 the stack, which speeds things up a bit. Default: True. */
127extern Bool HG_(clo_check_stack_refs);
128
sewardjf98e1c02008-10-25 16:22:41 +0000129#endif /* ! __HG_BASICS_H */
130
131/*--------------------------------------------------------------------*/
132/*--- end hg_basics.h ---*/
133/*--------------------------------------------------------------------*/