From 7e44438936091746fd5b192ca2fae3cd1b105713 Mon Sep 17 00:00:00 2001 From: Jonathan Gordon Date: Sun, 25 Sep 2011 12:05:03 +0000 Subject: Add a simple perl script to display info about what is allocating skin buffer. To use it enable DEBUG_SKIN_ALLOCATIONS in skin_buffer.h and pipe the rockboxui output to the script git-svn-id: svn://svn.rockbox.org/rockbox/trunk@30597 a1c6a512-1295-4272-9138-f99709370657 --- lib/skin_parser/skin_buffer.c | 8 ++++++++ lib/skin_parser/skin_buffer.h | 11 +++++++++++ lib/skin_parser/skin_buffer_debug.pl | 31 +++++++++++++++++++++++++++++++ 3 files changed, 50 insertions(+) create mode 100755 lib/skin_parser/skin_buffer_debug.pl (limited to 'lib') diff --git a/lib/skin_parser/skin_buffer.c b/lib/skin_parser/skin_buffer.c index 94f2e3ba7d..5a9d4464b8 100644 --- a/lib/skin_parser/skin_buffer.c +++ b/lib/skin_parser/skin_buffer.c @@ -98,9 +98,17 @@ void skin_buffer_init(char* buffer, size_t size) } /* Allocate size bytes from the buffer */ +#ifdef DEBUG_SKIN_ALLOCATIONS +void* skin_buffer_alloc_ex(size_t size, char* debug) +{ + void *retval = NULL; + printf("%d %s\n", size, debug); +#else void* skin_buffer_alloc(size_t size) { void *retval = NULL; +#endif + #ifdef USE_ROCKBOX_ALLOC /* 32-bit aligned */ size = (size + 3) & ~3; diff --git a/lib/skin_parser/skin_buffer.h b/lib/skin_parser/skin_buffer.h index 1698b8afb2..b2ed34e09f 100644 --- a/lib/skin_parser/skin_buffer.h +++ b/lib/skin_parser/skin_buffer.h @@ -27,7 +27,18 @@ #define _SKIN_BUFFFER_H_ void skin_buffer_init(char* buffer, size_t size); /* Allocate size bytes from the buffer */ + +/* #define DEBUG_SKIN_ALLOCATIONS */ + +#ifdef DEBUG_SKIN_ALLOCATIONS +#define FOO(X) #X +#define STRNG(X) FOO(X) +#define skin_buffer_alloc(s) skin_buffer_alloc_ex(s, __FILE__ ":" STRNG(__LINE__)) +void* skin_buffer_alloc_ex(size_t size, char* str); +#else void* skin_buffer_alloc(size_t size); +#endif + /* get the number of bytes currently being used */ size_t skin_buffer_usage(void); diff --git a/lib/skin_parser/skin_buffer_debug.pl b/lib/skin_parser/skin_buffer_debug.pl new file mode 100755 index 0000000000..6d0d1ba0e7 --- /dev/null +++ b/lib/skin_parser/skin_buffer_debug.pl @@ -0,0 +1,31 @@ +#!/usr/bin/perl +# __________ __ ___. +# Open \______ \ ____ ____ | | _\_ |__ _______ ___ +# Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / +# Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < +# Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ +# \/ \/ \/ \/ \/ +# $Id$ +# + +%allocs = (); + +while (<>) { + if (/([0-9]*) (.*)$/) { + $key = $2; + $value = $1; + if (exists $allocs{$key}) { + $val = $allocs{$key}[0]; + $count = $allocs{$key}[1]; + $allocs{$key} = [$value + $val, $count+1] + } else { + $allocs{$key} = [$value, 1] + } + } +} +print "Count\tTotal cost\tLine\n"; +for my $key ( keys %allocs ) { + $val = $allocs{$key}[0]; + $count = $allocs{$key}[1]; + print "$count\t$val\t$key\n"; +} -- cgit