On Tue, 2010-06-01 at 19:46 +0200, Joakim Sindholt wrote: > On Tue, 2010-06-01 at 17:24 +0100, José Fonseca wrote: > > On Tue, 2010-06-01 at 09:08 -0700, Joakim Sindholt wrote: > > > Hi. > > > I just had a look at debug options in u_debug, specifically enumerated > > > options in debug_get_flags_option(). It stands out that struct > > > debug_named_value doesn't have a description field, as is used in r300g. > > > I'm guessing that for this reason, r300g has it's own system, and I'm > > > reluctant to use it as well. > > > It can be quite useful to have a description available; especially when > > > you have options named "fp", "vp", "cs", "rs", "fb", etc. that aren't > > > exactly descriptive in their own right (at least for people unfamiliar > > > with the driver). > > > > > > Would it be acceptable to add a description field to debug_named_value? > > > > I think it might be useful. > > > > Just make sure NULL is valid description and ensure that the existing > > code is doesn't break or is fixed. > > > > E.g., add a new DEBUG_NAMED_VALUE_WITH_DESCRIPTION macro and keep > > DEBUG_NAMED_VALUE with the same number of args. > > > > Jose > > > > I devised a path that will output something like this: > > debug_get_flags_option: help for NINE_DEBUG: > | lib [0x00000001] Debugging information on library interface > | xnine [0x00000002] Show X11 winsys information > debug_get_flags_option: NINE_DEBUG = 0x0 (help) > > Any comments on the layout? Anything that should be aligned differently? > Each argument is printed out with a pretty ugly format string: > debug_printf("| %*s [0x%0*lx]%s%s\n", namealign, flags->name, > sizeof(unsigned long)*CHAR_BIT/4, flags->value, > flags->desc ? " " : "", flags->desc ? flags->desc : "");
Patches attached. If there are no objections I'll push these.
>From f49ffe4059776522205cb84db0a7e575d30f817f Mon Sep 17 00:00:00 2001 From: Joakim Sindholt <opensou...@zhasha.com> Date: Tue, 1 Jun 2010 20:11:02 +0200 Subject: [PATCH 1/3] util/u_debug: add description field to debug_named_value --- src/gallium/auxiliary/util/u_debug.c | 20 ++++++++++++++++---- src/gallium/auxiliary/util/u_debug.h | 6 ++++-- 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/src/gallium/auxiliary/util/u_debug.c b/src/gallium/auxiliary/util/u_debug.c index 86db2c2..3d913be 100644 --- a/src/gallium/auxiliary/util/u_debug.c +++ b/src/gallium/auxiliary/util/u_debug.c @@ -42,6 +42,7 @@ #include "util/u_tile.h" #include "util/u_prim.h" +#include <limits.h> /* CHAR_BIT */ void _debug_vprintf(const char *format, va_list ap) { @@ -173,6 +174,12 @@ debug_get_num_option(const char *name, long dfault) return result; } +static INLINE int +max( int a, + int b ) +{ + return (a > b) ? a : b; +} unsigned long debug_get_flags_option(const char *name, @@ -181,16 +188,21 @@ debug_get_flags_option(const char *name, { unsigned long result; const char *str; + const struct debug_named_value *orig = flags; + int namealign = 0; str = os_get_option(name); if(!str) result = dfault; else if (!util_strcmp(str, "help")) { result = dfault; - while (flags->name) { - debug_printf("%s: help for %s: %s [0x%lx]\n", __FUNCTION__, name, flags->name, flags->value); - flags++; - } + debug_printf("%s: help for %s:\n", __FUNCTION__, name); + for (; flags->name; ++flags) + namealign = max(namealign, strlen(flags->name)); + for (flags = orig; flags->name; ++flags) + debug_printf("| %*s [0x%0*lx]%s%s\n", namealign, flags->name, + sizeof(unsigned long)*CHAR_BIT/4, flags->value, + flags->desc ? " " : "", flags->desc ? flags->desc : ""); } else { result = 0; diff --git a/src/gallium/auxiliary/util/u_debug.h b/src/gallium/auxiliary/util/u_debug.h index e8ff277..1c9624e 100644 --- a/src/gallium/auxiliary/util/u_debug.h +++ b/src/gallium/auxiliary/util/u_debug.h @@ -230,6 +230,7 @@ struct debug_named_value { const char *name; unsigned long value; + const char *desc; }; @@ -252,8 +253,9 @@ struct debug_named_value * ... * @endcode */ -#define DEBUG_NAMED_VALUE(__symbol) {#__symbol, (unsigned long)__symbol} -#define DEBUG_NAMED_VALUE_END {NULL, 0} +#define DEBUG_NAMED_VALUE(__symbol) DEBUG_NAMED_VALUE_WITH_DESCRIPTION(__symbol, NULL) +#define DEBUG_NAMED_VALUE_WITH_DESCRIPTION(__symbol, __desc) {#__symbol, (unsigned long)__symbol, __desc} +#define DEBUG_NAMED_VALUE_END {NULL, 0, NULL} /** -- 1.7.0.1
>From d349d51658ab30d9ff3182577e968402289eb715 Mon Sep 17 00:00:00 2001 From: Joakim Sindholt <opensou...@zhasha.com> Date: Tue, 1 Jun 2010 20:11:30 +0200 Subject: [PATCH 2/3] gallium: silence all debug_named_value related warnings --- src/gallium/auxiliary/gallivm/lp_bld_init.c | 10 ++-- src/gallium/drivers/cell/ppu/cell_context.c | 16 ++++---- src/gallium/drivers/i965/brw_screen.c | 58 +++++++++++++------------- src/gallium/drivers/llvmpipe/lp_screen.c | 22 +++++----- src/gallium/drivers/svga/svga_screen.c | 30 +++++++------- src/gallium/drivers/trace/tr_context.c | 6 +- src/mesa/state_tracker/st_debug.c | 18 ++++---- 7 files changed, 80 insertions(+), 80 deletions(-) diff --git a/src/gallium/auxiliary/gallivm/lp_bld_init.c b/src/gallium/auxiliary/gallivm/lp_bld_init.c index e02a451..174e20e 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_init.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_init.c @@ -37,11 +37,11 @@ unsigned gallivm_debug = 0; static const struct debug_named_value lp_bld_debug_flags[] = { - { "tgsi", GALLIVM_DEBUG_TGSI }, - { "ir", GALLIVM_DEBUG_IR }, - { "asm", GALLIVM_DEBUG_ASM }, - { "nopt", GALLIVM_DEBUG_NO_OPT }, - {NULL, 0} + { "tgsi", GALLIVM_DEBUG_TGSI, NULL }, + { "ir", GALLIVM_DEBUG_IR, NULL }, + { "asm", GALLIVM_DEBUG_ASM, NULL }, + { "nopt", GALLIVM_DEBUG_NO_OPT, NULL }, + DEBUG_NAMED_VALUE_END }; #endif diff --git a/src/gallium/drivers/cell/ppu/cell_context.c b/src/gallium/drivers/cell/ppu/cell_context.c index 411f204..143eca8 100644 --- a/src/gallium/drivers/cell/ppu/cell_context.c +++ b/src/gallium/drivers/cell/ppu/cell_context.c @@ -88,14 +88,14 @@ cell_draw_create(struct cell_context *cell) static const struct debug_named_value cell_debug_flags[] = { - {"checker", CELL_DEBUG_CHECKER},/**< modulate tile clear color by SPU ID */ - {"asm", CELL_DEBUG_ASM}, /**< dump SPU asm code */ - {"sync", CELL_DEBUG_SYNC}, /**< SPUs do synchronous DMA */ - {"fragops", CELL_DEBUG_FRAGMENT_OPS}, /**< SPUs emit fragment ops debug messages*/ - {"fragopfallback", CELL_DEBUG_FRAGMENT_OP_FALLBACK}, /**< SPUs use reference implementation for fragment ops*/ - {"cmd", CELL_DEBUG_CMD}, /**< SPUs dump command buffer info */ - {"cache", CELL_DEBUG_CACHE}, /**< report texture cache stats on exit */ - {NULL, 0} + {"checker", CELL_DEBUG_CHECKER, NULL},/**< modulate tile clear color by SPU ID */ + {"asm", CELL_DEBUG_ASM, NULL}, /**< dump SPU asm code */ + {"sync", CELL_DEBUG_SYNC, NULL}, /**< SPUs do synchronous DMA */ + {"fragops", CELL_DEBUG_FRAGMENT_OPS, NULL}, /**< SPUs emit fragment ops debug messages*/ + {"fragopfallback", CELL_DEBUG_FRAGMENT_OP_FALLBACK, NULL}, /**< SPUs use reference implementation for fragment ops*/ + {"cmd", CELL_DEBUG_CMD, NULL}, /**< SPUs dump command buffer info */ + {"cache", CELL_DEBUG_CACHE, NULL}, /**< report texture cache stats on exit */ + DEBUG_NAMED_VALUE_END }; static unsigned int diff --git a/src/gallium/drivers/i965/brw_screen.c b/src/gallium/drivers/i965/brw_screen.c index 7a7b9c1..5a45687 100644 --- a/src/gallium/drivers/i965/brw_screen.c +++ b/src/gallium/drivers/i965/brw_screen.c @@ -39,38 +39,38 @@ #ifdef DEBUG static const struct debug_named_value debug_names[] = { - { "tex", DEBUG_TEXTURE}, - { "state", DEBUG_STATE}, - { "ioctl", DEBUG_IOCTL}, - { "blit", DEBUG_BLIT}, - { "curbe", DEBUG_CURBE}, - { "fall", DEBUG_FALLBACKS}, - { "verb", DEBUG_VERBOSE}, - { "bat", DEBUG_BATCH}, - { "pix", DEBUG_PIXEL}, - { "wins", DEBUG_WINSYS}, - { "min", DEBUG_MIN_URB}, - { "dis", DEBUG_DISASSEM}, - { "sync", DEBUG_SYNC}, - { "prim", DEBUG_PRIMS }, - { "vert", DEBUG_VERTS }, - { "dma", DEBUG_DMA }, - { "san", DEBUG_SANITY }, - { "sleep", DEBUG_SLEEP }, - { "stats", DEBUG_STATS }, - { "sing", DEBUG_SINGLE_THREAD }, - { "thre", DEBUG_SINGLE_THREAD }, - { "wm", DEBUG_WM }, - { "urb", DEBUG_URB }, - { "vs", DEBUG_VS }, - { NULL, 0 } + { "tex", DEBUG_TEXTURE, NULL }, + { "state", DEBUG_STATE, NULL }, + { "ioctl", DEBUG_IOCTL, NULL }, + { "blit", DEBUG_BLIT, NULL }, + { "curbe", DEBUG_CURBE, NULL }, + { "fall", DEBUG_FALLBACKS, NULL }, + { "verb", DEBUG_VERBOSE, NULL }, + { "bat", DEBUG_BATCH, NULL }, + { "pix", DEBUG_PIXEL, NULL }, + { "wins", DEBUG_WINSYS, NULL }, + { "min", DEBUG_MIN_URB, NULL }, + { "dis", DEBUG_DISASSEM, NULL }, + { "sync", DEBUG_SYNC, NULL }, + { "prim", DEBUG_PRIMS, NULL }, + { "vert", DEBUG_VERTS, NULL }, + { "dma", DEBUG_DMA, NULL }, + { "san", DEBUG_SANITY, NULL }, + { "sleep", DEBUG_SLEEP, NULL }, + { "stats", DEBUG_STATS, NULL }, + { "sing", DEBUG_SINGLE_THREAD, NULL }, + { "thre", DEBUG_SINGLE_THREAD, NULL }, + { "wm", DEBUG_WM, NULL }, + { "urb", DEBUG_URB, NULL }, + { "vs", DEBUG_VS, NULL }, + DEBUG_NAMED_VALUE_END }; static const struct debug_named_value dump_names[] = { - { "asm", DUMP_ASM}, - { "state", DUMP_STATE}, - { "batch", DUMP_BATCH}, - { NULL, 0 } + { "asm", DUMP_ASM, NULL }, + { "state", DUMP_STATE, NULL }, + { "batch", DUMP_BATCH, NULL }, + DEBUG_NAMED_VALUE_END }; int BRW_DEBUG = 0; diff --git a/src/gallium/drivers/llvmpipe/lp_screen.c b/src/gallium/drivers/llvmpipe/lp_screen.c index 34ad298..98ac11d 100644 --- a/src/gallium/drivers/llvmpipe/lp_screen.c +++ b/src/gallium/drivers/llvmpipe/lp_screen.c @@ -50,17 +50,17 @@ int LP_DEBUG = 0; static const struct debug_named_value lp_debug_flags[] = { - { "pipe", DEBUG_PIPE }, - { "tgsi", DEBUG_TGSI }, - { "tex", DEBUG_TEX }, - { "setup", DEBUG_SETUP }, - { "rast", DEBUG_RAST }, - { "query", DEBUG_QUERY }, - { "screen", DEBUG_SCREEN }, - { "show_tiles", DEBUG_SHOW_TILES }, - { "show_subtiles", DEBUG_SHOW_SUBTILES }, - { "counters", DEBUG_COUNTERS }, - {NULL, 0} + { "pipe", DEBUG_PIPE, NULL }, + { "tgsi", DEBUG_TGSI, NULL }, + { "tex", DEBUG_TEX, NULL }, + { "setup", DEBUG_SETUP, NULL }, + { "rast", DEBUG_RAST, NULL }, + { "query", DEBUG_QUERY, NULL }, + { "screen", DEBUG_SCREEN, NULL }, + { "show_tiles", DEBUG_SHOW_TILES, NULL }, + { "show_subtiles", DEBUG_SHOW_SUBTILES, NULL }, + { "counters", DEBUG_COUNTERS, NULL }, + DEBUG_NAMED_VALUE_END }; #endif diff --git a/src/gallium/drivers/svga/svga_screen.c b/src/gallium/drivers/svga/svga_screen.c index 99b4191..3de04d0 100644 --- a/src/gallium/drivers/svga/svga_screen.c +++ b/src/gallium/drivers/svga/svga_screen.c @@ -43,21 +43,21 @@ int SVGA_DEBUG = 0; static const struct debug_named_value svga_debug_flags[] = { - { "dma", DEBUG_DMA }, - { "tgsi", DEBUG_TGSI }, - { "pipe", DEBUG_PIPE }, - { "state", DEBUG_STATE }, - { "screen", DEBUG_SCREEN }, - { "tex", DEBUG_TEX }, - { "swtnl", DEBUG_SWTNL }, - { "const", DEBUG_CONSTS }, - { "viewport", DEBUG_VIEWPORT }, - { "views", DEBUG_VIEWS }, - { "perf", DEBUG_PERF }, - { "flush", DEBUG_FLUSH }, - { "sync", DEBUG_SYNC }, - { "cache", DEBUG_CACHE }, - {NULL, 0} + { "dma", DEBUG_DMA, NULL }, + { "tgsi", DEBUG_TGSI, NULL }, + { "pipe", DEBUG_PIPE, NULL }, + { "state", DEBUG_STATE, NULL }, + { "screen", DEBUG_SCREEN, NULL }, + { "tex", DEBUG_TEX, NULL }, + { "swtnl", DEBUG_SWTNL, NULL }, + { "const", DEBUG_CONSTS, NULL }, + { "viewport", DEBUG_VIEWPORT, NULL }, + { "views", DEBUG_VIEWS, NULL }, + { "perf", DEBUG_PERF, NULL }, + { "flush", DEBUG_FLUSH, NULL }, + { "sync", DEBUG_SYNC, NULL }, + { "cache", DEBUG_CACHE, NULL }, + DEBUG_NAMED_VALUE_END }; #endif diff --git a/src/gallium/drivers/trace/tr_context.c b/src/gallium/drivers/trace/tr_context.c index 5cc244d..344a50b 100644 --- a/src/gallium/drivers/trace/tr_context.c +++ b/src/gallium/drivers/trace/tr_context.c @@ -1380,9 +1380,9 @@ trace_context_transfer_inline_write(struct pipe_context *_context, static const struct debug_named_value rbug_blocker_flags[] = { - {"before", 1}, - {"after", 2}, - {NULL, 0}, + {"before", 1, NULL}, + {"after", 2, NULL}, + DEBUG_NAMED_VALUE_END }; struct pipe_context * diff --git a/src/mesa/state_tracker/st_debug.c b/src/mesa/state_tracker/st_debug.c index 2da27fc..0b37683 100644 --- a/src/mesa/state_tracker/st_debug.c +++ b/src/mesa/state_tracker/st_debug.c @@ -45,15 +45,15 @@ int ST_DEBUG = 0; static const struct debug_named_value st_debug_flags[] = { - { "mesa", DEBUG_MESA }, - { "tgsi", DEBUG_TGSI }, - { "constants",DEBUG_CONSTANTS }, - { "pipe", DEBUG_PIPE }, - { "tex", DEBUG_TEX }, - { "fallback", DEBUG_FALLBACK }, - { "screen", DEBUG_SCREEN }, - { "query", DEBUG_QUERY }, - {NULL, 0} + { "mesa", DEBUG_MESA, NULL }, + { "tgsi", DEBUG_TGSI, NULL }, + { "constants",DEBUG_CONSTANTS, NULL }, + { "pipe", DEBUG_PIPE, NULL }, + { "tex", DEBUG_TEX, NULL }, + { "fallback", DEBUG_FALLBACK, NULL }, + { "screen", DEBUG_SCREEN, NULL }, + { "query", DEBUG_QUERY, NULL }, + DEBUG_NAMED_VALUE_END }; #endif -- 1.7.0.1
>From f6bf0638b88e0da7c86616dd2fe2df500bb99303 Mon Sep 17 00:00:00 2001 From: Joakim Sindholt <opensou...@zhasha.com> Date: Wed, 2 Jun 2010 20:37:44 +0200 Subject: [PATCH 3/3] r300g: use util/u_debug --- src/gallium/drivers/r300/r300_debug.c | 59 +++------------------------------ 1 files changed, 5 insertions(+), 54 deletions(-) diff --git a/src/gallium/drivers/r300/r300_debug.c b/src/gallium/drivers/r300/r300_debug.c index 024731a..297791f 100644 --- a/src/gallium/drivers/r300/r300_debug.c +++ b/src/gallium/drivers/r300/r300_debug.c @@ -22,16 +22,11 @@ #include "r300_context.h" -#include <stdio.h> +#include "util/u_debug.h" -struct debug_option { - const char * name; - unsigned flag; - const char * description; -}; +#include <stdio.h> -static struct debug_option debug_options[] = { - { "help", DBG_HELP, "Helpful meta-information about the driver" }, +static const struct debug_named_value debug_options[] = { { "fp", DBG_FP, "Fragment program handling (for debugging)" }, { "vp", DBG_VP, "Vertex program handling (for debugging)" }, { "cs", DBG_CS, "Command submissions (for debugging)" }, @@ -46,57 +41,13 @@ static struct debug_option debug_options[] = { { "noimmd", DBG_NO_IMMD, "Disable immediate mode (for benchmarking)" }, { "stats", DBG_STATS, "Gather statistics (for lulz)" }, - { "all", ~0, "Convenience option that enables all debug flags" }, - /* must be last */ - { 0, 0, 0 } + DEBUG_NAMED_VALUE_END }; void r300_init_debug(struct r300_screen * screen) { - const char * options = debug_get_option("RADEON_DEBUG", 0); - boolean printhint = FALSE; - size_t length; - struct debug_option * opt; - - if (options) { - while(*options) { - if (*options == ' ' || *options == ',') { - options++; - continue; - } - - length = strcspn(options, " ,"); - - for(opt = debug_options; opt->name; ++opt) { - if (!strncmp(options, opt->name, length)) { - screen->debug |= opt->flag; - break; - } - } - - if (!opt->name) { - fprintf(stderr, "Unknown debug option: %s\n", options); - printhint = TRUE; - } - - options += length; - } - - if (!screen->debug) - printhint = TRUE; - } - - if (printhint || screen->debug & DBG_HELP) { - fprintf(stderr, "You can enable debug output by setting " - "the RADEON_DEBUG environment variable\n" - "to a comma-separated list of debug options. " - "Available options are:\n"); - - for(opt = debug_options; opt->name; ++opt) { - fprintf(stderr, " %s: %s\n", opt->name, opt->description); - } - } + screen->debug = debug_get_flags_option("RADEON_DEBUG", debug_options, 0); } void r500_dump_rs_block(struct r300_rs_block *rs) -- 1.7.0.1
_______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev