mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-01-25 01:30:30 +01:00
Remove old error logging code. New slang_log.[ch] files.
This commit is contained in:
parent
c4ac5ac9d7
commit
ca279b80e6
3 changed files with 156 additions and 94 deletions
|
|
@ -1,78 +0,0 @@
|
|||
/*
|
||||
* Mesa 3-D graphics library
|
||||
* Version: 6.5.2
|
||||
*
|
||||
* Copyright (C) 2005-2006 Brian Paul All Rights Reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
|
||||
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "imports.h"
|
||||
#include "slang_error.h"
|
||||
|
||||
|
||||
static char ErrorText[10000];
|
||||
static char FormattedErrorText[10000];
|
||||
static int ErrorPos;
|
||||
|
||||
|
||||
void
|
||||
_slang_reset_error(void)
|
||||
{
|
||||
ErrorText[0] = 0;
|
||||
ErrorPos = -1;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Record an error message, if one hasn't been recorded already.
|
||||
*/
|
||||
void
|
||||
_slang_record_error(const char *msg1, const char *msg2,
|
||||
GLint pos, const char *file, int line)
|
||||
{
|
||||
/* don't overwrite a previously recorded error */
|
||||
if (!ErrorText[0]) {
|
||||
_mesa_sprintf(ErrorText, "%s %s", msg1, msg2);
|
||||
ErrorPos = -1;
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "Mesa shader compile error: %s %s at %d (%s line %d)\n",
|
||||
msg1, msg2, pos, file, line);
|
||||
#endif
|
||||
}
|
||||
abort();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return formatted error text.
|
||||
*/
|
||||
const char *
|
||||
_slang_error_text(void)
|
||||
{
|
||||
/*
|
||||
* NVIDIA formats errors like this:
|
||||
* (LINE_NUMBER) : error ERROR_CODE: ERROR_TEXT
|
||||
* Example:
|
||||
* (7) : error C1048: invalid character 'P' in swizzle "P"
|
||||
*/
|
||||
_mesa_sprintf(FormattedErrorText,
|
||||
"(%d) : error: %s", ErrorPos, ErrorText);
|
||||
return FormattedErrorText;
|
||||
}
|
||||
|
||||
128
src/mesa/shader/slang/slang_log.c
Normal file
128
src/mesa/shader/slang/slang_log.c
Normal file
|
|
@ -0,0 +1,128 @@
|
|||
/*
|
||||
* Mesa 3-D graphics library
|
||||
* Version: 6.5.3
|
||||
*
|
||||
* Copyright (C) 2005-2007 Brian Paul All Rights Reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
|
||||
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "imports.h"
|
||||
#include "slang_log.h"
|
||||
#include "slang_utility.h"
|
||||
|
||||
|
||||
|
||||
static char *out_of_memory = "Error: Out of memory.\n";
|
||||
|
||||
void
|
||||
slang_info_log_construct(slang_info_log * log)
|
||||
{
|
||||
log->text = NULL;
|
||||
log->dont_free_text = 0;
|
||||
}
|
||||
|
||||
void
|
||||
slang_info_log_destruct(slang_info_log * log)
|
||||
{
|
||||
if (!log->dont_free_text)
|
||||
slang_alloc_free(log->text);
|
||||
}
|
||||
|
||||
static int
|
||||
slang_info_log_message(slang_info_log * log, const char *prefix,
|
||||
const char *msg)
|
||||
{
|
||||
GLuint size;
|
||||
|
||||
if (log->dont_free_text)
|
||||
return 0;
|
||||
size = slang_string_length(msg) + 2;
|
||||
if (prefix != NULL)
|
||||
size += slang_string_length(prefix) + 2;
|
||||
if (log->text != NULL) {
|
||||
GLuint old_len = slang_string_length(log->text);
|
||||
log->text = (char *)
|
||||
slang_alloc_realloc(log->text, old_len + 1, old_len + size);
|
||||
}
|
||||
else {
|
||||
log->text = (char *) (slang_alloc_malloc(size));
|
||||
if (log->text != NULL)
|
||||
log->text[0] = '\0';
|
||||
}
|
||||
if (log->text == NULL)
|
||||
return 0;
|
||||
if (prefix != NULL) {
|
||||
slang_string_concat(log->text, prefix);
|
||||
slang_string_concat(log->text, ": ");
|
||||
}
|
||||
slang_string_concat(log->text, msg);
|
||||
slang_string_concat(log->text, "\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
int
|
||||
slang_info_log_print(slang_info_log * log, const char *msg, ...)
|
||||
{
|
||||
va_list va;
|
||||
char buf[1024];
|
||||
|
||||
va_start(va, msg);
|
||||
_mesa_vsprintf(buf, msg, va);
|
||||
va_end(va);
|
||||
return slang_info_log_message(log, NULL, buf);
|
||||
}
|
||||
|
||||
int
|
||||
slang_info_log_error(slang_info_log * log, const char *msg, ...)
|
||||
{
|
||||
va_list va;
|
||||
char buf[1024];
|
||||
|
||||
va_start(va, msg);
|
||||
_mesa_vsprintf(buf, msg, va);
|
||||
va_end(va);
|
||||
if (slang_info_log_message(log, "Error", buf))
|
||||
return 1;
|
||||
slang_info_log_memory(log);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
slang_info_log_warning(slang_info_log * log, const char *msg, ...)
|
||||
{
|
||||
va_list va;
|
||||
char buf[1024];
|
||||
|
||||
va_start(va, msg);
|
||||
_mesa_vsprintf(buf, msg, va);
|
||||
va_end(va);
|
||||
if (slang_info_log_message(log, "Warning", buf))
|
||||
return 1;
|
||||
slang_info_log_memory(log);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
slang_info_log_memory(slang_info_log * log)
|
||||
{
|
||||
if (!slang_info_log_message(log, "Error", "Out of memory.")) {
|
||||
log->dont_free_text = 1;
|
||||
log->text = out_of_memory;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,8 +1,8 @@
|
|||
/*
|
||||
* Mesa 3-D graphics library
|
||||
* Version: 6.5.2
|
||||
* Version: 6.5.3
|
||||
*
|
||||
* Copyright (C) 2005-2006 Brian Paul All Rights Reserved.
|
||||
* Copyright (C) 2005-2007 Brian Paul All Rights Reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
|
|
@ -22,23 +22,35 @@
|
|||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef SLANG_ERROR_H
|
||||
#define SLANG_ERROR_H
|
||||
|
||||
#if 0
|
||||
extern void
|
||||
_slang_reset_error(void);
|
||||
#ifndef SLANG_LOG_H
|
||||
#define SLANG_LOG_H
|
||||
|
||||
|
||||
typedef struct slang_info_log_
|
||||
{
|
||||
char *text;
|
||||
int dont_free_text;
|
||||
} slang_info_log;
|
||||
|
||||
|
||||
extern void
|
||||
_slang_record_error(const char *msg1, const char *msg2,
|
||||
GLint pos, const char *file, int line);
|
||||
slang_info_log_construct(slang_info_log *);
|
||||
|
||||
extern void
|
||||
slang_info_log_destruct(slang_info_log *);
|
||||
|
||||
extern int
|
||||
slang_info_log_print(slang_info_log *, const char *, ...);
|
||||
|
||||
extern int
|
||||
slang_info_log_error(slang_info_log *, const char *, ...);
|
||||
|
||||
extern int
|
||||
slang_info_log_warning(slang_info_log *, const char *, ...);
|
||||
|
||||
extern void
|
||||
slang_info_log_memory(slang_info_log *);
|
||||
|
||||
|
||||
extern const char *
|
||||
_slang_error_text(void);
|
||||
#endif
|
||||
foo!
|
||||
|
||||
|
||||
#endif /* SLANG_ERROR_H */
|
||||
#endif /* SLANG_LOG_H */
|
||||
Loading…
Add table
Reference in a new issue