1
2/*---------------------------------------------------------------------*/
3/*--- Address Description, used e.g. to describe addresses involved ---*/
4/*--- in race conditions, locks.                                    ---*/
5/*---                                                hg_addrdescr.h ---*/
6/*---------------------------------------------------------------------*/
7
8/*
9   This file is part of Helgrind, a Valgrind tool for detecting errors
10   in threaded programs.
11
12   Copyright (C) 2007-2012 OpenWorks Ltd
13      info@open-works.co.uk
14
15   This program is free software; you can redistribute it and/or
16   modify it under the terms of the GNU General Public License as
17   published by the Free Software Foundation; either version 2 of the
18   License, or (at your option) any later version.
19
20   This program is distributed in the hope that it will be useful, but
21   WITHOUT ANY WARRANTY; without even the implied warranty of
22   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
23   General Public License for more details.
24
25   You should have received a copy of the GNU General Public License
26   along with this program; if not, write to the Free Software
27   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
28   02111-1307, USA.
29
30   The GNU General Public License is contained in the file COPYING.
31*/
32
33#ifndef __HG_ADDRDESCR_H
34#define __HG_ADDRDESCR_H
35
36/* Describe an address as best you can, for error messages or
37   lock description, putting the result in ai.
38   This might allocate some memory in ai, to be cleared with
39   VG_(clear_addrinfo). */
40extern void HG_(describe_addr) ( Addr a, /*OUT*/AddrInfo* ai );
41
42/* Prints (using *print) the readable description of addr given in ai.
43   "what" identifies the type pointed to by addr (e.g. a lock). */
44extern void HG_(pp_addrdescr) (Bool xml, const HChar* what, Addr addr,
45                               AddrInfo* ai,
46                               void(*print)(const HChar *format, ...));
47
48/* Get a readable description of addr, then print it using HG_(pp_addrdescr)
49   using xml False and VG_(printf) to emit the characters.
50   Returns True if a description was found/printed, False otherwise. */
51extern Bool HG_(get_and_pp_addrdescr) (Addr a);
52
53/* For error creation/address description:
54   map 'data_addr' to a malloc'd chunk, if any.
55   Slow linear search accelerated in some special cases normal hash
56   search of the mallocmeta table. This is an abuse of the normal file
57   structure since this is exported by hg_main.c, not hg_addrdesc.c.  Oh
58   Well.  Returns True if found, False if not.  Zero-sized blocks are
59   considered to contain the searched-for address if they equal that
60   address. */
61Bool HG_(mm_find_containing_block)( /*OUT*/ExeContext** where,
62                                    /*OUT*/Addr*        payload,
63                                    /*OUT*/SizeT*       szB,
64                                    Addr                data_addr );
65
66
67#endif /* ! __HG_ADDRDESCR_H */
68
69/*--------------------------------------------------------------------*/
70/*--- end                                           hg_addrdescr.h ---*/
71/*--------------------------------------------------------------------*/
72