blob: 79c6fb536ed825027530d9f8709d315476985cdd [file] [log] [blame]
sewardjf98e1c02008-10-25 16:22:41 +00001
2/*--------------------------------------------------------------------*/
3/*--- Error management for Helgrind. ---*/
4/*--- hg_errors.h ---*/
5/*--------------------------------------------------------------------*/
6
7/*
8 This file is part of Helgrind, a Valgrind tool for detecting errors
9 in threaded programs.
10
sewardj03f8d3f2012-08-05 15:46:46 +000011 Copyright (C) 2007-2012 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_ERRORS_H
33#define __HG_ERRORS_H
34
35
36/* The standard bundle of error management functions that we are
37required to present to the core/tool interface at startup. */
sewardj24118492009-07-15 14:50:02 +000038Bool HG_(eq_Error) ( VgRes not_used, Error* e1, Error* e2 );
39void HG_(before_pp_Error) ( Error* err );
40void HG_(pp_Error) ( Error* err );
41UInt HG_(update_extra) ( Error* err );
florian19f91bb2012-11-10 22:29:54 +000042Bool HG_(recognised_suppression) ( const HChar* name, Supp *su );
43Bool HG_(read_extra_suppression_info) ( Int fd, HChar** bufpp, SizeT* nBufp,
sewardjf98e1c02008-10-25 16:22:41 +000044 Supp* su );
45Bool HG_(error_matches_suppression) ( Error* err, Supp* su );
floriane543f302012-10-21 19:43:43 +000046const HChar* HG_(get_error_name) ( Error* err );
sewardj588adef2009-08-15 22:41:51 +000047Bool HG_(get_extra_suppression_info) ( Error* err,
floriandbb35842012-10-27 18:39:11 +000048 /*OUT*/HChar* buf, Int nBuf );
sewardjf98e1c02008-10-25 16:22:41 +000049
50/* Functions for recording various kinds of errors. */
51void HG_(record_error_Race) ( Thread* thr,
sewardja781be62008-12-08 00:12:28 +000052 Addr data_addr, Int szB, Bool isWrite,
sewardj23f12002009-07-24 08:45:08 +000053 Thread* h1_confthr,
54 ExeContext* h1_ct_segstart,
55 ExeContext* h1_ct_mbsegend );
sewardjf98e1c02008-10-25 16:22:41 +000056void HG_(record_error_UnlockUnlocked) ( Thread*, Lock* );
57void HG_(record_error_UnlockForeign) ( Thread*, Thread*, Lock* );
58void HG_(record_error_UnlockBogus) ( Thread*, Addr );
florian6bd9dc12012-11-23 16:17:43 +000059void HG_(record_error_PthAPIerror) ( Thread*, const HChar*, Word,
60 const HChar* );
sewardjffce8152011-06-24 10:09:41 +000061
62/* see the implementation for meaning of these params */
sewardjf98e1c02008-10-25 16:22:41 +000063void HG_(record_error_LockOrder) ( Thread*, Addr, Addr,
sewardjffce8152011-06-24 10:09:41 +000064 ExeContext*, ExeContext*,
65 ExeContext* );
66
florian6bd9dc12012-11-23 16:17:43 +000067void HG_(record_error_Misc_w_aux) ( Thread*, const HChar* errstr,
68 const HChar* auxstr,
69 ExeContext* auxctx );
70void HG_(record_error_Misc) ( Thread* thr, const HChar* errstr );
sewardj8fef6252010-07-29 05:28:02 +000071
sewardjf98e1c02008-10-25 16:22:41 +000072
73/* Statistics pertaining to error management. */
74extern ULong HG_(stats__LockN_to_P_queries);
75extern ULong HG_(stats__LockN_to_P_get_map_size) ( void );
76extern ULong HG_(stats__string_table_queries);
77extern ULong HG_(stats__string_table_get_map_size) ( void );
78
sewardj095d61e2010-03-11 13:43:18 +000079/* For error creation: map 'data_addr' to a malloc'd chunk, if any.
sewardjc8028ad2010-05-05 09:34:42 +000080 Slow linear search accelerated in some special cases normal hash
81 search of the mallocmeta table. This is an abuse of the normal file
82 structure since this is exported by hg_main.c, not hg_errors.c. Oh
83 Well. Returns True if found, False if not. Zero-sized blocks are
84 considered to contain the searched-for address if they equal that
85 address. */
86Bool HG_(mm_find_containing_block)( /*OUT*/ExeContext** where,
sewardj095d61e2010-03-11 13:43:18 +000087 /*OUT*/Addr* payload,
88 /*OUT*/SizeT* szB,
89 Addr data_addr );
90
sewardjf98e1c02008-10-25 16:22:41 +000091#endif /* ! __HG_ERRORS_H */
92
93/*--------------------------------------------------------------------*/
94/*--- end hg_errors.h ---*/
95/*--------------------------------------------------------------------*/