[Mesa-dev] [PATCH 2/4] util: add debug_memory_check_block(), debug_memory_tag()

Brian Paul brianp at vmware.com
Thu Apr 4 07:46:37 PDT 2013


On 04/04/2013 08:40 AM, Jose Fonseca wrote:
>
>
> ----- Original Message -----
>> The former just checks that the given block is valid by checking
>> the header and footer.
>>
>> The later sets the memory block's tag.  With extra debug code, we
>> can use that for monitoring/checking particular allocations.
>> ---
>>   src/gallium/auxiliary/os/os_memory_debug.h  |    6 +++
>>   src/gallium/auxiliary/util/u_debug_memory.c |   55
>>   +++++++++++++++++++++++++++
>>   2 files changed, 61 insertions(+), 0 deletions(-)
>>
>> diff --git a/src/gallium/auxiliary/os/os_memory_debug.h
>> b/src/gallium/auxiliary/os/os_memory_debug.h
>> index 36b8fc6..9a487de 100644
>> --- a/src/gallium/auxiliary/os/os_memory_debug.h
>> +++ b/src/gallium/auxiliary/os/os_memory_debug.h
>> @@ -60,6 +60,12 @@ void *
>>   debug_realloc(const char *file, unsigned line, const char *function,
>>                 void *old_ptr, size_t old_size, size_t new_size );
>>
>> +void
>> +debug_memory_tag(void *ptr, unsigned tag);
>> +
>> +void
>> +debug_memory_check_block(void *ptr);
>> +
>>   void
>>   debug_memory_check(void);
>>
>> diff --git a/src/gallium/auxiliary/util/u_debug_memory.c
>> b/src/gallium/auxiliary/util/u_debug_memory.c
>> index 4bf26a5..4723547 100644
>> --- a/src/gallium/auxiliary/util/u_debug_memory.c
>> +++ b/src/gallium/auxiliary/util/u_debug_memory.c
>> @@ -76,6 +76,7 @@ struct debug_memory_header
>>   #endif
>>
>>      unsigned magic;
>> +   unsigned tag;
>
> Long term, I think a "const char * tag" would be handier -- it could be used in the debug messages.
>

Yeah.  In the case I was investigating, it was just easier to hack in 
code like if (tag==42) vs. if (strcmp(tag, "foo")==0)".

-Brian


More information about the mesa-dev mailing list