From: Chia-I Wu Date: Tue, 22 Apr 2014 05:32:18 +0000 (+0800) Subject: mesa: eliminate debug output get_msg X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=274913c42c2359a9f7716beb72095613a8a934c6;p=mesa.git mesa: eliminate debug output get_msg Merge get_msg with the only caller. No functional change. Signed-off-by: Chia-I Wu Reviewed-by: Brian Paul --- diff --git a/src/mesa/main/errors.c b/src/mesa/main/errors.c index f3630498c9c..2b5959a1e3c 100644 --- a/src/mesa/main/errors.c +++ b/src/mesa/main/errors.c @@ -677,66 +677,6 @@ log_msg(struct gl_context *ctx, enum mesa_debug_source source, } -/** - * Pop the oldest debug message out of the log. - * Writes the message string, including the null terminator, into 'buf', - * using up to 'bufSize' bytes. If 'bufSize' is too small, or - * if 'buf' is NULL, nothing is written. - * - * Returns the number of bytes written on success, or when 'buf' is NULL, - * the number that would have been written. A return value of 0 - * indicates failure. - */ -static GLsizei -get_msg(struct gl_context *ctx, GLenum *source, GLenum *type, - GLuint *id, GLenum *severity, GLsizei bufSize, char *buf) -{ - struct gl_debug_state *debug = _mesa_get_debug_state(ctx); - const struct gl_debug_msg *msg; - GLsizei length; - - if (!debug) - return 0; - - msg = debug_fetch_message(debug); - if (!msg) - return 0; - - msg = &debug->Log[debug->NextMsg]; - length = msg->length; - - assert(length > 0 && length == debug->NextMsgLength); - - if (bufSize < length && buf != NULL) - return 0; - - if (severity) { - *severity = debug_severity_enums[msg->severity]; - } - - if (source) { - *source = debug_source_enums[msg->source]; - } - - if (type) { - *type = debug_type_enums[msg->type]; - } - - if (id) { - *id = msg->id; - } - - if (buf) { - assert(msg->message[length-1] == '\0'); - (void) strncpy(buf, msg->message, (size_t)length); - } - - debug_delete_messages(debug, 1); - - return length; -} - - /** * Verify that source, type, and severity are valid enums. * @@ -916,6 +856,7 @@ _mesa_GetDebugMessageLog(GLuint count, GLsizei logSize, GLenum *sources, GLsizei *lengths, GLchar *messageLog) { GET_CURRENT_CONTEXT(ctx); + struct gl_debug_state *debug; GLuint ret; if (!messageLog) @@ -928,29 +869,41 @@ _mesa_GetDebugMessageLog(GLuint count, GLsizei logSize, GLenum *sources, return 0; } + debug = _mesa_get_debug_state(ctx); + if (!debug) + return 0; + for (ret = 0; ret < count; ret++) { - GLsizei written = get_msg(ctx, sources, types, ids, severities, - logSize, messageLog); - if (!written) + const struct gl_debug_msg *msg = debug_fetch_message(debug); + + if (!msg) + break; + + assert(msg->length > 0 && msg->length == debug->NextMsgLength); + + if (logSize < msg->length && messageLog != NULL) break; if (messageLog) { - messageLog += written; - logSize -= written; - } - if (lengths) { - *lengths = written; - lengths++; + assert(msg->message[msg->length-1] == '\0'); + (void) strncpy(messageLog, msg->message, (size_t)msg->length); + + messageLog += msg->length; + logSize -= msg->length; } + if (lengths) + *lengths++ = msg->length; if (severities) - severities++; + *severities++ = debug_severity_enums[msg->severity]; if (sources) - sources++; + *sources++ = debug_source_enums[msg->source]; if (types) - types++; + *types++ = debug_type_enums[msg->type]; if (ids) - ids++; + *ids++ = msg->id; + + debug_delete_messages(debug, 1); } return ret;