summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonathan Gordon <rockbox@jdgordon.info>2011-09-25 12:05:03 +0000
committerJonathan Gordon <rockbox@jdgordon.info>2011-09-25 12:05:03 +0000
commit7e44438936091746fd5b192ca2fae3cd1b105713 (patch)
treef24ffcbc1612a3e8316af2b932ec41a5fa7b09ad
parentd7372533d07c3168715f9efdace76da1d3983fee (diff)
downloadrockbox-7e44438936091746fd5b192ca2fae3cd1b105713.tar.gz
rockbox-7e44438936091746fd5b192ca2fae3cd1b105713.zip
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
-rw-r--r--lib/skin_parser/skin_buffer.c8
-rw-r--r--lib/skin_parser/skin_buffer.h11
-rwxr-xr-xlib/skin_parser/skin_buffer_debug.pl31
3 files changed, 50 insertions, 0 deletions
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)
98} 98}
99 99
100/* Allocate size bytes from the buffer */ 100/* Allocate size bytes from the buffer */
101#ifdef DEBUG_SKIN_ALLOCATIONS
102void* skin_buffer_alloc_ex(size_t size, char* debug)
103{
104 void *retval = NULL;
105 printf("%d %s\n", size, debug);
106#else
101void* skin_buffer_alloc(size_t size) 107void* skin_buffer_alloc(size_t size)
102{ 108{
103 void *retval = NULL; 109 void *retval = NULL;
110#endif
111
104#ifdef USE_ROCKBOX_ALLOC 112#ifdef USE_ROCKBOX_ALLOC
105 /* 32-bit aligned */ 113 /* 32-bit aligned */
106 size = (size + 3) & ~3; 114 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 @@
27#define _SKIN_BUFFFER_H_ 27#define _SKIN_BUFFFER_H_
28void skin_buffer_init(char* buffer, size_t size); 28void skin_buffer_init(char* buffer, size_t size);
29/* Allocate size bytes from the buffer */ 29/* Allocate size bytes from the buffer */
30
31/* #define DEBUG_SKIN_ALLOCATIONS */
32
33#ifdef DEBUG_SKIN_ALLOCATIONS
34#define FOO(X) #X
35#define STRNG(X) FOO(X)
36#define skin_buffer_alloc(s) skin_buffer_alloc_ex(s, __FILE__ ":" STRNG(__LINE__))
37void* skin_buffer_alloc_ex(size_t size, char* str);
38#else
30void* skin_buffer_alloc(size_t size); 39void* skin_buffer_alloc(size_t size);
40#endif
41
31 42
32/* get the number of bytes currently being used */ 43/* get the number of bytes currently being used */
33size_t skin_buffer_usage(void); 44size_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 @@
1#!/usr/bin/perl
2# __________ __ ___.
3# Open \______ \ ____ ____ | | _\_ |__ _______ ___
4# Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5# Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6# Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7# \/ \/ \/ \/ \/
8# $Id$
9#
10
11%allocs = ();
12
13while (<>) {
14 if (/([0-9]*) (.*)$/) {
15 $key = $2;
16 $value = $1;
17 if (exists $allocs{$key}) {
18 $val = $allocs{$key}[0];
19 $count = $allocs{$key}[1];
20 $allocs{$key} = [$value + $val, $count+1]
21 } else {
22 $allocs{$key} = [$value, 1]
23 }
24 }
25}
26print "Count\tTotal cost\tLine\n";
27for my $key ( keys %allocs ) {
28 $val = $allocs{$key}[0];
29 $count = $allocs{$key}[1];
30 print "$count\t$val\t$key\n";
31}