APPEND(" (");
// Get the directory name, if any, possibly pruned, into dirname.
HChar* dirname = NULL;
- if (VG_(clo_n_fullpath_after) > 0) {
+ if (VG_(sizeXA)(VG_(clo_fullpath_after)) > 0) {
Int i;
dirname = buf_dirname;
// Remove leading prefixes from the dirname.
// If user supplied --fullpath-after=foo, this will remove
// a leading string which matches '.*foo' (not greedy).
- for (i = 0; i < VG_(clo_n_fullpath_after); i++) {
- const HChar* prefix = VG_(clo_fullpath_after)[i];
+ for (i = 0; i < VG_(sizeXA)(VG_(clo_fullpath_after)); i++) {
+ const HChar* prefix =
+ *(HChar**) VG_(indexXA)( VG_(clo_fullpath_after), i );
HChar* str = VG_(strstr)(dirname, prefix);
if (str) {
dirname = str + VG_(strlen)(prefix);
// Ensure buffer is properly terminated
vg_assert(xtra[num_written] == '\0');
+ HChar *filename = *(HChar**) VG_(indexXA)(VG_(clo_suppressions),
+ su->clo_suppressions_i);
VG_(dmsg)("used_suppression: %6d %s %s:%d%s%s\n", su->count, su->sname,
- VG_(clo_suppressions)[su->clo_suppressions_i],
+ filename,
su->sname_lineno,
num_written ? " " : "", xtra);
VG_(free)(xtra);
*/
static void load_one_suppressions_file ( Int clo_suppressions_i )
{
- const HChar* filename = VG_(clo_suppressions)[clo_suppressions_i];
+ const HChar* filename = *(HChar**) VG_(indexXA)(VG_(clo_suppressions),
+ clo_suppressions_i);
SysRes sres;
Int fd, i, j, lineno = 0;
Bool got_a_location_line_read_by_tool;
{
Int i;
suppressions = NULL;
- for (i = 0; i < VG_(clo_n_suppressions); i++) {
+ for (i = 0; i < VG_(sizeXA)(VG_(clo_suppressions)); i++) {
if (VG_(clo_verbosity) > 1) {
VG_(dmsg)("Reading suppressions file: %s\n",
- VG_(clo_suppressions)[i] );
+ *(HChar**) VG_(indexXA)(VG_(clo_suppressions), i));
}
load_one_suppressions_file( i );
}
IPtoFunOrObjCompleter* ip2fo)
{
if (DEBUG_ERRORMGR || VG_(debugLog_getLevel)() >= 4) {
- if (su)
+ if (su) {
+ HChar *filename = *(HChar**) VG_(indexXA)(VG_(clo_suppressions),
+ su->clo_suppressions_i);
VG_(dmsg)("errormgr matching end suppression %s %s:%d matched:\n",
su->sname,
- VG_(clo_suppressions)[su->clo_suppressions_i],
+ filename,
su->sname_lineno);
- else
+ } else
VG_(dmsg)("errormgr matching end no suppression matched:\n");
VG_(pp_StackTrace) (ip2fo->ips, ip2fo->n_ips);
pp_ip2fo(ip2fo);
UWord n_supps = su->n_callers;
UWord szbPatt = sizeof(SuppLoc);
Bool matchAll = False; /* we just want to match a prefix */
- if (DEBUG_ERRORMGR)
+ if (DEBUG_ERRORMGR) {
+ HChar *filename = *(HChar**) VG_(indexXA)(VG_(clo_suppressions),
+ su->clo_suppressions_i);
VG_(dmsg)(" errormgr Checking match with %s %s:%d\n",
su->sname,
- VG_(clo_suppressions)[su->clo_suppressions_i],
+ filename,
su->sname_lineno);
+ }
return
VG_(generic_match)(
matchAll,
vg_assert( VG_(args_for_valgrind) );
+ VG_(clo_suppressions) = VG_(newXA)(VG_(malloc), "main.mpclo.4",
+ VG_(free), sizeof(HChar *));
+ VG_(clo_fullpath_after) = VG_(newXA)(VG_(malloc), "main.mpclo.5",
+ VG_(free), sizeof(HChar *));
+ VG_(clo_req_tsyms) = VG_(newXA)(VG_(malloc), "main.mpclo.6",
+ VG_(free), sizeof(HChar *));
+
/* BEGIN command-line processing loop */
for (i = 0; i < VG_(sizeXA)( VG_(args_for_valgrind) ); i++) {
VG_(clo_default_supp)) { }
else if VG_STR_CLO(arg, "--suppressions", tmp_str) {
- if (VG_(clo_n_suppressions) >= VG_CLO_MAX_SFILES) {
- VG_(fmsg_bad_option)(arg,
- "Too many suppression files specified.\n"
- "Increase VG_CLO_MAX_SFILES and recompile.\n");
- }
- VG_(clo_suppressions)[VG_(clo_n_suppressions)] = tmp_str;
- VG_(clo_n_suppressions)++;
+ VG_(addToXA)(VG_(clo_suppressions), &tmp_str);
}
else if VG_STR_CLO (arg, "--fullpath-after", tmp_str) {
- if (VG_(clo_n_fullpath_after) >= VG_CLO_MAX_FULLPATH_AFTER) {
- VG_(fmsg_bad_option)(arg,
- "Too many --fullpath-after= specifications.\n"
- "Increase VG_CLO_MAX_FULLPATH_AFTER and recompile.\n");
- }
- VG_(clo_fullpath_after)[VG_(clo_n_fullpath_after)] = tmp_str;
- VG_(clo_n_fullpath_after)++;
+ VG_(addToXA)(VG_(clo_fullpath_after), &tmp_str);
}
else if VG_STR_CLO (arg, "--extra-debuginfo-path",
VG_(clo_extra_debuginfo_path)) {}
else if VG_STR_CLO(arg, "--require-text-symbol", tmp_str) {
- if (VG_(clo_n_req_tsyms) >= VG_CLO_MAX_REQ_TSYMS) {
- VG_(fmsg_bad_option)(arg,
- "Too many --require-text-symbol= specifications.\n"
- "Increase VG_CLO_MAX_REQ_TSYMS and recompile.\n");
- }
/* String needs to be of the form C?*C?*, where C is any
character, but is the same both times. Having it in this
form facilitates finding the boundary between the sopatt
VG_(fmsg_bad_option)(arg,
"Invalid --require-text-symbol= specification.\n");
}
- VG_(clo_req_tsyms)[VG_(clo_n_req_tsyms)] = tmp_str;
- VG_(clo_n_req_tsyms)++;
+ VG_(addToXA)(VG_(clo_req_tsyms), &tmp_str);
}
/* "stuvwxyz" --> stuvwxyz (binary) */
// Suppressions related stuff
if (VG_(clo_default_supp) &&
- VG_(clo_n_suppressions) < VG_CLO_MAX_SFILES-1 &&
(VG_(needs).core_errors || VG_(needs).tool_errors)) {
/* If we haven't reached the max number of suppressions, load
the default one. */
Int len = VG_(strlen)(VG_(libdir)) + 1 + sizeof(default_supp);
HChar *buf = VG_(malloc)("main.mpclo.3", len);
VG_(sprintf)(buf, "%s/%s", VG_(libdir), default_supp);
- VG_(clo_suppressions)[VG_(clo_n_suppressions)] = buf;
- VG_(clo_n_suppressions)++;
+ VG_(addToXA)(VG_(clo_suppressions), &buf);
}
*logging_to_fd = log_to == VgLogTo_Fd || log_to == VgLogTo_Socket;
Bool VG_(clo_time_stamp) = False;
Int VG_(clo_input_fd) = 0; /* stdin */
Bool VG_(clo_default_supp) = True;
-Int VG_(clo_n_suppressions) = 0;
-const HChar* VG_(clo_suppressions)[VG_CLO_MAX_SFILES];
-Int VG_(clo_n_fullpath_after) = 0;
-const HChar* VG_(clo_fullpath_after)[VG_CLO_MAX_FULLPATH_AFTER];
+XArray *VG_(clo_suppressions); // array of strings
+XArray *VG_(clo_fullpath_after); // array of strings
const HChar* VG_(clo_extra_debuginfo_path) = NULL;
const HChar* VG_(clo_debuginfo_server) = NULL;
Bool VG_(clo_allow_mismatched_debuginfo) = False;
Bool VG_(clo_sym_offsets) = False;
Bool VG_(clo_read_inline_info) = False; // Or should be put it to True by default ???
Bool VG_(clo_read_var_info) = False;
-Int VG_(clo_n_req_tsyms) = 0;
-const HChar* VG_(clo_req_tsyms)[VG_CLO_MAX_REQ_TSYMS];
+XArray *VG_(clo_req_tsyms); // array of strings
HChar* VG_(clo_require_text_symbol) = NULL;
Bool VG_(clo_run_libc_freeres) = True;
Bool VG_(clo_track_fds) = False;
frequently be used. Work through the list of specs and
accumulate in fnpatts[] the fn patterns that pertain to this
object. */
- HChar* fnpatts[VG_CLO_MAX_REQ_TSYMS];
- Int fnpatts_used = 0;
+ XArray *fnpatts = VG_(newXA)( VG_(malloc), "m_redir.hrts.5",
+ VG_(free), sizeof(HChar*) );
+
Int i, j;
const HChar* di_soname = VG_(DebugInfo_get_soname)(di);
vg_assert(di_soname); // must be present
- VG_(memset)(&fnpatts, 0, sizeof(fnpatts));
-
- vg_assert(VG_(clo_n_req_tsyms) >= 0);
- vg_assert(VG_(clo_n_req_tsyms) <= VG_CLO_MAX_REQ_TSYMS);
- for (i = 0; i < VG_(clo_n_req_tsyms); i++) {
- const HChar* clo_spec = VG_(clo_req_tsyms)[i];
+ for (i = 0; i < VG_(sizeXA)(VG_(clo_req_tsyms)); i++) {
+ const HChar* clo_spec = *(HChar**) VG_(indexXA)(VG_(clo_req_tsyms), i);
vg_assert(clo_spec && VG_(strlen)(clo_spec) >= 4);
// clone the spec, so we can stick a zero at the end of the sopatt
HChar *spec = VG_(strdup)("m_redir.hrts.1", clo_spec);
vg_assert(fnpatt && *fnpatt == sep);
*fnpatt = 0;
fnpatt++;
- if (VG_(string_match)(sopatt, di_soname))
- fnpatts[fnpatts_used++]
- = VG_(strdup)("m_redir.hrts.2", fnpatt);
+ if (VG_(string_match)(sopatt, di_soname)) {
+ HChar *pattern = VG_(strdup)("m_redir.hrts.2", fnpatt);
+ VG_(addToXA)(fnpatts, &pattern);
+ }
VG_(free)(spec);
}
- if (fnpatts_used == 0)
+ if (VG_(sizeXA)(fnpatts) == 0) {
+ VG_(deleteXA)(fnpatts);
return; /* no applicable spec strings */
+ }
- /* So finally, fnpatts[0 .. fnpatts_used - 1] contains the set of
+ /* So finally, fnpatts contains the set of
(patterns for) text symbol names that must be found in this
object, in order to continue. That is, we must find at least
one text symbol name that matches each pattern, else we must
abort the run. */
if (0) VG_(printf)("for %s\n", di_soname);
- for (i = 0; i < fnpatts_used; i++)
- if (0) VG_(printf)(" fnpatt: %s\n", fnpatts[i]);
+ for (i = 0; i < VG_(sizeXA)(fnpatts); i++)
+ if (0) VG_(printf)(" fnpatt: %s\n",
+ *(HChar**) VG_(indexXA)(fnpatts, i));
/* For each spec, look through the syms to find one that matches.
This isn't terribly efficient but it happens rarely, so no big
deal. */
- for (i = 0; i < fnpatts_used; i++) {
+ for (i = 0; i < VG_(sizeXA)(fnpatts); i++) {
Bool found = False;
- HChar* fnpatt = fnpatts[i];
+ const HChar* fnpatt = *(HChar**) VG_(indexXA)(fnpatts, i);
Int nsyms = VG_(DebugInfo_syms_howmany)(di);
for (j = 0; j < nsyms; j++) {
Bool isText = False;
}
/* All required specs were found. Just free memory and return. */
- for (i = 0; i < fnpatts_used; i++)
- VG_(free)(fnpatts[i]);
+ VG_(deleteXA)(fnpatts);
}
// other module imports this one, if only for VG_(clo_verbosity).
//--------------------------------------------------------------------
#include "pub_tool_options.h"
-
-/* The max number of suppression files. */
-#define VG_CLO_MAX_SFILES 100
-
-/* The max number of --require-text-symbol= specification strings. */
-#define VG_CLO_MAX_REQ_TSYMS 100
-
-/* The max number of --fullpath-after= parameters. */
-#define VG_CLO_MAX_FULLPATH_AFTER 100
+#include "pub_core_xarray.h"
/* Should we stop collecting errors if too many appear? default: YES */
extern Bool VG_(clo_error_limit);
/* Whether or not to load the default suppressions. */
extern Bool VG_(clo_default_supp);
-/* The number of suppression files specified. */
-extern Int VG_(clo_n_suppressions);
+
/* The names of the suppression files. */
-extern const HChar* VG_(clo_suppressions)[VG_CLO_MAX_SFILES];
+extern XArray *VG_(clo_suppressions);
/* An array of strings harvested from --fullpath-after= flags. */
-extern Int VG_(clo_n_fullpath_after);
-extern const HChar* VG_(clo_fullpath_after)[VG_CLO_MAX_FULLPATH_AFTER];
+extern XArray *VG_(clo_fullpath_after);
/* Full path to additional path to search for debug symbols */
extern const HChar* VG_(clo_extra_debuginfo_path);
silently with the un-marked-up library. Note that you should put
the entire flag in quotes to stop shells messing up the * and ?
wildcards. */
-extern Int VG_(clo_n_req_tsyms);
-extern const HChar* VG_(clo_req_tsyms)[VG_CLO_MAX_REQ_TSYMS];
+extern XArray *VG_(clo_req_tsyms);
/* Track open file descriptors? */
extern Bool VG_(clo_track_fds);