blob: 1492de313fc318ea8695fe7a3ca48f22b0712d31 [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
12 Copyright (C) 2008-2008 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 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"
40#include "pub_tool_execontext.h"
41#include "pub_tool_tooliface.h"
42#include "pub_tool_options.h"
43
44//#include "h_list.h" // Seg
45#include "sg_main.h"
46#include "pc_common.h"
47#include "h_main.h"
48
49
50//////////////////////////////////////////////////////////////
51// //
52// //
53// //
54//////////////////////////////////////////////////////////////
55
56
57//////////////////////////////////////////////////////////////
58// //
59// main //
60// //
61//////////////////////////////////////////////////////////////
62
63static void pc_fini ( Int exitcode ) {
64 h_fini( exitcode );
65 sg_fini( exitcode );
66}
67
68static void pc_die_mem_stack ( Addr old_SP, SizeT len ) {
69 /* h_die_mem_stack( old_SP, len ); */
70 sg_die_mem_stack( old_SP, len );
71}
72
73static
74void pc_pre_thread_ll_create ( ThreadId parent, ThreadId child ) {
75 /* h_pre_thread_ll_create(); */
76 sg_pre_thread_ll_create(parent,child);
77}
78
79static void pc_pre_thread_first_insn ( ThreadId tid ) {
80 /* h_pre_thread_first_insn(tid); */
81 sg_pre_thread_first_insn(tid);
82}
83
84static
85void pc_new_mem_mmap ( Addr a, SizeT len,
86 Bool rr, Bool ww, Bool xx, ULong di_handle )
87{
88 h_new_mem_mmap(a, len, rr, ww, xx, di_handle);
89 sg_new_mem_mmap(a, len, rr, ww, xx, di_handle);
90}
91
92static
93void pc_new_mem_startup ( Addr a, SizeT len,
94 Bool rr, Bool ww, Bool xx, ULong di_handle )
95{
96 h_new_mem_startup(a, len, rr, ww, xx, di_handle);
97 sg_new_mem_startup(a, len, rr, ww, xx, di_handle);
98}
99
100static void pc_die_mem_munmap ( Addr a, SizeT len ) {
101 h_die_mem_munmap(a, len);
102 sg_die_mem_munmap(a, len);
103}
104
105static void pc_pre_mem_read ( CorePart part, ThreadId tid, Char* s,
106 Addr base, SizeT size ) {
107 h_pre_mem_access(part, tid, s, base, size );
108 /* sg_pre_mem_read(part, tid, s, base, size); */
109}
110
111static void pc_pre_mem_read_asciiz ( CorePart part, ThreadId tid,
112 Char* s, Addr lo )
113{
114 h_pre_mem_read_asciiz(part, tid, s, lo);
115 /* sg_pre_mem_read_asciiz(part, tid, s, lo); */
116}
117
118static void pc_pre_mem_write ( CorePart part, ThreadId tid, Char* s,
119 Addr base, SizeT size ) {
120 h_pre_mem_access(part, tid, s, base, size);
121 /* sg_pre_mem_write(part, tid, s, base, size); */
122}
123
124static void pc_post_clo_init ( void )
125{
126 h_post_clo_init();
127 sg_post_clo_init();
128}
129
130static void pc_pre_clo_init(void)
131{
132 VG_(details_name) ("exp-ptrcheck");
133 VG_(details_version) (NULL);
134 VG_(details_description) ("a heap, stack & global array "
135 "overrun detector");
136 VG_(details_copyright_author)(
137 "Copyright (C) 2003-2008, and GNU GPL'd, by OpenWorks Ltd et al.");
138 VG_(details_bug_reports_to) (VG_BUGS_TO);
sewardj4b8ce602008-10-20 10:23:46 +0000139 VG_(details_avg_translation_sizeB) ( 496 );
sewardj024598e2008-09-18 14:43:05 +0000140
141 VG_(basic_tool_funcs) (pc_post_clo_init,
142 h_instrument,
143 pc_fini);
144
145 VG_(needs_malloc_replacement)( h_replace_malloc,
146 h_replace___builtin_new,
147 h_replace___builtin_vec_new,
148 h_replace_memalign,
149 h_replace_calloc,
150 h_replace_free,
151 h_replace___builtin_delete,
152 h_replace___builtin_vec_delete,
153 h_replace_realloc,
154 0 /* no need for client heap redzones */ );
155
156 VG_(needs_var_info) ();
157
158 VG_(needs_core_errors) ();
159 VG_(needs_tool_errors) (pc_eq_Error,
160 pc_pp_Error,
161 True,/*show TIDs for errors*/
162 pc_update_Error_extra,
163 pc_is_recognised_suppression,
164 pc_read_extra_suppression_info,
165 pc_error_matches_suppression,
166 pc_get_error_name,
167 pc_print_extra_suppression_info);
168
169 VG_(needs_syscall_wrapper)( h_pre_syscall,
170 h_post_syscall );
171
172 VG_(needs_command_line_options)( pc_process_cmd_line_options,
173 pc_print_usage,
174 pc_print_debug_usage );
175
176 VG_(track_die_mem_stack) ( pc_die_mem_stack );
177 VG_(track_pre_thread_ll_create) ( pc_pre_thread_ll_create );
178 VG_(track_pre_thread_first_insn)( pc_pre_thread_first_insn );
179
180 VG_(track_new_mem_mmap) ( pc_new_mem_mmap );
181 VG_(track_new_mem_startup) ( pc_new_mem_startup);
182 VG_(track_die_mem_munmap) ( pc_die_mem_munmap );
183
184 VG_(track_pre_mem_read) ( pc_pre_mem_read );
185 VG_(track_pre_mem_read_asciiz) ( pc_pre_mem_read_asciiz );
186 VG_(track_pre_mem_write) ( pc_pre_mem_write );
187
188 VG_(track_post_reg_write_clientcall_return) ( h_post_reg_write_clientcall );
189 VG_(track_post_reg_write)( h_post_reg_write_demux );
190
191 h_pre_clo_init();
192 sg_pre_clo_init();
193
194 VG_(clo_vex_control).iropt_unroll_thresh = 0;
195 VG_(clo_vex_control).guest_chase_thresh = 0;
196}
197
198VG_DETERMINE_INTERFACE_VERSION(pc_pre_clo_init)
199
200
201/*--------------------------------------------------------------------*/
202/*--- end pc_main.c ---*/
203/*--------------------------------------------------------------------*/