summaryrefslogtreecommitdiff
path: root/tools/build/v2/engine/debug.c
diff options
context:
space:
mode:
Diffstat (limited to 'tools/build/v2/engine/debug.c')
-rw-r--r--tools/build/v2/engine/debug.c35
1 files changed, 22 insertions, 13 deletions
diff --git a/tools/build/v2/engine/debug.c b/tools/build/v2/engine/debug.c
index 7290555a74..827356bb83 100644
--- a/tools/build/v2/engine/debug.c
+++ b/tools/build/v2/engine/debug.c
@@ -14,34 +14,41 @@
static profile_frame * profile_stack = 0;
static struct hash * profile_hash = 0;
-static profile_info profile_other = { "[OTHER]", 0, 0, 0, 0, 0 };
-static profile_info profile_total = { "[TOTAL]", 0, 0, 0, 0, 0 };
+static profile_info profile_other = { 0, 0, 0, 0, 0, 0 };
+static profile_info profile_total = { 0, 0, 0, 0, 0, 0 };
-profile_frame * profile_init( char * rulename, profile_frame * frame )
+profile_frame * profile_init( OBJECT * rulename, profile_frame * frame )
{
if ( DEBUG_PROFILE ) profile_enter( rulename, frame );
return frame;
}
-void profile_enter( char * rulename, profile_frame * frame )
+void profile_enter( OBJECT * rulename, profile_frame * frame )
{
if ( DEBUG_PROFILE )
{
clock_t start = clock();
- profile_info info;
- profile_info * p = &info;
-
- if ( !rulename ) p = &profile_other;
+ profile_info * p;
if ( !profile_hash && rulename )
profile_hash = hashinit( sizeof( profile_info ), "profile" );
- info.name = rulename;
-
- if ( rulename && hashenter( profile_hash, (HASHDATA * *)&p ) )
- p->cumulative = p->net = p->num_entries = p->stack_count = p->memory = 0;
+ if ( rulename )
+ {
+ int found;
+ p = (profile_info *)hash_insert( profile_hash, rulename, &found );
+ if ( !found )
+ {
+ p->name = rulename;
+ p->cumulative = p->net = p->num_entries = p->stack_count = p->memory = 0;
+ }
+ }
+ else
+ {
+ p = &profile_other;
+ }
++p->num_entries;
++p->stack_count;
@@ -115,7 +122,7 @@ static void dump_profile_entry( void * p_, void * ignored )
profile_total.memory += p->memory;
}
printf( "%10ld %12.6f %12.6f %12.8f %10ld %10ld %s\n", p->num_entries,
- cumulative, net, q, p->memory, mem_each, p->name );
+ cumulative, net, q, p->memory, mem_each, object_str( p->name ) );
}
@@ -126,7 +133,9 @@ void profile_dump()
printf( "%10s %12s %12s %12s %10s %10s %s\n", "--count--", "--gross--",
"--net--", "--each--", "--mem--", "--each--", "--name--" );
hashenumerate( profile_hash, dump_profile_entry, 0 );
+ profile_other.name = constant_other;
dump_profile_entry( &profile_other, 0 );
+ profile_total.name = constant_total;
dump_profile_entry( &profile_total, (void *)1 );
}
}