njn | 810086f | 2002-11-14 12:42:47 +0000 | [diff] [blame] | 1 | |
| 2 | /*--------------------------------------------------------------------*/ |
nethercote | 7cc9c23 | 2004-01-21 15:08:04 +0000 | [diff] [blame] | 3 | /*--- Stuff relating to tool data structures. ---*/ |
sewardj | a765834 | 2005-05-17 13:43:54 +0000 | [diff] [blame] | 4 | /*--- m_tooliface.c ---*/ |
njn | 810086f | 2002-11-14 12:42:47 +0000 | [diff] [blame] | 5 | /*--------------------------------------------------------------------*/ |
| 6 | |
| 7 | /* |
njn | b9c427c | 2004-12-01 14:14:42 +0000 | [diff] [blame] | 8 | This file is part of Valgrind, a dynamic binary instrumentation |
| 9 | framework. |
njn | 810086f | 2002-11-14 12:42:47 +0000 | [diff] [blame] | 10 | |
sewardj | 4d474d0 | 2008-02-11 11:34:59 +0000 | [diff] [blame] | 11 | Copyright (C) 2000-2008 Nicholas Nethercote |
njn | 2bc1012 | 2005-05-08 02:10:27 +0000 | [diff] [blame] | 12 | njn@valgrind.org |
njn | 810086f | 2002-11-14 12:42:47 +0000 | [diff] [blame] | 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 | |
njn | c7561b9 | 2005-06-19 01:24:32 +0000 | [diff] [blame] | 32 | #include "pub_core_basics.h" |
njn | 4802b38 | 2005-06-11 04:58:29 +0000 | [diff] [blame] | 33 | #include "pub_core_tooliface.h" |
njn | 810086f | 2002-11-14 12:42:47 +0000 | [diff] [blame] | 34 | |
njn | 51d827b | 2005-05-09 01:02:08 +0000 | [diff] [blame] | 35 | // The core/tool dictionary of functions (initially zeroed, as we want it) |
| 36 | VgToolInterface VG_(tdict); |
njn | 810086f | 2002-11-14 12:42:47 +0000 | [diff] [blame] | 37 | |
njn | 8a97c6d | 2005-03-31 04:37:24 +0000 | [diff] [blame] | 38 | /*--------------------------------------------------------------------*/ |
| 39 | /* Setting basic functions */ |
| 40 | |
| 41 | void VG_(basic_tool_funcs)( |
| 42 | void(*post_clo_init)(void), |
sewardj | 0b9d74a | 2006-12-24 02:24:11 +0000 | [diff] [blame] | 43 | IRSB*(*instrument)(VgCallbackClosure*, IRSB*, |
sewardj | 461df9c | 2006-01-17 02:06:39 +0000 | [diff] [blame] | 44 | VexGuestLayout*, VexGuestExtents*, IRType, IRType), |
njn | 8a97c6d | 2005-03-31 04:37:24 +0000 | [diff] [blame] | 45 | void(*fini)(Int) |
| 46 | ) |
| 47 | { |
njn | cf81d55 | 2005-03-31 04:52:26 +0000 | [diff] [blame] | 48 | VG_(tdict).tool_post_clo_init = post_clo_init; |
| 49 | VG_(tdict).tool_instrument = instrument; |
| 50 | VG_(tdict).tool_fini = fini; |
njn | 8a97c6d | 2005-03-31 04:37:24 +0000 | [diff] [blame] | 51 | } |
| 52 | |
njn | 51d827b | 2005-05-09 01:02:08 +0000 | [diff] [blame] | 53 | |
njn | 8a97c6d | 2005-03-31 04:37:24 +0000 | [diff] [blame] | 54 | /*--------------------------------------------------------------------*/ |
| 55 | /* Setting details */ |
| 56 | |
njn | 810086f | 2002-11-14 12:42:47 +0000 | [diff] [blame] | 57 | /* Init with default values. */ |
| 58 | VgDetails VG_(details) = { |
sewardj | c0d8f68 | 2002-11-30 00:49:43 +0000 | [diff] [blame] | 59 | .name = NULL, |
| 60 | .version = NULL, |
| 61 | .description = NULL, |
| 62 | .copyright_author = NULL, |
| 63 | .bug_reports_to = NULL, |
njn | 120281f | 2003-02-03 12:20:07 +0000 | [diff] [blame] | 64 | .avg_translation_sizeB = VG_DEFAULT_TRANS_SIZEB, |
njn | 810086f | 2002-11-14 12:42:47 +0000 | [diff] [blame] | 65 | }; |
| 66 | |
njn | 8a97c6d | 2005-03-31 04:37:24 +0000 | [diff] [blame] | 67 | /* Use macro because they're so repetitive */ |
| 68 | #define DETAILS(type, detail) \ |
| 69 | extern void VG_(details_##detail)(type detail) \ |
| 70 | { \ |
| 71 | VG_(details).detail = detail; \ |
| 72 | } |
| 73 | |
| 74 | DETAILS(Char*, name) |
| 75 | DETAILS(Char*, version) |
| 76 | DETAILS(Char*, description) |
| 77 | DETAILS(Char*, copyright_author) |
| 78 | DETAILS(Char*, bug_reports_to) |
| 79 | DETAILS(UInt, avg_translation_sizeB) |
| 80 | |
njn | 51d827b | 2005-05-09 01:02:08 +0000 | [diff] [blame] | 81 | |
njn | 8a97c6d | 2005-03-31 04:37:24 +0000 | [diff] [blame] | 82 | /*--------------------------------------------------------------------*/ |
| 83 | /* Setting needs */ |
| 84 | |
njn | 810086f | 2002-11-14 12:42:47 +0000 | [diff] [blame] | 85 | VgNeeds VG_(needs) = { |
| 86 | .core_errors = False, |
njn | 95ec870 | 2004-11-22 16:46:13 +0000 | [diff] [blame] | 87 | .tool_errors = False, |
njn | 810086f | 2002-11-14 12:42:47 +0000 | [diff] [blame] | 88 | .libc_freeres = False, |
sewardj | 0b9d74a | 2006-12-24 02:24:11 +0000 | [diff] [blame] | 89 | .superblock_discards = False, |
njn | 810086f | 2002-11-14 12:42:47 +0000 | [diff] [blame] | 90 | .command_line_options = False, |
| 91 | .client_requests = False, |
njn | 810086f | 2002-11-14 12:42:47 +0000 | [diff] [blame] | 92 | .syscall_wrapper = False, |
njn | 810086f | 2002-11-14 12:42:47 +0000 | [diff] [blame] | 93 | .sanity_checks = False, |
sewardj | b8b79ad | 2008-03-03 01:35:41 +0000 | [diff] [blame] | 94 | .var_info = False, |
njn | fc51f8d | 2005-06-21 03:20:17 +0000 | [diff] [blame] | 95 | .malloc_replacement = False, |
njn | ca54af3 | 2006-04-16 10:25:43 +0000 | [diff] [blame] | 96 | .xml_output = False, |
sewardj | 81651dc | 2007-08-28 06:05:20 +0000 | [diff] [blame] | 97 | .final_IR_tidy_pass = False |
njn | 810086f | 2002-11-14 12:42:47 +0000 | [diff] [blame] | 98 | }; |
| 99 | |
| 100 | /* static */ |
sewardj | 45f4e7c | 2005-09-27 19:20:21 +0000 | [diff] [blame] | 101 | Bool VG_(sanity_check_needs)(Char** failmsg) |
njn | 810086f | 2002-11-14 12:42:47 +0000 | [diff] [blame] | 102 | { |
sewardj | 7cf4e6b | 2008-05-01 20:24:26 +0000 | [diff] [blame] | 103 | Bool any_new_mem_stack_N, any_new_mem_stack_N_w_ECU; |
| 104 | Bool any_new_mem_stack_w_conflicting_otags; |
| 105 | Bool any_die_mem_stack_N; |
| 106 | |
njn | 64c8324 | 2005-06-21 01:54:38 +0000 | [diff] [blame] | 107 | #define CHECK_NOT(var, value) \ |
| 108 | if ((var)==(value)) { \ |
sewardj | 7cf4e6b | 2008-05-01 20:24:26 +0000 | [diff] [blame] | 109 | *failmsg = "Tool error: '" #var "' not initialised\n"; \ |
njn | 64c8324 | 2005-06-21 01:54:38 +0000 | [diff] [blame] | 110 | return False; \ |
njn | 810086f | 2002-11-14 12:42:47 +0000 | [diff] [blame] | 111 | } |
| 112 | |
njn | 120281f | 2003-02-03 12:20:07 +0000 | [diff] [blame] | 113 | /* Ones that must be set */ |
njn | 810086f | 2002-11-14 12:42:47 +0000 | [diff] [blame] | 114 | CHECK_NOT(VG_(details).name, NULL); |
| 115 | /* Nb: .version can be NULL */ |
| 116 | CHECK_NOT(VG_(details).description, NULL); |
| 117 | CHECK_NOT(VG_(details).copyright_author, NULL); |
| 118 | CHECK_NOT(VG_(details).bug_reports_to, NULL); |
| 119 | |
sewardj | 7cf4e6b | 2008-05-01 20:24:26 +0000 | [diff] [blame] | 120 | /* Check that new_mem_stack is defined if any new_mem_stack_N |
| 121 | are. */ |
| 122 | any_new_mem_stack_N |
| 123 | = VG_(tdict).track_new_mem_stack_4 || |
| 124 | VG_(tdict).track_new_mem_stack_8 || |
| 125 | VG_(tdict).track_new_mem_stack_12 || |
| 126 | VG_(tdict).track_new_mem_stack_16 || |
| 127 | VG_(tdict).track_new_mem_stack_32 || |
| 128 | VG_(tdict).track_new_mem_stack_112 || |
| 129 | VG_(tdict).track_new_mem_stack_128 || |
| 130 | VG_(tdict).track_new_mem_stack_144 || |
| 131 | VG_(tdict).track_new_mem_stack_160; |
| 132 | |
| 133 | if (any_new_mem_stack_N && ! VG_(tdict).track_new_mem_stack) { |
| 134 | *failmsg = "Tool error: one of the specialised 'new_mem_stack_N'\n" |
njn | 64c8324 | 2005-06-21 01:54:38 +0000 | [diff] [blame] | 135 | " events tracked, but not the generic 'new_mem_stack' one.\n" |
| 136 | " 'new_mem_stack' should be defined\n"; |
| 137 | return False; |
njn | 9b007f6 | 2003-04-07 14:40:25 +0000 | [diff] [blame] | 138 | } |
| 139 | |
sewardj | 7cf4e6b | 2008-05-01 20:24:26 +0000 | [diff] [blame] | 140 | /* Check that new_mem_stack_w_ECU is defined if any |
| 141 | new_mem_stack_N_w_ECU are. */ |
| 142 | any_new_mem_stack_N_w_ECU |
| 143 | = VG_(tdict).track_new_mem_stack_4_w_ECU || |
| 144 | VG_(tdict).track_new_mem_stack_8_w_ECU || |
| 145 | VG_(tdict).track_new_mem_stack_12_w_ECU || |
| 146 | VG_(tdict).track_new_mem_stack_16_w_ECU || |
| 147 | VG_(tdict).track_new_mem_stack_32_w_ECU || |
| 148 | VG_(tdict).track_new_mem_stack_112_w_ECU || |
| 149 | VG_(tdict).track_new_mem_stack_128_w_ECU || |
| 150 | VG_(tdict).track_new_mem_stack_144_w_ECU || |
| 151 | VG_(tdict).track_new_mem_stack_160_w_ECU; |
| 152 | |
| 153 | if (any_new_mem_stack_N_w_ECU && ! VG_(tdict).track_new_mem_stack_w_ECU) { |
| 154 | *failmsg = "Tool error: one of the specialised 'new_mem_stack_N_w_ECU'\n" |
| 155 | " events tracked, but not the generic 'new_mem_stack_w_ECU' one.\n" |
| 156 | " 'new_mem_stack_w_ECU' should be defined\n"; |
| 157 | return False; |
| 158 | } |
| 159 | |
| 160 | /* Check that in no cases are both with- and without-otag versions of the |
| 161 | same new_mem_stack_ function defined. */ |
| 162 | any_new_mem_stack_w_conflicting_otags |
| 163 | = (VG_(tdict).track_new_mem_stack_4 && VG_(tdict).track_new_mem_stack_4_w_ECU) || |
| 164 | (VG_(tdict).track_new_mem_stack_8 && VG_(tdict).track_new_mem_stack_8_w_ECU) || |
| 165 | (VG_(tdict).track_new_mem_stack_12 && VG_(tdict).track_new_mem_stack_12_w_ECU) || |
| 166 | (VG_(tdict).track_new_mem_stack_16 && VG_(tdict).track_new_mem_stack_16_w_ECU) || |
| 167 | (VG_(tdict).track_new_mem_stack_32 && VG_(tdict).track_new_mem_stack_32_w_ECU) || |
| 168 | (VG_(tdict).track_new_mem_stack_112 && VG_(tdict).track_new_mem_stack_112_w_ECU) || |
| 169 | (VG_(tdict).track_new_mem_stack_128 && VG_(tdict).track_new_mem_stack_128_w_ECU) || |
| 170 | (VG_(tdict).track_new_mem_stack_144 && VG_(tdict).track_new_mem_stack_144_w_ECU) || |
| 171 | (VG_(tdict).track_new_mem_stack_160 && VG_(tdict).track_new_mem_stack_160_w_ECU) || |
| 172 | (VG_(tdict).track_new_mem_stack && VG_(tdict).track_new_mem_stack_w_ECU); |
| 173 | |
| 174 | if (any_new_mem_stack_w_conflicting_otags) { |
| 175 | *failmsg = "Tool error: tool supplies both a 'new_mem_stack_N' and a\n" |
| 176 | " 'new_mem_stack_N_w_ECU' function for some N (or none),\n" |
| 177 | " but you can only have one or the other (not both)\n"; |
| 178 | return False; |
| 179 | } |
| 180 | |
| 181 | /* Check that die_mem_stack is defined if any die_mem_stack_N |
| 182 | are. */ |
| 183 | any_die_mem_stack_N |
| 184 | = VG_(tdict).track_die_mem_stack_4 || |
| 185 | VG_(tdict).track_die_mem_stack_8 || |
| 186 | VG_(tdict).track_die_mem_stack_12 || |
| 187 | VG_(tdict).track_die_mem_stack_16 || |
| 188 | VG_(tdict).track_die_mem_stack_32 || |
| 189 | VG_(tdict).track_die_mem_stack_112 || |
| 190 | VG_(tdict).track_die_mem_stack_128 || |
| 191 | VG_(tdict).track_die_mem_stack_144 || |
| 192 | VG_(tdict).track_die_mem_stack_160; |
| 193 | |
| 194 | if (any_die_mem_stack_N && ! VG_(tdict).track_die_mem_stack) { |
| 195 | *failmsg = "Tool error: one of the specialised 'die_mem_stack_N'\n" |
njn | 64c8324 | 2005-06-21 01:54:38 +0000 | [diff] [blame] | 196 | " events tracked, but not the generic 'die_mem_stack' one.\n" |
| 197 | " 'die_mem_stack' should be defined\n"; |
| 198 | return False; |
njn | 9b007f6 | 2003-04-07 14:40:25 +0000 | [diff] [blame] | 199 | } |
| 200 | |
njn | 64c8324 | 2005-06-21 01:54:38 +0000 | [diff] [blame] | 201 | return True; |
| 202 | |
njn | 810086f | 2002-11-14 12:42:47 +0000 | [diff] [blame] | 203 | #undef CHECK_NOT |
njn | 810086f | 2002-11-14 12:42:47 +0000 | [diff] [blame] | 204 | } |
| 205 | |
njn | 810086f | 2002-11-14 12:42:47 +0000 | [diff] [blame] | 206 | /* Use macro because they're so repetitive */ |
| 207 | #define NEEDS(need) \ |
| 208 | extern void VG_(needs_##need)(void) \ |
| 209 | { \ |
| 210 | VG_(needs).need = True; \ |
| 211 | } |
| 212 | |
njn | 8a97c6d | 2005-03-31 04:37:24 +0000 | [diff] [blame] | 213 | // These ones don't require any tool-supplied functions |
njn | 810086f | 2002-11-14 12:42:47 +0000 | [diff] [blame] | 214 | NEEDS(libc_freeres) |
| 215 | NEEDS(core_errors) |
sewardj | b8b79ad | 2008-03-03 01:35:41 +0000 | [diff] [blame] | 216 | NEEDS(var_info) |
njn | ca54af3 | 2006-04-16 10:25:43 +0000 | [diff] [blame] | 217 | NEEDS(xml_output) |
njn | fdc28af | 2003-02-24 10:36:48 +0000 | [diff] [blame] | 218 | |
sewardj | 0b9d74a | 2006-12-24 02:24:11 +0000 | [diff] [blame] | 219 | void VG_(needs_superblock_discards)( |
sewardj | 4ba057c | 2005-10-18 12:04:18 +0000 | [diff] [blame] | 220 | void (*discard)(Addr64, VexGuestExtents) |
njn | 8a97c6d | 2005-03-31 04:37:24 +0000 | [diff] [blame] | 221 | ) |
| 222 | { |
sewardj | 0b9d74a | 2006-12-24 02:24:11 +0000 | [diff] [blame] | 223 | VG_(needs).superblock_discards = True; |
| 224 | VG_(tdict).tool_discard_superblock_info = discard; |
njn | 8a97c6d | 2005-03-31 04:37:24 +0000 | [diff] [blame] | 225 | } |
| 226 | |
| 227 | void VG_(needs_tool_errors)( |
| 228 | Bool (*eq) (VgRes, Error*, Error*), |
| 229 | void (*pp) (Error*), |
sewardj | adb102f | 2007-11-09 23:21:44 +0000 | [diff] [blame] | 230 | Bool show_TIDs, |
njn | 8a97c6d | 2005-03-31 04:37:24 +0000 | [diff] [blame] | 231 | UInt (*update) (Error*), |
| 232 | Bool (*recog) (Char*, Supp*), |
| 233 | Bool (*read_extra) (Int, Char*, Int, Supp*), |
| 234 | Bool (*matches) (Error*, Supp*), |
| 235 | Char* (*name) (Error*), |
| 236 | void (*print_extra)(Error*) |
| 237 | ) |
| 238 | { |
| 239 | VG_(needs).tool_errors = True; |
njn | cf81d55 | 2005-03-31 04:52:26 +0000 | [diff] [blame] | 240 | VG_(tdict).tool_eq_Error = eq; |
| 241 | VG_(tdict).tool_pp_Error = pp; |
sewardj | adb102f | 2007-11-09 23:21:44 +0000 | [diff] [blame] | 242 | VG_(tdict).tool_show_ThreadIDs_for_errors = show_TIDs; |
njn | cf81d55 | 2005-03-31 04:52:26 +0000 | [diff] [blame] | 243 | VG_(tdict).tool_update_extra = update; |
| 244 | VG_(tdict).tool_recognised_suppression = recog; |
| 245 | VG_(tdict).tool_read_extra_suppression_info = read_extra; |
| 246 | VG_(tdict).tool_error_matches_suppression = matches; |
| 247 | VG_(tdict).tool_get_error_name = name; |
| 248 | VG_(tdict).tool_print_extra_suppression_info = print_extra; |
njn | 8a97c6d | 2005-03-31 04:37:24 +0000 | [diff] [blame] | 249 | } |
| 250 | |
| 251 | void VG_(needs_command_line_options)( |
| 252 | Bool (*process)(Char*), |
| 253 | void (*usage)(void), |
| 254 | void (*debug_usage)(void) |
| 255 | ) |
| 256 | { |
| 257 | VG_(needs).command_line_options = True; |
njn | cf81d55 | 2005-03-31 04:52:26 +0000 | [diff] [blame] | 258 | VG_(tdict).tool_process_cmd_line_option = process; |
| 259 | VG_(tdict).tool_print_usage = usage; |
| 260 | VG_(tdict).tool_print_debug_usage = debug_usage; |
njn | 8a97c6d | 2005-03-31 04:37:24 +0000 | [diff] [blame] | 261 | } |
| 262 | |
| 263 | void VG_(needs_client_requests)( |
| 264 | Bool (*handle)(ThreadId, UWord*, UWord*) |
| 265 | ) |
| 266 | { |
| 267 | VG_(needs).client_requests = True; |
njn | cf81d55 | 2005-03-31 04:52:26 +0000 | [diff] [blame] | 268 | VG_(tdict).tool_handle_client_request = handle; |
njn | 8a97c6d | 2005-03-31 04:37:24 +0000 | [diff] [blame] | 269 | } |
| 270 | |
| 271 | void VG_(needs_syscall_wrapper)( |
| 272 | void(*pre) (ThreadId, UInt), |
sewardj | a8d8e23 | 2005-06-07 20:04:56 +0000 | [diff] [blame] | 273 | void(*post)(ThreadId, UInt, SysRes res) |
njn | 8a97c6d | 2005-03-31 04:37:24 +0000 | [diff] [blame] | 274 | ) |
| 275 | { |
| 276 | VG_(needs).syscall_wrapper = True; |
njn | cf81d55 | 2005-03-31 04:52:26 +0000 | [diff] [blame] | 277 | VG_(tdict).tool_pre_syscall = pre; |
| 278 | VG_(tdict).tool_post_syscall = post; |
njn | 8a97c6d | 2005-03-31 04:37:24 +0000 | [diff] [blame] | 279 | } |
| 280 | |
| 281 | void VG_(needs_sanity_checks)( |
| 282 | Bool(*cheap)(void), |
| 283 | Bool(*expen)(void) |
| 284 | ) |
| 285 | { |
| 286 | VG_(needs).sanity_checks = True; |
njn | cf81d55 | 2005-03-31 04:52:26 +0000 | [diff] [blame] | 287 | VG_(tdict).tool_cheap_sanity_check = cheap; |
| 288 | VG_(tdict).tool_expensive_sanity_check = expen; |
njn | 8a97c6d | 2005-03-31 04:37:24 +0000 | [diff] [blame] | 289 | } |
| 290 | |
njn | fc51f8d | 2005-06-21 03:20:17 +0000 | [diff] [blame] | 291 | void VG_(needs_malloc_replacement)( |
njn | 8a97c6d | 2005-03-31 04:37:24 +0000 | [diff] [blame] | 292 | void* (*malloc) ( ThreadId, SizeT ), |
| 293 | void* (*__builtin_new) ( ThreadId, SizeT ), |
| 294 | void* (*__builtin_vec_new) ( ThreadId, SizeT ), |
| 295 | void* (*memalign) ( ThreadId, SizeT, SizeT ), |
| 296 | void* (*calloc) ( ThreadId, SizeT, SizeT ), |
| 297 | void (*free) ( ThreadId, void* ), |
| 298 | void (*__builtin_delete) ( ThreadId, void* ), |
| 299 | void (*__builtin_vec_delete) ( ThreadId, void* ), |
| 300 | void* (*realloc) ( ThreadId, void*, SizeT ), |
| 301 | SizeT client_malloc_redzone_szB |
| 302 | ) |
| 303 | { |
njn | fc51f8d | 2005-06-21 03:20:17 +0000 | [diff] [blame] | 304 | VG_(needs).malloc_replacement = True; |
| 305 | VG_(tdict).tool_malloc = malloc; |
| 306 | VG_(tdict).tool___builtin_new = __builtin_new; |
| 307 | VG_(tdict).tool___builtin_vec_new = __builtin_vec_new; |
| 308 | VG_(tdict).tool_memalign = memalign; |
| 309 | VG_(tdict).tool_calloc = calloc; |
| 310 | VG_(tdict).tool_free = free; |
| 311 | VG_(tdict).tool___builtin_delete = __builtin_delete; |
| 312 | VG_(tdict).tool___builtin_vec_delete = __builtin_vec_delete; |
| 313 | VG_(tdict).tool_realloc = realloc; |
| 314 | VG_(tdict).tool_client_redzone_szB = client_malloc_redzone_szB; |
njn | 8a97c6d | 2005-03-31 04:37:24 +0000 | [diff] [blame] | 315 | } |
| 316 | |
sewardj | 81651dc | 2007-08-28 06:05:20 +0000 | [diff] [blame] | 317 | void VG_(needs_final_IR_tidy_pass)( |
| 318 | IRSB*(*final_tidy)(IRSB*) |
| 319 | ) |
| 320 | { |
| 321 | VG_(needs).final_IR_tidy_pass = True; |
| 322 | VG_(tdict).tool_final_IR_tidy_pass = final_tidy; |
| 323 | } |
njn | 51d827b | 2005-05-09 01:02:08 +0000 | [diff] [blame] | 324 | |
njn | 810086f | 2002-11-14 12:42:47 +0000 | [diff] [blame] | 325 | /*--------------------------------------------------------------------*/ |
sewardj | 7cf4e6b | 2008-05-01 20:24:26 +0000 | [diff] [blame] | 326 | /* Tracked events. Digit 'n' on DEFn is the REGPARMness. */ |
njn | 51d827b | 2005-05-09 01:02:08 +0000 | [diff] [blame] | 327 | |
sewardj | 7cf4e6b | 2008-05-01 20:24:26 +0000 | [diff] [blame] | 328 | #define DEF0(fn, args...) \ |
| 329 | void VG_(fn)(void(*f)(args)) { \ |
| 330 | VG_(tdict).fn = f; \ |
| 331 | } |
| 332 | |
| 333 | #define DEF1(fn, args...) \ |
| 334 | void VG_(fn)(VG_REGPARM(1) void(*f)(args)) { \ |
njn | 51d827b | 2005-05-09 01:02:08 +0000 | [diff] [blame] | 335 | VG_(tdict).fn = f; \ |
| 336 | } |
| 337 | |
| 338 | #define DEF2(fn, args...) \ |
sewardj | 7cf4e6b | 2008-05-01 20:24:26 +0000 | [diff] [blame] | 339 | void VG_(fn)(VG_REGPARM(2) void(*f)(args)) { \ |
njn | 51d827b | 2005-05-09 01:02:08 +0000 | [diff] [blame] | 340 | VG_(tdict).fn = f; \ |
| 341 | } |
| 342 | |
sewardj | 9c606bd | 2008-09-18 18:12:50 +0000 | [diff] [blame] | 343 | DEF0(track_new_mem_startup, Addr, SizeT, Bool, Bool, Bool, ULong) |
sewardj | 7cf4e6b | 2008-05-01 20:24:26 +0000 | [diff] [blame] | 344 | DEF0(track_new_mem_stack_signal, Addr, SizeT, UInt) |
| 345 | DEF0(track_new_mem_brk, Addr, SizeT, UInt) |
sewardj | 9c606bd | 2008-09-18 18:12:50 +0000 | [diff] [blame] | 346 | DEF0(track_new_mem_mmap, Addr, SizeT, Bool, Bool, Bool, ULong) |
njn | 51d827b | 2005-05-09 01:02:08 +0000 | [diff] [blame] | 347 | |
sewardj | 7cf4e6b | 2008-05-01 20:24:26 +0000 | [diff] [blame] | 348 | DEF0(track_copy_mem_remap, Addr, Addr, SizeT) |
| 349 | DEF0(track_change_mem_mprotect, Addr, SizeT, Bool, Bool, Bool) |
| 350 | DEF0(track_die_mem_stack_signal, Addr, SizeT) |
| 351 | DEF0(track_die_mem_brk, Addr, SizeT) |
| 352 | DEF0(track_die_mem_munmap, Addr, SizeT) |
njn | 51d827b | 2005-05-09 01:02:08 +0000 | [diff] [blame] | 353 | |
sewardj | 7cf4e6b | 2008-05-01 20:24:26 +0000 | [diff] [blame] | 354 | DEF2(track_new_mem_stack_4_w_ECU, Addr, UInt) |
| 355 | DEF2(track_new_mem_stack_8_w_ECU, Addr, UInt) |
| 356 | DEF2(track_new_mem_stack_12_w_ECU, Addr, UInt) |
| 357 | DEF2(track_new_mem_stack_16_w_ECU, Addr, UInt) |
| 358 | DEF2(track_new_mem_stack_32_w_ECU, Addr, UInt) |
| 359 | DEF2(track_new_mem_stack_112_w_ECU, Addr, UInt) |
| 360 | DEF2(track_new_mem_stack_128_w_ECU, Addr, UInt) |
| 361 | DEF2(track_new_mem_stack_144_w_ECU, Addr, UInt) |
| 362 | DEF2(track_new_mem_stack_160_w_ECU, Addr, UInt) |
| 363 | DEF0(track_new_mem_stack_w_ECU, Addr, SizeT, UInt) |
njn | 51d827b | 2005-05-09 01:02:08 +0000 | [diff] [blame] | 364 | |
sewardj | 7cf4e6b | 2008-05-01 20:24:26 +0000 | [diff] [blame] | 365 | DEF1(track_new_mem_stack_4, Addr) |
| 366 | DEF1(track_new_mem_stack_8, Addr) |
| 367 | DEF1(track_new_mem_stack_12, Addr) |
| 368 | DEF1(track_new_mem_stack_16, Addr) |
| 369 | DEF1(track_new_mem_stack_32, Addr) |
| 370 | DEF1(track_new_mem_stack_112, Addr) |
| 371 | DEF1(track_new_mem_stack_128, Addr) |
| 372 | DEF1(track_new_mem_stack_144, Addr) |
| 373 | DEF1(track_new_mem_stack_160, Addr) |
| 374 | DEF0(track_new_mem_stack, Addr, SizeT) |
njn | 51d827b | 2005-05-09 01:02:08 +0000 | [diff] [blame] | 375 | |
sewardj | 7cf4e6b | 2008-05-01 20:24:26 +0000 | [diff] [blame] | 376 | DEF1(track_die_mem_stack_4, Addr) |
| 377 | DEF1(track_die_mem_stack_8, Addr) |
| 378 | DEF1(track_die_mem_stack_12, Addr) |
| 379 | DEF1(track_die_mem_stack_16, Addr) |
| 380 | DEF1(track_die_mem_stack_32, Addr) |
| 381 | DEF1(track_die_mem_stack_112, Addr) |
| 382 | DEF1(track_die_mem_stack_128, Addr) |
| 383 | DEF1(track_die_mem_stack_144, Addr) |
| 384 | DEF1(track_die_mem_stack_160, Addr) |
| 385 | DEF0(track_die_mem_stack, Addr, SizeT) |
njn | 51d827b | 2005-05-09 01:02:08 +0000 | [diff] [blame] | 386 | |
sewardj | 7cf4e6b | 2008-05-01 20:24:26 +0000 | [diff] [blame] | 387 | DEF0(track_ban_mem_stack, Addr, SizeT) |
njn | 51d827b | 2005-05-09 01:02:08 +0000 | [diff] [blame] | 388 | |
sewardj | 7cf4e6b | 2008-05-01 20:24:26 +0000 | [diff] [blame] | 389 | DEF0(track_pre_mem_read, CorePart, ThreadId, Char*, Addr, SizeT) |
| 390 | DEF0(track_pre_mem_read_asciiz, CorePart, ThreadId, Char*, Addr) |
| 391 | DEF0(track_pre_mem_write, CorePart, ThreadId, Char*, Addr, SizeT) |
| 392 | DEF0(track_post_mem_write, CorePart, ThreadId, Addr, SizeT) |
njn | 51d827b | 2005-05-09 01:02:08 +0000 | [diff] [blame] | 393 | |
sewardj | 7cf4e6b | 2008-05-01 20:24:26 +0000 | [diff] [blame] | 394 | DEF0(track_pre_reg_read, CorePart, ThreadId, Char*, OffT, SizeT) |
| 395 | DEF0(track_post_reg_write, CorePart, ThreadId, OffT, SizeT) |
njn | 51d827b | 2005-05-09 01:02:08 +0000 | [diff] [blame] | 396 | |
sewardj | 7cf4e6b | 2008-05-01 20:24:26 +0000 | [diff] [blame] | 397 | DEF0(track_post_reg_write_clientcall_return, ThreadId, OffT, SizeT, Addr) |
njn | 51d827b | 2005-05-09 01:02:08 +0000 | [diff] [blame] | 398 | |
sewardj | 7cf4e6b | 2008-05-01 20:24:26 +0000 | [diff] [blame] | 399 | DEF0(track_start_client_code, ThreadId, ULong) |
| 400 | DEF0(track_stop_client_code, ThreadId, ULong) |
njn | 51d827b | 2005-05-09 01:02:08 +0000 | [diff] [blame] | 401 | |
sewardj | 7cf4e6b | 2008-05-01 20:24:26 +0000 | [diff] [blame] | 402 | DEF0(track_pre_thread_ll_create, ThreadId, ThreadId) |
| 403 | DEF0(track_pre_thread_first_insn, ThreadId) |
| 404 | DEF0(track_pre_thread_ll_exit, ThreadId) |
| 405 | |
| 406 | DEF0(track_pre_deliver_signal, ThreadId, Int sigNo, Bool) |
| 407 | DEF0(track_post_deliver_signal, ThreadId, Int sigNo) |
njn | 51d827b | 2005-05-09 01:02:08 +0000 | [diff] [blame] | 408 | |
njn | 51d827b | 2005-05-09 01:02:08 +0000 | [diff] [blame] | 409 | /*--------------------------------------------------------------------*/ |
| 410 | /*--- end ---*/ |
njn | 810086f | 2002-11-14 12:42:47 +0000 | [diff] [blame] | 411 | /*--------------------------------------------------------------------*/ |