From 38b1628e8d2a73af6df14fb16e48eef4edaaee01 Mon Sep 17 00:00:00 2001 From: Dave Abrahams Date: Tue, 30 Apr 2002 14:22:46 +0000 Subject: [PATCH] Improved debugging output: * added space after "on" * try harder to indicate in which module a rule is going to execute * Stop printing the module context of variable settings; it was confusing especially when the variable turned out to be a local variable or an argument name. * Register the name by which each rule is /invoked/ in its frame instead of the name by which the rule was defined. This changes the behavior of the builtin BACKTRACE rule, causing it to register the rule's invocation names (filenames and line numbers lead the user to the definition context anyway). This change was neccessary in order to support classes: we can now extract the name of a class being initialized by looking at the backtrace from within the class module's __init__ rule. [SVN r13585] --- src/engine/compile.c | 32 +++++++++++++++++++++++--------- 1 file changed, 23 insertions(+), 9 deletions(-) diff --git a/src/engine/compile.c b/src/engine/compile.c index 60e2df083..197a9e557 100644 --- a/src/engine/compile.c +++ b/src/engine/compile.c @@ -30,6 +30,7 @@ # include # include +# include /* * compile.c - compile parsed jam statements @@ -775,15 +776,29 @@ evaluate_rule( return result; } - if ( DEBUG_COMPILE ) - { - debug_compile( 1, l->string, frame); - lol_print( frame->args ); - printf( "\n" ); - } rulename = l->string; rule = bindrule( l->string, frame->module ); + if ( DEBUG_COMPILE ) + { + /* Try hard to indicate in which module the rule is going to execute */ + if ( rule->module != frame->module + && rule->procedure != 0 && strcmp(rulename, rule->procedure->rulename) ) + { + char buf[256] = ""; + strncat( buf, rule->module->name, sizeof(buf) - 1 ); + strncat( buf, rule->name, sizeof(buf) - 1 ); + debug_compile( 1, buf, frame); + } + else + { + debug_compile( 1, rulename, frame); + } + + lol_print( frame->args ); + printf( "\n" ); + } + if ( rule->procedure && rule->module != prev_module ) { /* propagate current module to nested rule invocations */ @@ -803,7 +818,7 @@ evaluate_rule( /* record current rule name in frame */ if ( rule->procedure ) { - frame->rulename = rule->procedure->rulename; + frame->rulename = rulename; /* and enter record profile info */ if ( DEBUG_PROFILE ) profile_enter( rule->procedure->rulename, prof ); @@ -923,7 +938,6 @@ compile_set( if( DEBUG_COMPILE ) { debug_compile( 0, "set", frame); - printf( frame->module->name ); list_print( nt ); printf( " %s ", trace ); list_print( ns ); @@ -1017,7 +1031,7 @@ compile_settings( { debug_compile( 0, "set", frame); list_print( nt ); - printf( "on " ); + printf( " on " ); list_print( targets ); printf( " %s ", append ? "+=" : "=" ); list_print( ns );