Home | History | Annotate | Download | only in helgrind
      1 
      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 
     11    Copyright (C) 2007-2010 OpenWorks Ltd
     12       info (at) 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 
     42 void* HG_(zalloc) ( HChar* cc, SizeT n );
     43 void  HG_(free)   ( void* p );
     44 Char* HG_(strdup) ( HChar* cc, const Char* s );
     45 
     46 static 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. */
     68 extern 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. */
     73 extern Bool HG_(clo_cmp_race_err_addrs);
     74 
     75 /* Controls how much history to collect, in order to show conflicting
     76    accesses.  There are three levels:
     77 
     78    0: "none": don't collect any history.  Fastest, but means we can
     79       only show one of the two stacks in a race.
     80 
     81    1: "approx": collect one stack trace per (notional) segment, that
     82       is, collect a stack trace for a thread every time its vector
     83       clock changes.  This faciliates showing the bounds of the
     84       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). */
     94 extern 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. */
    100 extern UWord HG_(clo_conflict_cache_size);
    101 
    102 /* Sanity check level.  This is an or-ing of
    103    SCE_{THREADS,LOCKS,BIGRANGE,ACCESS,LAOG}. */
    104 extern Word HG_(clo_sanity_flags);
    105 
    106 
    107 #endif /* ! __HG_BASICS_H */
    108 
    109 /*--------------------------------------------------------------------*/
    110 /*--- end                                              hg_basics.h ---*/
    111 /*--------------------------------------------------------------------*/
    112