Nicholas Nethercote 594c7fc446 This commit moves some skin-specific stuff out of core, and generally
neatens other things up.

Also, it adds the --gen-suppressions option for automatically generating
suppressions for each error.

Note that it changes the core/skin interface:
SK_(dup_extra_and_update)() is replaced by SK_(update_extra)(), and
SK_(get_error_name)() and SK_(print_extra_suppression_info)() are added.


-----------------------------------------------------------------------------
details
-----------------------------------------------------------------------------
Removed ac_common.c -- it just #included another .c file;  moved the
#include into ac_main.c.

Introduced "mac_" prefixes for files shared between Addrcheck and Memcheck,
to make it clearer which code is shared.  Also using a "MAC_" prefix for
functions and variables and types that are shared.  Addrcheck doesn't see
the "MC_" prefix at all.

Factored out almost-identical mc_describe_addr() and describe_addr()
(AddrCheck's version) into MAC_(describe_addr)().

Got rid of the "pp_ExeContext" closure passed to SK_(pp_SkinError)(), it
wasn't really necessary.

Introduced MAC_(pp_shared_SkinError)() for the error printing code shared by
Addrcheck and Memcheck.  Fixed some bogus stuff in Addrcheck error messages
about "uninitialised bytes" (there because of an imperfect conversion from
Memcheck).

Moved the leak checker out of core (vg_memory.c), into mac_leakcheck.c.
 - This meant the hacky way of recording Leak errors, which was different to
   normal errors, could be changed to something better:  introduced a
   function VG_(unique_error)(), which unlike VG_(maybe_record_error)() just
   prints the error (unless suppressed) but doesn't record it.  Used for
   leaks;  a much better solution all round as it allowed me to remove a lot
   of almost-identical code from leak handling (is_suppressible_leak(),
   leaksupp_matches_callers()).

 - As part of this, changed the horrible SK_(dup_extra_and_update) into the
   slightly less horrible SK_(update_extra), which returns the size of the
   `extra' part for the core to duplicate.

 - Also renamed it from VG_(generic_detect_memory_leaks)() to
   MAC_(do_detect_memory_leaks).  In making the code nicer w.r.t suppressions
   and error reporting, I tied it a bit more closely to Memcheck/Addrcheck,
   and got rid of some of the args.  It's not really "generic" any more, but
   then it never really was.  (This could be undone, but there doesn't seem
   to be much point.)

STREQ and STREQN were #defined in several places, and in two different ways.
Made global macros VG_STREQ, VG_CLO_STREQ and VG_CLO_STREQN in vg_skin.h.

Added the --gen-suppressions code.  This required adding the functions
SK_(get_error_name)() and SK_(print_extra_suppression_info)() for skins that
use the error handling need.

Added documentation for --gen-suppressions, and fixed some other minor document
problems.

Various other minor related changes too.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1517
2003-04-08 00:08:52 +00:00

163 lines
5.4 KiB
C

/*--------------------------------------------------------------------*/
/*--- A header file for all parts of the MemCheck skin. ---*/
/*--- mc_include.h ---*/
/*--------------------------------------------------------------------*/
/*
This file is part of MemCheck, a heavyweight Valgrind skin for
detecting memory errors.
Copyright (C) 2000-2002 Julian Seward
jseward@acm.org
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307, USA.
The GNU General Public License is contained in the file COPYING.
*/
/* Note: this header should contain declarations that are for use by
Memcheck only -- declarations shared with Addrcheck go in mac_shared.h.
*/
#ifndef __MC_INCLUDE_H
#define __MC_INCLUDE_H
#include "mac_shared.h"
#include "mc_constants.h"
/*------------------------------------------------------------*/
/*--- Types ---*/
/*------------------------------------------------------------*/
/* UCode extension for efficient memory checking operations */
typedef
enum {
/* uinstrs which are not needed for mere translation of x86 code,
only for instrumentation of it. */
LOADV = DUMMY_FINAL_UOPCODE + 1,
STOREV,
GETV,
PUTV,
TESTV,
SETV,
/* Get/set the v-bit (and it is only one bit) for the simulated
%eflags register. */
GETVF,
PUTVF,
/* Do a unary or binary tag op. Only for post-instrumented
code. For TAG1, first and only arg is a TempReg, and is both
arg and result reg. For TAG2, first arg is src, second is
dst, in the normal way; both are TempRegs. In both cases,
3rd arg is a RiCHelper with a Lit16 tag. This indicates
which tag op to do. */
TAG1,
TAG2
}
MemCheckOpcode;
/* Lists the names of value-tag operations used in instrumented
code. These are the third argument to TAG1 and TAG2 uinsns. */
typedef
enum {
/* Unary. */
Tag_PCast40, Tag_PCast20, Tag_PCast10,
Tag_PCast01, Tag_PCast02, Tag_PCast04,
Tag_PCast14, Tag_PCast12, Tag_PCast11,
Tag_Left4, Tag_Left2, Tag_Left1,
Tag_SWiden14, Tag_SWiden24, Tag_SWiden12,
Tag_ZWiden14, Tag_ZWiden24, Tag_ZWiden12,
/* Binary; 1st is rd; 2nd is rd+wr */
Tag_UifU4, Tag_UifU2, Tag_UifU1, Tag_UifU0,
Tag_DifD4, Tag_DifD2, Tag_DifD1,
Tag_ImproveAND4_TQ, Tag_ImproveAND2_TQ, Tag_ImproveAND1_TQ,
Tag_ImproveOR4_TQ, Tag_ImproveOR2_TQ, Tag_ImproveOR1_TQ,
Tag_DebugFn
}
TagOp;
/*------------------------------------------------------------*/
/*--- Command line options ---*/
/*------------------------------------------------------------*/
/* DEBUG: clean up instrumented code? default: YES */
extern Bool MC_(clo_cleanup);
/* When instrumenting, omit some checks if tell-tale literals for
inlined strlen() are visible in the basic block. default: YES */
extern Bool MC_(clo_avoid_strlen_errors);
/*------------------------------------------------------------*/
/*--- Functions ---*/
/*------------------------------------------------------------*/
/* Functions defined in vg_memcheck_helpers.S */
extern void MC_(helper_value_check4_fail) ( void );
extern void MC_(helper_value_check2_fail) ( void );
extern void MC_(helper_value_check1_fail) ( void );
extern void MC_(helper_value_check0_fail) ( void );
/* Functions defined in vg_memcheck.c */
extern void MC_(helperc_STOREV4) ( Addr, UInt );
extern void MC_(helperc_STOREV2) ( Addr, UInt );
extern void MC_(helperc_STOREV1) ( Addr, UInt );
extern UInt MC_(helperc_LOADV1) ( Addr );
extern UInt MC_(helperc_LOADV2) ( Addr );
extern UInt MC_(helperc_LOADV4) ( Addr );
extern void MC_(fpu_write_check) ( Addr addr, Int size );
extern void MC_(fpu_read_check) ( Addr addr, Int size );
/* For client requests */
extern void MC_(make_noaccess) ( Addr a, UInt len );
extern void MC_(make_readable) ( Addr a, UInt len );
extern void MC_(make_writable) ( Addr a, UInt len );
extern Bool MC_(check_writable) ( Addr a, UInt len, Addr* bad_addr );
extern Bool MC_(check_readable) ( Addr a, UInt len, Addr* bad_addr );
extern void MC_(detect_memory_leaks) ( void );
/* Functions defined in vg_memcheck_clientreqs.c */
extern Bool MC_(client_perm_maybe_describe)( Addr a, AddrInfo* ai );
extern void MC_(show_client_block_stats) ( void );
/* Functions defined in vg_memcheck_errcontext.c */
extern void MC_(record_value_error) ( Int size );
extern void MC_(record_user_error) ( ThreadState* tst, Addr a, Bool isWrite );
#endif
/*--------------------------------------------------------------------*/
/*--- end mc_include.h ---*/
/*--------------------------------------------------------------------*/