util/debug: update parse_enable_string to deal with +all/-all

Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Reviewed-by: Danylo Piliaiev <dpiliaiev@igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/29944>
This commit is contained in:
Lionel Landwerlin 2024-06-28 11:17:43 +03:00 committed by Lionel Landwerlin
parent 4b1e3b8515
commit bc523e8949

View file

@ -450,31 +450,33 @@ parse_enable_string(const char *debug,
uint64_t flag = default_value;
if (debug != NULL) {
for (; control->string != NULL; control++) {
if (!strcmp(debug, "all")) {
flag |= control->flag;
const char *s = debug;
unsigned n;
for (; n = strcspn(s, ", "), *s; s += MAX2(1, n)) {
bool enable;
if (s[0] == '+') {
enable = true;
s++; n--;
} else if (s[0] == '-') {
enable = false;
s++; n--;
} else {
const char *s = debug;
unsigned n;
for (; n = strcspn(s, ", "), *s; s += MAX2(1, n)) {
bool enable;
if (s[0] == '+') {
enable = true;
s++; n--;
} else if (s[0] == '-') {
enable = false;
s++; n--;
} else {
enable = true;
}
if (strlen(control->string) == n &&
!strncmp(control->string, s, n)) {
enable = true;
}
if (!strncmp(s, "all", 3)) {
if (enable)
flag = ~0ull;
else
flag = 0;
} else {
for (const struct debug_control *c = control; c->string != NULL; c++) {
if (strlen(c->string) == n &&
!strncmp(c->string, s, n)) {
if (enable)
flag |= control->flag;
flag |= c->flag;
else
flag &= ~control->flag;
flag &= ~c->flag;
}
}
}