mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-20 22:30:12 +01:00
util: Add dump_debug_control_string to dump debug_control
Signed-off-by: Danylo Piliaiev <dpiliaiev@igalia.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/33491>
This commit is contained in:
parent
0886eda4f1
commit
5c87616d96
2 changed files with 41 additions and 0 deletions
|
|
@ -501,3 +501,39 @@ comma_separated_list_contains(const char *list, const char *s)
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
dump_debug_control_string(char *output,
|
||||||
|
size_t max_size,
|
||||||
|
const struct debug_control *control,
|
||||||
|
uint64_t flags)
|
||||||
|
{
|
||||||
|
size_t pos = 0;
|
||||||
|
int ret;
|
||||||
|
bool first = true;
|
||||||
|
|
||||||
|
for (const struct debug_control *c = control; c->string != NULL; c++) {
|
||||||
|
if (!(flags & c->flag))
|
||||||
|
continue;
|
||||||
|
ret = snprintf(output + pos, max_size - pos,
|
||||||
|
first ? "%s" : "|%s", c->string);
|
||||||
|
if (ret < 0 || ret >= max_size - pos) {
|
||||||
|
output[max_size-3] = output[max_size-2] = '.';
|
||||||
|
output[max_size-1] = '\0';
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
pos += ret;
|
||||||
|
first = false;
|
||||||
|
flags &= ~(c->flag);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (flags) {
|
||||||
|
ret = snprintf(output + pos, max_size - pos,
|
||||||
|
first ? "0x%" PRIx64 : "|0x%" PRIx64, flags);
|
||||||
|
if (ret < 0 || ret >= max_size - pos) {
|
||||||
|
output[max_size-3] = output[max_size-2] = '.';
|
||||||
|
output[max_size-1] = '\0';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -341,6 +341,11 @@ parse_enable_string(const char *debug,
|
||||||
uint64_t default_value,
|
uint64_t default_value,
|
||||||
const struct debug_control *control);
|
const struct debug_control *control);
|
||||||
|
|
||||||
|
void
|
||||||
|
dump_debug_control_string(char *output,
|
||||||
|
size_t max_size,
|
||||||
|
const struct debug_control *control,
|
||||||
|
uint64_t flags);
|
||||||
|
|
||||||
bool
|
bool
|
||||||
comma_separated_list_contains(const char *list, const char *s);
|
comma_separated_list_contains(const char *list, const char *s);
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue