summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorChia-I Wu <[email protected]>2014-04-22 13:32:18 +0800
committerChia-I Wu <[email protected]>2014-04-27 10:06:20 +0800
commit274913c42c2359a9f7716beb72095613a8a934c6 (patch)
tree1788e8f86720eaca6ac7ff37c93a613f25fd181e /src
parent04a8baad3721896f70353638866423bd699fbcd2 (diff)
mesa: eliminate debug output get_msg
Merge get_msg with the only caller. No functional change. Signed-off-by: Chia-I Wu <[email protected]> Reviewed-by: Brian Paul <[email protected]>
Diffstat (limited to 'src')
-rw-r--r--src/mesa/main/errors.c99
1 files changed, 26 insertions, 73 deletions
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
@@ -678,66 +678,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.
*
* The 'caller' param is used for handling values available
@@ -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;