29 #define DEBUG_CONTEXT_LINES 0
34 #define DEBUG_DEPENDENCIES 0
42 const char line_prefix[] =
" | ";
43 char err_col[] =
"\033[31;1m";
44 char warn_col[] =
"\033[33;1m";
45 char info_col[] =
"\033[0;2m";
46 char reset_col[] =
"\033[0;0m";
51 err_col[0] = warn_col[0] = info_col[0] = reset_col[0] =
'\0';
56 #if DEBUG_DEPENDENCIES
58 dynstr,
"%s%sIncluded files (in order):%s\n", info_col, line_prefix, reset_col);
63 int64_t cursor = 0, line_count = 0;
64 while ((cursor =
src.find(
'\n', cursor) + 1)) {
67 if (sources_end_line.
is_empty() ==
false) {
68 line_count += sources_end_line.
last();
70 sources_end_line.
append(line_count);
71 #if DEBUG_DEPENDENCIES
75 dynstr,
"%s%s %s%s\n", info_col, line_prefix, filename.
c_str(), reset_col);
79 if (sources_end_line.
size() == 0) {
80 sources_end_line.
append(0);
83 char *log_line =
log, *line_end;
87 bool found_line_id =
false;
88 while ((line_end = strchr(log_line,
'\n'))) {
90 if (line_end == log_line) {
97 if (logref.
endswith(
" shader failed to compile with the following errors:") ||
98 logref.
endswith(
" No code generated")) {
99 log_line += (size_t)line_end - (
size_t)log_line;
104 log_line = parser->
parse_line(log_line, log_item);
116 found_line_id =
false;
122 const char *src_line = sources_combined;
135 const char *src_line_end;
136 found_line_id =
false;
138 int src_line_index = 1;
139 while ((src_line_end = strchr(src_line,
'\n'))) {
140 if (src_line_index >= log_item.
cursor.
row) {
141 found_line_id =
true;
149 src_line = src_line_end + 1;
172 src_line = src_line_end + 1;
174 while ((src_line_end = strchr(src_line,
'\n'))) {
181 src_line = src_line_end + 1;
191 if (source_index <= 0) {
193 if (log_item.
cursor.
row <= sources_end_line[i]) {
199 if (source_index > 0) {
200 row_in_file -= sources_end_line[source_index - 1];
203 if (source_index > 0) {
205 sources[source_index]);
228 log_line = line_end + 1;
229 previous_location = log_item.
cursor;
248 const char *error_msg,
249 const char *warning_msg)
const
251 if (
STREQLEN(log_line, error_msg, strlen(error_msg))) {
252 log_line += strlen(error_msg);
255 else if (
STREQLEN(log_line, warning_msg, strlen(warning_msg))) {
256 log_line += strlen(warning_msg);
264 while (
at_any(log_line, separators)) {
272 char *cursor = log_line;
273 while (!
ELEM(cursor[0],
'\n',
'\0')) {
274 if (cursor[0] == stop_char) {
284 return log_line[0] >=
'0' && log_line[0] <=
'9';
294 return (
int)strtol(log_line, r_new_position, 10);
A dynamically sized string ADT.
DynStr * BLI_dynstr_new(void) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT
void BLI_dynstr_nappend(DynStr *__restrict ds, const char *cstr, int len) ATTR_NONNULL()
char * BLI_dynstr_get_cstring(const DynStr *ds) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
void BLI_dynstr_free(DynStr *ds) ATTR_NONNULL()
void BLI_dynstr_appendf(DynStr *__restrict ds, const char *__restrict format,...) ATTR_PRINTF_FORMAT(2
void BLI_dynstr_append(DynStr *__restrict ds, const char *cstr) ATTR_NONNULL()
char * BLI_string_join_arrayN(const char *strings[], uint strings_len) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
#define STREQLEN(a, b, n)
void CLG_log_str(CLG_LogType *lg, enum CLG_Severity severity, const char *file_line, const char *fn, const char *message) _CLOG_ATTR_NONNULL(1
int CLG_color_support_get(CLG_LogRef *clg_ref)
Read Guarded memory(de)allocation.
constexpr const T * data() const
constexpr int64_t size() const
static constexpr int64_t not_found
constexpr int64_t find(char c, int64_t pos=0) const
constexpr bool is_empty() const
constexpr StringRef substr(int64_t start, int64_t size) const
constexpr bool endswith(StringRef suffix) const
constexpr const char * c_str() const
void append(const T &value)
const T & last(const int64_t n=0) const
IndexRange index_range() const
char * skip_separators(char *log_line, const StringRef separators) const
char * skip_severity(char *log_line, GPULogItem &log_item, const char *error_msg, const char *warning_msg) const
virtual char * parse_line(char *log_line, GPULogItem &log_item)=0
bool at_number(const char *log_line) const
int parse_number(const char *log_line, char **r_new_position) const
bool at_any(const char *log_line, const StringRef chars) const
char * skip_until(char *log_line, char stop_char) const
void print_log(Span< const char * > sources, char *log, const char *stage, bool error, GPULogParser *parser)
SyclQueue void void * src
#define DEBUG_CONTEXT_LINES
void(* MEM_freeN)(void *vmemh)
ccl_device_inline float3 log(float3 v)
static void error(const char *str)
StringRefNull gpu_shader_dependency_get_filename_from_source_string(const StringRefNull source_string)