Add -R param to enable or disable recursion report

This commit is contained in:
Sergei Marochkin 2016-11-11 19:27:09 +03:00
parent 56ef450a24
commit 1a608c25a1
3 changed files with 7 additions and 1 deletions

View File

@ -817,6 +817,7 @@ SC_VDECL int pc_optimize; /* (peephole) optimization level */
SC_VDECL int pc_memflags; /* special flags for the stack/heap usage */ SC_VDECL int pc_memflags; /* special flags for the stack/heap usage */
SC_VDECL int pc_naked; /* if true mark following function as naked */ SC_VDECL int pc_naked; /* if true mark following function as naked */
SC_VDECL int pc_compat; /* running in compatibility mode? */ SC_VDECL int pc_compat; /* running in compatibility mode? */
SC_VDECL int pc_recursion; /* enable detailed recursion report? */
SC_VDECL constvalue sc_automaton_tab; /* automaton table */ SC_VDECL constvalue sc_automaton_tab; /* automaton table */
SC_VDECL constvalue sc_state_tab; /* state table */ SC_VDECL constvalue sc_state_tab; /* state table */

View File

@ -1097,6 +1097,9 @@ static void parseoptions(int argc,char **argv,char *oname,char *ename,char *pnam
case 'p': case 'p':
strlcpy(pname,option_value(ptr),_MAX_PATH); /* set name of implicit include file */ strlcpy(pname,option_value(ptr),_MAX_PATH); /* set name of implicit include file */
break; break;
case 'R':
pc_recursion=toggle_option(ptr,pc_recursion);
break;
#if !defined SC_LIGHT #if !defined SC_LIGHT
case 'r': case 'r':
strlcpy(rname,option_value(ptr),_MAX_PATH); /* set name of report file */ strlcpy(rname,option_value(ptr),_MAX_PATH); /* set name of report file */
@ -1417,6 +1420,7 @@ static void about(void)
pc_printf(" 1 JIT-compatible optimizations only\n"); pc_printf(" 1 JIT-compatible optimizations only\n");
pc_printf(" 2 full optimizations\n"); pc_printf(" 2 full optimizations\n");
pc_printf(" -p<name> set name of \"prefix\" file\n"); pc_printf(" -p<name> set name of \"prefix\" file\n");
pc_printf(" -R[+/-] add detailed recursion report with call chains (default=%c)\n",pc_recursion ? '+' : '-');
#if !defined SC_LIGHT #if !defined SC_LIGHT
pc_printf(" -r[name] write cross reference report to console or to specified file\n"); pc_printf(" -r[name] write cross reference report to console or to specified file\n");
#endif #endif
@ -4606,7 +4610,7 @@ static long max_stacksize(symbol *root,int *recursion)
assert(symstack[1]==NULL); assert(symstack[1]==NULL);
recursion_detected=0; recursion_detected=0;
size=max_stacksize_recurse(symstack,sym,rsymstack,0L,&maxparams,&recursion_detected); size=max_stacksize_recurse(symstack,sym,rsymstack,0L,&maxparams,&recursion_detected);
if (recursion_detected) { if (recursion_detected && pc_recursion) {
if (rsymstack[1]==NULL) { if (rsymstack[1]==NULL) {
pc_printf("recursion detected: function %s directly calls itself\n", sym->name); pc_printf("recursion detected: function %s directly calls itself\n", sym->name);
} else { } else {

View File

@ -92,6 +92,7 @@ SC_VDEFINE int pc_optimize=sOPTIMIZE_NOMACRO; /* (peephole) optimization level *
SC_VDEFINE int pc_memflags=0; /* special flags for the stack/heap usage */ SC_VDEFINE int pc_memflags=0; /* special flags for the stack/heap usage */
SC_VDEFINE int pc_naked=FALSE; /* if true mark following function as naked */ SC_VDEFINE int pc_naked=FALSE; /* if true mark following function as naked */
SC_VDEFINE int pc_compat=FALSE; /* running in compatibility mode? */ SC_VDEFINE int pc_compat=FALSE; /* running in compatibility mode? */
SC_VDEFINE int pc_recursion=FALSE; /* enable detailed recursion report? */
SC_VDEFINE constvalue sc_automaton_tab = { NULL, "", 0, 0}; /* automaton table */ SC_VDEFINE constvalue sc_automaton_tab = { NULL, "", 0, 0}; /* automaton table */
SC_VDEFINE constvalue sc_state_tab = { NULL, "", 0, 0}; /* state table */ SC_VDEFINE constvalue sc_state_tab = { NULL, "", 0, 0}; /* state table */