sewardj | 3282402 | 2005-05-17 13:45:04 +0000 | [diff] [blame] | 1 | |
| 2 | /*--------------------------------------------------------------------*/ |
njn | b1cc5d6 | 2010-07-06 04:05:23 +0000 | [diff] [blame] | 3 | /*--- Command line options. m_options.c ---*/ |
sewardj | 3282402 | 2005-05-17 13:45:04 +0000 | [diff] [blame] | 4 | /*--------------------------------------------------------------------*/ |
| 5 | |
| 6 | /* |
| 7 | This file is part of Valgrind, a dynamic binary instrumentation |
| 8 | framework. |
| 9 | |
sewardj | 03f8d3f | 2012-08-05 15:46:46 +0000 | [diff] [blame] | 10 | Copyright (C) 2000-2012 Nicholas Nethercote |
sewardj | 3282402 | 2005-05-17 13:45:04 +0000 | [diff] [blame] | 11 | njn@valgrind.org |
| 12 | |
| 13 | This program is free software; you can redistribute it and/or |
| 14 | modify it under the terms of the GNU General Public License as |
| 15 | published by the Free Software Foundation; either version 2 of the |
| 16 | License, or (at your option) any later version. |
| 17 | |
| 18 | This program is distributed in the hope that it will be useful, but |
| 19 | WITHOUT ANY WARRANTY; without even the implied warranty of |
| 20 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 21 | General Public License for more details. |
| 22 | |
| 23 | You should have received a copy of the GNU General Public License |
| 24 | along with this program; if not, write to the Free Software |
| 25 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA |
| 26 | 02111-1307, USA. |
| 27 | |
| 28 | The GNU General Public License is contained in the file COPYING. |
| 29 | */ |
| 30 | |
njn | c7561b9 | 2005-06-19 01:24:32 +0000 | [diff] [blame] | 31 | #include "pub_core_basics.h" |
njn | 374a36d | 2007-11-23 01:41:32 +0000 | [diff] [blame] | 32 | #include "pub_core_vki.h" |
njn | a3506d3 | 2005-05-18 04:36:01 +0000 | [diff] [blame] | 33 | #include "pub_core_options.h" |
sewardj | 6893d65 | 2006-10-15 01:25:13 +0000 | [diff] [blame] | 34 | #include "pub_core_libcassert.h" |
njn | 374a36d | 2007-11-23 01:41:32 +0000 | [diff] [blame] | 35 | #include "pub_core_libcbase.h" |
| 36 | #include "pub_core_libcfile.h" |
sewardj | 6893d65 | 2006-10-15 01:25:13 +0000 | [diff] [blame] | 37 | #include "pub_core_libcprint.h" |
njn | 374a36d | 2007-11-23 01:41:32 +0000 | [diff] [blame] | 38 | #include "pub_core_libcproc.h" |
| 39 | #include "pub_core_mallocfree.h" |
sewardj | 0642127 | 2009-11-05 08:55:13 +0000 | [diff] [blame] | 40 | #include "pub_core_seqmatch.h" // VG_(string_match) |
sewardj | 3282402 | 2005-05-17 13:45:04 +0000 | [diff] [blame] | 41 | |
njn | a3506d3 | 2005-05-18 04:36:01 +0000 | [diff] [blame] | 42 | // See pub_{core,tool}_options.h for explanations of all these. |
| 43 | |
| 44 | |
| 45 | /* Define, and set defaults. */ |
| 46 | VexControl VG_(clo_vex_control); |
| 47 | Bool VG_(clo_error_limit) = True; |
sewardj | b977908 | 2006-05-12 23:50:15 +0000 | [diff] [blame] | 48 | Int VG_(clo_error_exitcode) = 0; |
sewardj | 0ba37c9 | 2011-07-12 11:46:24 +0000 | [diff] [blame] | 49 | |
philippe | 5d5dd8e | 2012-08-05 00:08:25 +0000 | [diff] [blame] | 50 | #if defined(VGPV_arm_linux_android) || defined(VGPV_x86_linux_android) |
sewardj | deddfdf | 2011-10-26 15:07:56 +0000 | [diff] [blame] | 51 | VgVgdb VG_(clo_vgdb) = Vg_VgdbNo; // currently disabled on Android |
| 52 | #else |
sewardj | 0ba37c9 | 2011-07-12 11:46:24 +0000 | [diff] [blame] | 53 | VgVgdb VG_(clo_vgdb) = Vg_VgdbYes; |
sewardj | deddfdf | 2011-10-26 15:07:56 +0000 | [diff] [blame] | 54 | #endif |
sewardj | 3b29048 | 2011-05-06 21:02:55 +0000 | [diff] [blame] | 55 | Int VG_(clo_vgdb_poll) = 5000; |
| 56 | Int VG_(clo_vgdb_error) = 999999999; |
florian | b985e2d | 2011-09-29 03:03:45 +0000 | [diff] [blame] | 57 | HChar* VG_(clo_vgdb_prefix) = NULL; |
sewardj | 3b29048 | 2011-05-06 21:02:55 +0000 | [diff] [blame] | 58 | Bool VG_(clo_vgdb_shadow_registers) = False; |
sewardj | 0ba37c9 | 2011-07-12 11:46:24 +0000 | [diff] [blame] | 59 | |
njn | a3506d3 | 2005-05-18 04:36:01 +0000 | [diff] [blame] | 60 | Bool VG_(clo_db_attach) = False; |
| 61 | Char* VG_(clo_db_command) = GDB_PATH " -nw %f %p"; |
| 62 | Int VG_(clo_gen_suppressions) = 0; |
| 63 | Int VG_(clo_sanity_level) = 1; |
| 64 | Int VG_(clo_verbosity) = 1; |
sewardj | 2d9e874 | 2009-08-07 15:46:56 +0000 | [diff] [blame] | 65 | Bool VG_(clo_stats) = False; |
sewardj | 71bc3cb | 2005-05-19 00:25:45 +0000 | [diff] [blame] | 66 | Bool VG_(clo_xml) = False; |
sewardj | 768db0e | 2005-07-19 14:18:56 +0000 | [diff] [blame] | 67 | HChar* VG_(clo_xml_user_comment) = NULL; |
njn | a3506d3 | 2005-05-18 04:36:01 +0000 | [diff] [blame] | 68 | Bool VG_(clo_demangle) = True; |
philippe | 1e470b5 | 2012-05-11 19:33:46 +0000 | [diff] [blame] | 69 | HChar* VG_(clo_soname_synonyms) = NULL; |
njn | a3506d3 | 2005-05-18 04:36:01 +0000 | [diff] [blame] | 70 | Bool VG_(clo_trace_children) = False; |
sewardj | 0642127 | 2009-11-05 08:55:13 +0000 | [diff] [blame] | 71 | HChar* VG_(clo_trace_children_skip) = NULL; |
sewardj | 9ab64a4 | 2010-12-06 11:40:04 +0000 | [diff] [blame] | 72 | HChar* VG_(clo_trace_children_skip_by_arg) = NULL; |
sewardj | 6e31f80 | 2007-11-17 22:29:25 +0000 | [diff] [blame] | 73 | Bool VG_(clo_child_silent_after_fork) = False; |
sewardj | 738856f | 2009-07-15 14:48:32 +0000 | [diff] [blame] | 74 | Char* VG_(clo_log_fname_expanded) = NULL; |
| 75 | Char* VG_(clo_xml_fname_expanded) = NULL; |
njn | a3506d3 | 2005-05-18 04:36:01 +0000 | [diff] [blame] | 76 | Bool VG_(clo_time_stamp) = False; |
| 77 | Int VG_(clo_input_fd) = 0; /* stdin */ |
| 78 | Int VG_(clo_n_suppressions) = 0; |
| 79 | Char* VG_(clo_suppressions)[VG_CLO_MAX_SFILES]; |
sewardj | 14cdbf8 | 2010-10-12 00:44:05 +0000 | [diff] [blame] | 80 | Int VG_(clo_n_fullpath_after) = 0; |
| 81 | Char* VG_(clo_fullpath_after)[VG_CLO_MAX_FULLPATH_AFTER]; |
njn | a3506d3 | 2005-05-18 04:36:01 +0000 | [diff] [blame] | 82 | UChar VG_(clo_trace_flags) = 0; // 00000000b |
| 83 | UChar VG_(clo_profile_flags) = 0; // 00000000b |
florian | 29e022d | 2012-07-02 21:13:34 +0000 | [diff] [blame] | 84 | Int VG_(clo_trace_notbelow) = -1; // unspecified |
| 85 | Int VG_(clo_trace_notabove) = -1; // unspecified |
njn | a3506d3 | 2005-05-18 04:36:01 +0000 | [diff] [blame] | 86 | Bool VG_(clo_trace_syscalls) = False; |
| 87 | Bool VG_(clo_trace_signals) = False; |
| 88 | Bool VG_(clo_trace_symtab) = False; |
sewardj | f767d96 | 2007-02-12 17:47:14 +0000 | [diff] [blame] | 89 | HChar* VG_(clo_trace_symtab_patt) = "*"; |
njn | a3506d3 | 2005-05-18 04:36:01 +0000 | [diff] [blame] | 90 | Bool VG_(clo_trace_cfi) = False; |
sewardj | f767d96 | 2007-02-12 17:47:14 +0000 | [diff] [blame] | 91 | Bool VG_(clo_debug_dump_syms) = False; |
| 92 | Bool VG_(clo_debug_dump_line) = False; |
| 93 | Bool VG_(clo_debug_dump_frames) = False; |
njn | a3506d3 | 2005-05-18 04:36:01 +0000 | [diff] [blame] | 94 | Bool VG_(clo_trace_redir) = False; |
bart | 78bfc71 | 2011-12-08 16:14:59 +0000 | [diff] [blame] | 95 | enum FairSchedType |
| 96 | VG_(clo_fair_sched) = disable_fair_sched; |
njn | a3506d3 | 2005-05-18 04:36:01 +0000 | [diff] [blame] | 97 | Bool VG_(clo_trace_sched) = False; |
sewardj | 9c606bd | 2008-09-18 18:12:50 +0000 | [diff] [blame] | 98 | Bool VG_(clo_profile_heap) = False; |
philippe | d99c26a | 2012-07-31 22:17:28 +0000 | [diff] [blame] | 99 | Int VG_(clo_core_redzone_size) = CORE_REDZONE_DEFAULT_SZB; |
| 100 | // A value != -1 overrides the tool-specific value |
| 101 | // VG_(needs_malloc_replacement).tool_client_redzone_szB |
| 102 | Int VG_(clo_redzone_size) = -1; |
njn | a3506d3 | 2005-05-18 04:36:01 +0000 | [diff] [blame] | 103 | Int VG_(clo_dump_error) = 0; |
| 104 | Int VG_(clo_backtrace_size) = 12; |
njn | 628add6 | 2005-11-12 18:21:40 +0000 | [diff] [blame] | 105 | Char* VG_(clo_sim_hints) = NULL; |
sewardj | 41ded2c | 2006-10-17 01:34:57 +0000 | [diff] [blame] | 106 | Bool VG_(clo_sym_offsets) = False; |
sewardj | b8b79ad | 2008-03-03 01:35:41 +0000 | [diff] [blame] | 107 | Bool VG_(clo_read_var_info) = False; |
sewardj | f9ebc39 | 2010-05-09 22:30:43 +0000 | [diff] [blame] | 108 | Int VG_(clo_n_req_tsyms) = 0; |
| 109 | HChar* VG_(clo_req_tsyms)[VG_CLO_MAX_REQ_TSYMS]; |
| 110 | HChar* VG_(clo_require_text_symbol) = NULL; |
njn | a3506d3 | 2005-05-18 04:36:01 +0000 | [diff] [blame] | 111 | Bool VG_(clo_run_libc_freeres) = True; |
| 112 | Bool VG_(clo_track_fds) = False; |
| 113 | Bool VG_(clo_show_below_main)= False; |
njn | a3506d3 | 2005-05-18 04:36:01 +0000 | [diff] [blame] | 114 | Bool VG_(clo_show_emwarns) = False; |
sewardj | 91b470c | 2007-08-28 17:03:01 +0000 | [diff] [blame] | 115 | Word VG_(clo_max_stackframe) = 2000000; |
sewardj | 95d86c0 | 2007-12-18 01:49:23 +0000 | [diff] [blame] | 116 | Word VG_(clo_main_stacksize) = 0; /* use client's rlimit.stack */ |
njn | a3506d3 | 2005-05-18 04:36:01 +0000 | [diff] [blame] | 117 | Bool VG_(clo_wait_for_gdb) = False; |
sewardj | 6c3a219 | 2005-07-24 07:00:45 +0000 | [diff] [blame] | 118 | VgSmc VG_(clo_smc_check) = Vg_SmcStack; |
sewardj | ce5a566 | 2005-10-06 03:19:49 +0000 | [diff] [blame] | 119 | HChar* VG_(clo_kernel_variant) = NULL; |
njn | 97db761 | 2009-08-04 02:32:55 +0000 | [diff] [blame] | 120 | Bool VG_(clo_dsymutil) = False; |
sewardj | 26412bd | 2005-07-07 10:05:05 +0000 | [diff] [blame] | 121 | |
sewardj | 3282402 | 2005-05-17 13:45:04 +0000 | [diff] [blame] | 122 | |
sewardj | 6893d65 | 2006-10-15 01:25:13 +0000 | [diff] [blame] | 123 | /*====================================================================*/ |
njn | b1cc5d6 | 2010-07-06 04:05:23 +0000 | [diff] [blame] | 124 | /*=== File expansion ===*/ |
sewardj | 6893d65 | 2006-10-15 01:25:13 +0000 | [diff] [blame] | 125 | /*====================================================================*/ |
| 126 | |
njn | 374a36d | 2007-11-23 01:41:32 +0000 | [diff] [blame] | 127 | // Copies the string, prepending it with the startup working directory, and |
| 128 | // expanding %p and %q entries. Returns a new, malloc'd string. |
| 129 | Char* VG_(expand_file_name)(Char* option_name, Char* format) |
| 130 | { |
| 131 | static Char base_dir[VKI_PATH_MAX]; |
| 132 | Int len, i = 0, j = 0; |
| 133 | Char* out; |
| 134 | |
| 135 | Bool ok = VG_(get_startup_wd)(base_dir, VKI_PATH_MAX); |
| 136 | tl_assert(ok); |
| 137 | |
| 138 | if (VG_STREQ(format, "")) { |
| 139 | // Empty name, bad. |
njn | b1cc5d6 | 2010-07-06 04:05:23 +0000 | [diff] [blame] | 140 | VG_(fmsg)("%s: filename is empty", option_name); |
njn | 5542d8f | 2009-06-09 00:50:45 +0000 | [diff] [blame] | 141 | goto bad; |
| 142 | } |
| 143 | |
| 144 | // If 'format' starts with a '~', abort -- the user probably expected the |
| 145 | // shell to expand but it didn't (see bug 195268 for details). This means |
| 146 | // that we don't allow a legitimate filename beginning with '~' but that |
| 147 | // seems very unlikely. |
| 148 | if (format[0] == '~') { |
njn | b1cc5d6 | 2010-07-06 04:05:23 +0000 | [diff] [blame] | 149 | VG_(fmsg)( |
| 150 | "%s: filename begins with '~'\n" |
| 151 | "You probably expected the shell to expand the '~', but it\n" |
| 152 | "didn't. The rules for '~'-expansion vary from shell to shell.\n" |
| 153 | "You might have more luck using $HOME instead.\n", |
| 154 | option_name |
| 155 | ); |
njn | 374a36d | 2007-11-23 01:41:32 +0000 | [diff] [blame] | 156 | goto bad; |
| 157 | } |
| 158 | |
njn | 2dd08f5 | 2007-11-23 22:37:35 +0000 | [diff] [blame] | 159 | // If 'format' starts with a '/', do not prefix with startup dir. |
| 160 | if (format[0] != '/') { |
| 161 | j += VG_(strlen)(base_dir); |
| 162 | } |
| 163 | |
njn | 374a36d | 2007-11-23 01:41:32 +0000 | [diff] [blame] | 164 | // The 10 is slop, it should be enough in most cases. |
njn | 374a36d | 2007-11-23 01:41:32 +0000 | [diff] [blame] | 165 | len = j + VG_(strlen)(format) + 10; |
sewardj | 9c606bd | 2008-09-18 18:12:50 +0000 | [diff] [blame] | 166 | out = VG_(malloc)( "options.efn.1", len ); |
njn | 2dd08f5 | 2007-11-23 22:37:35 +0000 | [diff] [blame] | 167 | if (format[0] != '/') { |
| 168 | VG_(strcpy)(out, base_dir); |
| 169 | out[j++] = '/'; |
| 170 | } |
njn | 374a36d | 2007-11-23 01:41:32 +0000 | [diff] [blame] | 171 | |
| 172 | #define ENSURE_THIS_MUCH_SPACE(x) \ |
| 173 | if (j + x >= len) { \ |
| 174 | len += (10 + x); \ |
sewardj | 9c606bd | 2008-09-18 18:12:50 +0000 | [diff] [blame] | 175 | out = VG_(realloc)("options.efn.2(multiple)", out, len); \ |
njn | 374a36d | 2007-11-23 01:41:32 +0000 | [diff] [blame] | 176 | } |
| 177 | |
njn | 374a36d | 2007-11-23 01:41:32 +0000 | [diff] [blame] | 178 | while (format[i]) { |
| 179 | if (format[i] != '%') { |
| 180 | ENSURE_THIS_MUCH_SPACE(1); |
| 181 | out[j++] = format[i++]; |
| 182 | |
| 183 | } else { |
| 184 | // We saw a '%'. What's next... |
| 185 | i++; |
| 186 | if ('%' == format[i]) { |
| 187 | // Replace '%%' with '%'. |
| 188 | ENSURE_THIS_MUCH_SPACE(1); |
| 189 | out[j++] = format[i++]; |
| 190 | } |
| 191 | else if ('p' == format[i]) { |
| 192 | // Print the PID. Assume that it's not longer than 10 chars -- |
| 193 | // reasonable since 'pid' is an Int (ie. 32 bits). |
| 194 | Int pid = VG_(getpid)(); |
| 195 | ENSURE_THIS_MUCH_SPACE(10); |
| 196 | j += VG_(sprintf)(&out[j], "%d", pid); |
| 197 | i++; |
| 198 | } |
njn | 2dd08f5 | 2007-11-23 22:37:35 +0000 | [diff] [blame] | 199 | else if ('q' == format[i]) { |
| 200 | i++; |
| 201 | if ('{' == format[i]) { |
| 202 | // Get the env var name, print its contents. |
| 203 | Char* qualname; |
| 204 | Char* qual; |
njn | 374a36d | 2007-11-23 01:41:32 +0000 | [diff] [blame] | 205 | i++; |
njn | 2dd08f5 | 2007-11-23 22:37:35 +0000 | [diff] [blame] | 206 | qualname = &format[i]; |
| 207 | while (True) { |
| 208 | if (0 == format[i]) { |
njn | b1cc5d6 | 2010-07-06 04:05:23 +0000 | [diff] [blame] | 209 | VG_(fmsg)("%s: malformed %%q specifier\n", option_name); |
njn | 2dd08f5 | 2007-11-23 22:37:35 +0000 | [diff] [blame] | 210 | goto bad; |
| 211 | } else if ('}' == format[i]) { |
| 212 | // Temporarily replace the '}' with NUL to extract var |
| 213 | // name. |
| 214 | format[i] = 0; |
| 215 | qual = VG_(getenv)(qualname); |
| 216 | if (NULL == qual) { |
njn | b1cc5d6 | 2010-07-06 04:05:23 +0000 | [diff] [blame] | 217 | VG_(fmsg)("%s: environment variable %s is not set\n", |
| 218 | option_name, qualname); |
njn | 2dd08f5 | 2007-11-23 22:37:35 +0000 | [diff] [blame] | 219 | format[i] = '}'; // Put the '}' back. |
| 220 | goto bad; |
| 221 | } |
| 222 | format[i] = '}'; // Put the '}' back. |
| 223 | i++; |
| 224 | break; |
| 225 | } |
| 226 | i++; |
| 227 | } |
| 228 | ENSURE_THIS_MUCH_SPACE(VG_(strlen)(qual)); |
| 229 | j += VG_(sprintf)(&out[j], "%s", qual); |
| 230 | } else { |
njn | b1cc5d6 | 2010-07-06 04:05:23 +0000 | [diff] [blame] | 231 | VG_(fmsg)("%s: expected '{' after '%%q'\n", option_name); |
njn | 2dd08f5 | 2007-11-23 22:37:35 +0000 | [diff] [blame] | 232 | goto bad; |
njn | 374a36d | 2007-11-23 01:41:32 +0000 | [diff] [blame] | 233 | } |
njn | 374a36d | 2007-11-23 01:41:32 +0000 | [diff] [blame] | 234 | } |
| 235 | else { |
| 236 | // Something else, abort. |
njn | b1cc5d6 | 2010-07-06 04:05:23 +0000 | [diff] [blame] | 237 | VG_(fmsg)("%s: expected 'p' or 'q' or '%%' after '%%'\n", |
| 238 | option_name); |
njn | 374a36d | 2007-11-23 01:41:32 +0000 | [diff] [blame] | 239 | goto bad; |
| 240 | } |
| 241 | } |
| 242 | } |
| 243 | ENSURE_THIS_MUCH_SPACE(1); |
| 244 | out[j++] = 0; |
| 245 | |
| 246 | return out; |
| 247 | |
| 248 | bad: { |
| 249 | Char* opt = // 2: 1 for the '=', 1 for the NUL. |
sewardj | 9c606bd | 2008-09-18 18:12:50 +0000 | [diff] [blame] | 250 | VG_(malloc)( "options.efn.3", |
| 251 | VG_(strlen)(option_name) + VG_(strlen)(format) + 2 ); |
njn | 374a36d | 2007-11-23 01:41:32 +0000 | [diff] [blame] | 252 | VG_(strcpy)(opt, option_name); |
| 253 | VG_(strcat)(opt, "="); |
| 254 | VG_(strcat)(opt, format); |
njn | b1cc5d6 | 2010-07-06 04:05:23 +0000 | [diff] [blame] | 255 | VG_(fmsg_bad_option)(opt, ""); |
njn | 374a36d | 2007-11-23 01:41:32 +0000 | [diff] [blame] | 256 | } |
| 257 | } |
| 258 | |
sewardj | 0642127 | 2009-11-05 08:55:13 +0000 | [diff] [blame] | 259 | /*====================================================================*/ |
| 260 | /*=== --trace-children= support ===*/ |
| 261 | /*====================================================================*/ |
| 262 | |
| 263 | static HChar const* consume_commas ( HChar const* c ) { |
| 264 | while (*c && *c == ',') { |
| 265 | ++c; |
| 266 | } |
| 267 | return c; |
| 268 | } |
| 269 | |
| 270 | static HChar const* consume_field ( HChar const* c ) { |
| 271 | while (*c && *c != ',') { |
| 272 | ++c; |
| 273 | } |
| 274 | return c; |
| 275 | } |
| 276 | |
| 277 | /* Should we trace into this child executable (across execve etc) ? |
sewardj | 9ab64a4 | 2010-12-06 11:40:04 +0000 | [diff] [blame] | 278 | This involves considering --trace-children=, |
| 279 | --trace-children-skip=, --trace-children-skip-by-arg=, and the name |
| 280 | of the executable. 'child_argv' must not include the name of the |
| 281 | executable itself; iow child_argv[0] must be the first arg, if any, |
| 282 | for the child. */ |
| 283 | Bool VG_(should_we_trace_this_child) ( HChar* child_exe_name, |
| 284 | HChar** child_argv ) |
sewardj | 0642127 | 2009-11-05 08:55:13 +0000 | [diff] [blame] | 285 | { |
| 286 | // child_exe_name is pulled out of the guest's space. We |
| 287 | // should be at least marginally cautious with it, lest it |
| 288 | // explode or burst into flames unexpectedly. |
| 289 | if (child_exe_name == NULL || VG_(strlen)(child_exe_name) == 0) |
| 290 | return VG_(clo_trace_children); // we know narfink |
| 291 | |
sewardj | 0642127 | 2009-11-05 08:55:13 +0000 | [diff] [blame] | 292 | // If --trace-children=no, the answer is simply NO. |
| 293 | if (! VG_(clo_trace_children)) |
| 294 | return False; |
| 295 | |
sewardj | 9ab64a4 | 2010-12-06 11:40:04 +0000 | [diff] [blame] | 296 | // Otherwise, look for other reasons to say NO. First, |
| 297 | // see if the exe name matches any of the patterns specified |
| 298 | // by --trace-children-skip=. |
sewardj | 0642127 | 2009-11-05 08:55:13 +0000 | [diff] [blame] | 299 | if (VG_(clo_trace_children_skip)) { |
| 300 | HChar const* last = VG_(clo_trace_children_skip); |
| 301 | HChar const* name = (HChar const*)child_exe_name; |
| 302 | while (*last) { |
| 303 | Bool matches; |
| 304 | HChar* patt; |
| 305 | HChar const* first = consume_commas(last); |
| 306 | last = consume_field(first); |
| 307 | if (first == last) |
| 308 | break; |
| 309 | vg_assert(last > first); |
| 310 | /* copy the candidate string into a temporary malloc'd block |
| 311 | so we can use VG_(string_match) on it. */ |
| 312 | patt = VG_(calloc)("m_options.swttc.1", last - first + 1, 1); |
| 313 | VG_(memcpy)(patt, first, last - first); |
| 314 | vg_assert(patt[last-first] == 0); |
| 315 | matches = VG_(string_match)(patt, name); |
| 316 | VG_(free)(patt); |
| 317 | if (matches) |
| 318 | return False; |
| 319 | } |
| 320 | } |
sewardj | 9ab64a4 | 2010-12-06 11:40:04 +0000 | [diff] [blame] | 321 | |
| 322 | // Check if any of the args match any of the patterns specified |
| 323 | // by --trace-children-skip-by-arg=. |
| 324 | if (VG_(clo_trace_children_skip_by_arg) && child_argv != NULL) { |
| 325 | HChar const* last = VG_(clo_trace_children_skip_by_arg); |
| 326 | while (*last) { |
| 327 | Int i; |
| 328 | Bool matches; |
| 329 | HChar* patt; |
| 330 | HChar const* first = consume_commas(last); |
| 331 | last = consume_field(first); |
| 332 | if (first == last) |
| 333 | break; |
| 334 | vg_assert(last > first); |
| 335 | /* copy the candidate string into a temporary malloc'd block |
| 336 | so we can use VG_(string_match) on it. */ |
| 337 | patt = VG_(calloc)("m_options.swttc.1", last - first + 1, 1); |
| 338 | VG_(memcpy)(patt, first, last - first); |
| 339 | vg_assert(patt[last-first] == 0); |
| 340 | for (i = 0; child_argv[i]; i++) { |
| 341 | matches = VG_(string_match)(patt, child_argv[i]); |
| 342 | if (matches) { |
| 343 | VG_(free)(patt); |
| 344 | return False; |
| 345 | } |
| 346 | } |
| 347 | VG_(free)(patt); |
| 348 | } |
| 349 | } |
| 350 | |
sewardj | 0642127 | 2009-11-05 08:55:13 +0000 | [diff] [blame] | 351 | // --trace-children=yes, and this particular executable isn't |
| 352 | // excluded |
| 353 | return True; |
| 354 | } |
njn | 374a36d | 2007-11-23 01:41:32 +0000 | [diff] [blame] | 355 | |
sewardj | 6893d65 | 2006-10-15 01:25:13 +0000 | [diff] [blame] | 356 | |
sewardj | 3282402 | 2005-05-17 13:45:04 +0000 | [diff] [blame] | 357 | /*--------------------------------------------------------------------*/ |
njn | b1cc5d6 | 2010-07-06 04:05:23 +0000 | [diff] [blame] | 358 | /*--- end ---*/ |
sewardj | 3282402 | 2005-05-17 13:45:04 +0000 | [diff] [blame] | 359 | /*--------------------------------------------------------------------*/ |