blob: 5cfd94cf80e649dd36a09bdd91e0f4194812b1e9 [file] [log] [blame]
sewardj024598e2008-09-18 14:43:05 +00001
2/*--------------------------------------------------------------------*/
3/*--- Ptrcheck: a pointer-use checker. ---*/
4/*--- This file coordinates the h_ and sg_ subtools. ---*/
5/*--- pc_main.c ---*/
6/*--------------------------------------------------------------------*/
7
8/*
9 This file is part of Ptrcheck, a Valgrind tool for checking pointer
10 use in programs.
11
sewardj03f8d3f2012-08-05 15:46:46 +000012 Copyright (C) 2008-2012 OpenWorks Ltd
sewardj024598e2008-09-18 14:43:05 +000013 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 Neither the names of the U.S. Department of Energy nor the
33 University of California nor the names of its contributors may be
34 used to endorse or promote products derived from this software
35 without prior written permission.
36*/
37
38#include "pub_tool_basics.h"
39#include "pub_tool_libcassert.h"
sewardj4815eb52008-10-20 23:33:49 +000040#include "pub_tool_libcprint.h"
sewardj024598e2008-09-18 14:43:05 +000041#include "pub_tool_execontext.h"
42#include "pub_tool_tooliface.h"
43#include "pub_tool_options.h"
44
sewardj024598e2008-09-18 14:43:05 +000045#include "sg_main.h"
46#include "pc_common.h"
47#include "h_main.h"
48
49
50//////////////////////////////////////////////////////////////
51// //
sewardj024598e2008-09-18 14:43:05 +000052// main //
53// //
54//////////////////////////////////////////////////////////////
55
sewardj024598e2008-09-18 14:43:05 +000056static void pc_pre_clo_init(void)
57{
njnf76d27a2009-05-28 01:53:07 +000058#if defined(VGO_darwin)
59 // This makes the (all-failing) regtests run much faster.
sewardjd2f95a02011-05-11 16:04:28 +000060 VG_(printf)("SGCheck doesn't work on Darwin yet, sorry.\n");
njnf76d27a2009-05-28 01:53:07 +000061 VG_(exit)(1);
62#endif
sewardjf5b019f2011-05-11 12:01:37 +000063#if defined(VGA_s390x)
64 /* fixs390: to be done. */
sewardjd2f95a02011-05-11 16:04:28 +000065 VG_(printf)("SGCheck doesn't work s390x yet, sorry.\n");
sewardjf5b019f2011-05-11 12:01:37 +000066 VG_(exit)(1);
67#endif
njnf76d27a2009-05-28 01:53:07 +000068
sewardjf5b019f2011-05-11 12:01:37 +000069 // Can't change the name until we change the names in suppressions
70 // too.
sewardjd2f95a02011-05-11 16:04:28 +000071 VG_(details_name) ("exp-sgcheck");
sewardj024598e2008-09-18 14:43:05 +000072 VG_(details_version) (NULL);
sewardjf5b019f2011-05-11 12:01:37 +000073 VG_(details_description) ("a stack and global array "
sewardj024598e2008-09-18 14:43:05 +000074 "overrun detector");
75 VG_(details_copyright_author)(
sewardj03f8d3f2012-08-05 15:46:46 +000076 "Copyright (C) 2003-2012, and GNU GPL'd, by OpenWorks Ltd et al.");
sewardj024598e2008-09-18 14:43:05 +000077 VG_(details_bug_reports_to) (VG_BUGS_TO);
sewardj4b8ce602008-10-20 10:23:46 +000078 VG_(details_avg_translation_sizeB) ( 496 );
sewardj024598e2008-09-18 14:43:05 +000079
sewardjf5b019f2011-05-11 12:01:37 +000080 VG_(basic_tool_funcs) (sg_post_clo_init,
sewardj024598e2008-09-18 14:43:05 +000081 h_instrument,
sewardjf5b019f2011-05-11 12:01:37 +000082 sg_fini);
sewardj024598e2008-09-18 14:43:05 +000083
84 VG_(needs_malloc_replacement)( h_replace_malloc,
85 h_replace___builtin_new,
86 h_replace___builtin_vec_new,
87 h_replace_memalign,
88 h_replace_calloc,
89 h_replace_free,
90 h_replace___builtin_delete,
91 h_replace___builtin_vec_delete,
92 h_replace_realloc,
njn8b140de2009-02-17 04:31:18 +000093 h_replace_malloc_usable_size,
sewardj024598e2008-09-18 14:43:05 +000094 0 /* no need for client heap redzones */ );
95
96 VG_(needs_var_info) ();
97
98 VG_(needs_core_errors) ();
99 VG_(needs_tool_errors) (pc_eq_Error,
sewardjc1bc9d12009-07-15 14:50:22 +0000100 pc_before_pp_Error,
sewardj024598e2008-09-18 14:43:05 +0000101 pc_pp_Error,
102 True,/*show TIDs for errors*/
103 pc_update_Error_extra,
104 pc_is_recognised_suppression,
105 pc_read_extra_suppression_info,
106 pc_error_matches_suppression,
107 pc_get_error_name,
sewardj588adef2009-08-15 22:41:51 +0000108 pc_get_extra_suppression_info);
sewardj024598e2008-09-18 14:43:05 +0000109
sewardjc1bc9d12009-07-15 14:50:22 +0000110 VG_(needs_xml_output) ();
111
sewardjf5b019f2011-05-11 12:01:37 +0000112 //VG_(needs_syscall_wrapper)( h_pre_syscall,
113 // h_post_syscall );
sewardj024598e2008-09-18 14:43:05 +0000114
115 VG_(needs_command_line_options)( pc_process_cmd_line_options,
116 pc_print_usage,
117 pc_print_debug_usage );
118
sewardjf5b019f2011-05-11 12:01:37 +0000119 VG_(track_die_mem_stack) ( sg_die_mem_stack );
120 VG_(track_pre_thread_ll_create) ( sg_pre_thread_ll_create );
121 VG_(track_pre_thread_first_insn)( sg_pre_thread_first_insn );
sewardj024598e2008-09-18 14:43:05 +0000122
sewardjf5b019f2011-05-11 12:01:37 +0000123 VG_(track_new_mem_mmap) ( sg_new_mem_mmap );
124 VG_(track_new_mem_startup) ( sg_new_mem_startup);
125 VG_(track_die_mem_munmap) ( sg_die_mem_munmap );
sewardj024598e2008-09-18 14:43:05 +0000126
sewardjf5b019f2011-05-11 12:01:37 +0000127 /* Really we ought to give handlers for these, to
128 check that syscalls don't read across array boundaries. */
129 /*
130 VG_(track_pre_mem_read) ( NULL );
131 VG_(track_pre_mem_read_asciiz) ( NULL );
132 VG_(track_pre_mem_write) ( NULL );
133 */
sewardj024598e2008-09-18 14:43:05 +0000134
sewardj024598e2008-09-18 14:43:05 +0000135 sg_pre_clo_init();
136
137 VG_(clo_vex_control).iropt_unroll_thresh = 0;
138 VG_(clo_vex_control).guest_chase_thresh = 0;
139}
140
141VG_DETERMINE_INTERFACE_VERSION(pc_pre_clo_init)
142
143
144/*--------------------------------------------------------------------*/
145/*--- end pc_main.c ---*/
146/*--------------------------------------------------------------------*/