From f9a4a0a9710c23a2041673eec290ff2f9260cbd0 Mon Sep 17 00:00:00 2001 From: Pauli Nieminen Date: Sun, 30 Aug 2009 16:48:33 +0300 Subject: radeon: Add common debugging functions. These function are aiming to make it very simple to add and keep large amount of debugging code without having runtime impact in relase builds. Basic idea is to expose simple printf style debugging functions that are inlined. Level parameter will be evalueted in compile time so compiler can optimise some of debugging functions out if compile time request for debug level is too tight. --- src/mesa/drivers/dri/radeon/radeon_debug.c | 62 ++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 src/mesa/drivers/dri/radeon/radeon_debug.c (limited to 'src/mesa/drivers/dri/radeon/radeon_debug.c') diff --git a/src/mesa/drivers/dri/radeon/radeon_debug.c b/src/mesa/drivers/dri/radeon/radeon_debug.c new file mode 100644 index 0000000000..b5e7b668ce --- /dev/null +++ b/src/mesa/drivers/dri/radeon/radeon_debug.c @@ -0,0 +1,62 @@ +/* + * Copyright © 2009 Pauli Nieminen + * 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, sub license, 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 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 NON-INFRINGEMENT. IN NO EVENT SHALL + * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS 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. + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial portions + * of the Software. + */ +/* + * Authors: + * Pauli Nieminen + */ + +#include "utils.h" + +#include "radeon_debug.h" + +static const struct dri_debug_control debug_control[] = { + {"fall", RADEON_FALLBACKS}, + {"tex", RADEON_TEXTURE}, + {"ioctl", RADEON_IOCTL}, + {"render", RADEON_RENDER}, + {"swrender", RADEON_SWRENDER}, + {"state", RADEON_STATE}, + {"shader", RADEON_SHADER}, + {"vfmt", RADEON_VFMT}, + {"vtxf", RADEON_VFMT}, + {"dri", RADEON_DRI}, + {"dma", RADEON_DMA}, + {"sanity", RADEON_SANITY}, + {"sync", RADEON_SYNC}, + {"pixel", RADEON_PIXEL}, + {"mem", RADEON_MEMORY}, + {"cs", RADEON_CS}, + {"allmsg", ~RADEON_SYNC}, /* avoid the term "sync" because the parser uses strstr */ + {NULL, 0} +}; + +radeon_debug_type_t radeon_enabled_debug_types; + +void radeon_init_debug(void) +{ + radeon_enabled_debug_types = driParseDebugString(getenv("RADEON_DEBUG"), debug_control); + + radeon_enabled_debug_types |= RADEON_GENERAL; +} -- cgit v1.2.3 From 4e0d99a63588c67a955f797733da32d04e6f4ee6 Mon Sep 17 00:00:00 2001 From: Pauli Nieminen Date: Sun, 30 Aug 2009 19:44:16 +0300 Subject: r100: Use shared debug code. Converted r100 to use shared debug code with sed and fast compile check. New code has compability layer so old debugging code doesn't have to be changed all immidiatly. --- src/mesa/drivers/dri/radeon/radeon_debug.c | 1 + 1 file changed, 1 insertion(+) (limited to 'src/mesa/drivers/dri/radeon/radeon_debug.c') diff --git a/src/mesa/drivers/dri/radeon/radeon_debug.c b/src/mesa/drivers/dri/radeon/radeon_debug.c index b5e7b668ce..cb1fd63cf7 100644 --- a/src/mesa/drivers/dri/radeon/radeon_debug.c +++ b/src/mesa/drivers/dri/radeon/radeon_debug.c @@ -35,6 +35,7 @@ static const struct dri_debug_control debug_control[] = { {"fall", RADEON_FALLBACKS}, {"tex", RADEON_TEXTURE}, {"ioctl", RADEON_IOCTL}, + {"verts", RADEON_RENDER}, {"render", RADEON_RENDER}, {"swrender", RADEON_SWRENDER}, {"state", RADEON_STATE}, -- cgit v1.2.3 From fde929c4fdee2e998542f071ff7165d87f572593 Mon Sep 17 00:00:00 2001 From: Pauli Nieminen Date: Mon, 31 Aug 2009 20:25:33 +0300 Subject: radeon: Add support for indenting debug output. Indetion can be used to make it easier to read debug code when sections of debug output are indented. --- src/mesa/drivers/dri/radeon/radeon_debug.c | 35 ++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) (limited to 'src/mesa/drivers/dri/radeon/radeon_debug.c') diff --git a/src/mesa/drivers/dri/radeon/radeon_debug.c b/src/mesa/drivers/dri/radeon/radeon_debug.c index cb1fd63cf7..691680e956 100644 --- a/src/mesa/drivers/dri/radeon/radeon_debug.c +++ b/src/mesa/drivers/dri/radeon/radeon_debug.c @@ -30,6 +30,7 @@ #include "utils.h" #include "radeon_debug.h" +#include "radeon_common_context.h" static const struct dri_debug_control debug_control[] = { {"fall", RADEON_FALLBACKS}, @@ -61,3 +62,37 @@ void radeon_init_debug(void) radeon_enabled_debug_types |= RADEON_GENERAL; } + +void _radeon_debug_add_indent(void) +{ + GET_CURRENT_CONTEXT(ctx); + radeonContextPtr radeon = RADEON_CONTEXT(ctx); + const size_t length = sizeof(radeon->debug.indent) + / sizeof(radeon->debug.indent[0]); + if (radeon->debug.indent_depth < length - 1) { + radeon->debug.indent[radeon->debug.indent_depth] = '\t'; + ++radeon->debug.indent_depth; + }; +} + +void _radeon_debug_remove_indent(void) +{ + GET_CURRENT_CONTEXT(ctx); + radeonContextPtr radeon = RADEON_CONTEXT(ctx); + if (radeon->debug.indent_depth > 0) { + radeon->debug.indent[radeon->debug.indent_depth] = '\0'; + --radeon->debug.indent_depth; + } +} + +extern void _radeon_print(const radeon_debug_type_t type, + const radeon_debug_level_t level, + const char* message, + va_list values) +{ + GET_CURRENT_CONTEXT(ctx); + radeonContextPtr radeon = RADEON_CONTEXT(ctx); + // FIXME: Make this multi thread safe + fprintf(stderr, "%s", radeon->debug.indent); + vfprintf(stderr, message, values); +} -- cgit v1.2.3 From c4a3e036ed1c755a291018251c4f55c45ac17079 Mon Sep 17 00:00:00 2001 From: Pauli Nieminen Date: Tue, 1 Sep 2009 00:39:20 +0300 Subject: radeon: Fix null pointer reference in debug system if no context is bind. --- src/mesa/drivers/dri/radeon/radeon_debug.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'src/mesa/drivers/dri/radeon/radeon_debug.c') diff --git a/src/mesa/drivers/dri/radeon/radeon_debug.c b/src/mesa/drivers/dri/radeon/radeon_debug.c index 691680e956..a1ed39683f 100644 --- a/src/mesa/drivers/dri/radeon/radeon_debug.c +++ b/src/mesa/drivers/dri/radeon/radeon_debug.c @@ -91,8 +91,11 @@ extern void _radeon_print(const radeon_debug_type_t type, va_list values) { GET_CURRENT_CONTEXT(ctx); - radeonContextPtr radeon = RADEON_CONTEXT(ctx); - // FIXME: Make this multi thread safe - fprintf(stderr, "%s", radeon->debug.indent); + if (ctx) { + radeonContextPtr radeon = RADEON_CONTEXT(ctx); + // FIXME: Make this multi thread safe + if (radeon->debug.indent_depth) + fprintf(stderr, "%s", radeon->debug.indent); + } vfprintf(stderr, message, values); } -- cgit v1.2.3