Hash :
c5a38976
Author :
Date :
2021-09-01T07:35:40
Capture/Replay: Add expression trigger validation calls. Setting the environment variable "ANGLE_CAPTURE_VALIDATION_EXPR" will make ANGLE's capture logic evaluate this expression every captured call to see if it should insert a validation checkpoint. The retracing script also accepts --validation-expr as an argument. For instance, the expression: ((frame == 2) && (call < 1189) && (call > 1100) && ((call % 5) == 0)) Will insert validation checkpoints on frame 2, between calls 1100 and 1189 and will validate every 5th call. The 'call' here is the count of captured calls, which are mostly GL calls with a few ANGLE replay calls in the mix. We add a small single-header library that can evaluate arthithmetic expressions in order to parse these expressions, as well as an option to the retracing script. Bug: angleproject:5133 Change-Id: Ic369e85d8e905a3a7a32fa098f7d8ebe7baf4ab9 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3136094 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: Tim Van Patten <timvp@google.com> Reviewed-by: Cody Northrop <cnorthrop@google.com>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122
//
// Copyright 2015 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// string_utils:
// String helper functions.
//
#ifndef LIBANGLE_STRING_UTILS_H_
#define LIBANGLE_STRING_UTILS_H_
#include <string>
#include <vector>
#include "common/Optional.h"
namespace angle
{
extern const char kWhitespaceASCII[];
enum WhitespaceHandling
{
KEEP_WHITESPACE,
TRIM_WHITESPACE,
};
enum SplitResult
{
SPLIT_WANT_ALL,
SPLIT_WANT_NONEMPTY,
};
std::vector<std::string> SplitString(const std::string &input,
const std::string &delimiters,
WhitespaceHandling whitespace,
SplitResult resultType);
void SplitStringAlongWhitespace(const std::string &input, std::vector<std::string> *tokensOut);
std::string TrimString(const std::string &input, const std::string &trimChars);
// Return the substring starting at offset and up to the first occurance of the |delimeter|.
std::string GetPrefix(const std::string &input, size_t offset, const char *delimiter);
std::string GetPrefix(const std::string &input, size_t offset, char delimiter);
bool HexStringToUInt(const std::string &input, unsigned int *uintOut);
bool ReadFileToString(const std::string &path, std::string *stringOut);
// Check if the string str begins with the given prefix.
// The comparison is case sensitive.
bool BeginsWith(const std::string &str, const std::string &prefix);
// Check if the string str begins with the given prefix.
// Prefix may not be NULL and needs to be NULL terminated.
// The comparison is case sensitive.
bool BeginsWith(const std::string &str, const char *prefix);
// Check if the string str begins with the given prefix.
// str and prefix may not be NULL and need to be NULL terminated.
// The comparison is case sensitive.
bool BeginsWith(const char *str, const char *prefix);
// Check if the string str begins with the first prefixLength characters of the given prefix.
// The length of the prefix string should be greater than or equal to prefixLength.
// The comparison is case sensitive.
bool BeginsWith(const std::string &str, const std::string &prefix, const size_t prefixLength);
// Check if the string str ends with the given suffix.
// The comparison is case sensitive.
bool EndsWith(const std::string &str, const std::string &suffix);
// Check if the string str ends with the given suffix.
// Suffix may not be NULL and needs to be NULL terminated.
// The comparison is case sensitive.
bool EndsWith(const std::string &str, const char *suffix);
// Check if the string str ends with the given suffix.
// str and suffix may not be NULL and need to be NULL terminated.
// The comparison is case sensitive.
bool EndsWith(const char *str, const char *suffix);
// Check if the given token string contains the given token.
// The tokens are separated by the given delimiter.
// The comparison is case sensitive.
bool ContainsToken(const std::string &tokenStr, char delimiter, const std::string &token);
// Convert to lower-case.
void ToLower(std::string *str);
// Convert to upper-case.
void ToUpper(std::string *str);
// Replaces the substring 'substring' in 'str' with 'replacement'. Returns true if successful.
bool ReplaceSubstring(std::string *str,
const std::string &substring,
const std::string &replacement);
// Replaces all substrings 'substring' in 'str' with 'replacement'. Returns count of replacements.
int ReplaceAllSubstrings(std::string *str,
const std::string &substring,
const std::string &replacement);
// Split up a string parsed from an environment variable.
std::vector<std::string> GetStringsFromEnvironmentVarOrAndroidProperty(const char *varName,
const char *propertyName,
const char *separator);
// Split up a string parsed from environment variable or via Android property, use cached result if
// available.
std::vector<std::string> GetCachedStringsFromEnvironmentVarOrAndroidProperty(
const char *varName,
const char *propertyName,
const char *separator);
// reference name can have *.
bool NamesMatchWithWildcard(const char *ref, const char *testName);
} // namespace angle
#endif // LIBANGLE_STRING_UTILS_H_