From 3eb09cb746b3e88bb7492e2170122ba7220996b6 Mon Sep 17 00:00:00 2001 From: Chris Jefferson Date: Mon, 12 Dec 2022 23:31:05 +0000 Subject: [PATCH] Remove ActivateProfileColour --- doc/ref/debug.xml | 1 - lib/newprofile.g | 22 -------- src/profile.c | 128 +--------------------------------------------- 3 files changed, 2 insertions(+), 149 deletions(-) diff --git a/doc/ref/debug.xml b/doc/ref/debug.xml index 58d2f0d720c..0d40021e9dd 100644 --- a/doc/ref/debug.xml +++ b/doc/ref/debug.xml @@ -839,7 +839,6 @@ Profiles are transformed into a human-readable form with <#Include Label="CoverageLineByLine"> <#Include Label="UnprofileLineByLine"> <#Include Label="UncoverageLineByLine"> -<#Include Label="ActivateProfileColour"> <#Include Label="IsLineByLineProfileActive"> diff --git a/lib/newprofile.g b/lib/newprofile.g index 8b42db1b931..86755f1fef4 100644 --- a/lib/newprofile.g +++ b/lib/newprofile.g @@ -153,25 +153,3 @@ end); BIND_GLOBAL("UncoverageLineByLine", function() return DEACTIVATE_PROFILING(); end); - - -############################################################################# -## -## -## <#GAPDoc Label="ActivateProfileColour"> -## -## -## -## -## Called with argument true, -## -## makes GAP colour functions when printing them to show which lines -## have been executed while profiling was active via -## at any time during this GAP session. -## Passing false disables this behaviour. -## -## -## <#/GAPDoc> -BIND_GLOBAL("ActivateProfileColour",function(b) - return ACTIVATE_COLOR_PROFILING(b); -end); diff --git a/src/profile.c b/src/profile.c index ba3b3a9881b..ab7cd27f488 100644 --- a/src/profile.c +++ b/src/profile.c @@ -83,9 +83,8 @@ ** we provide -P (profiling) and -c (code coverage) options to the GAP ** executable so the user can start before code loading starts ** -** 3) Operating at just a line basis can sometimes be too course. We can -** see this when we use ActivateProfileColour. However, without some -** serious additional overheads, I can't see how to provide this +** 3) Operating at just a line basis can sometimes be too course. However, +** without some serious additional overheads, I can't see how to provide this ** functionality in output (basically we would have to store ** line and character positions for the start and end of every expression). ** @@ -836,128 +835,6 @@ static Obj FuncIsLineByLineProfileActive(Obj self) } } -/**************************************************************************** -** -** We are now into the functions which deal with colouring printing output. -** This code basically wraps all the existing print functions and will colour -** their output either green or red depending on if statements are marked -** as being executed. -*/ - -static Int CurrentColour = 0; - -static void setColour(void) -{ - if(CurrentColour == 0) { - Pr("\x1b[0m", 0, 0); - } - else if(CurrentColour == 1) { - Pr("\x1b[32m", 0, 0); - } - else if(CurrentColour == 2) { - Pr("\x1b[31m", 0, 0); - } -} - -static void ProfilePrintStatPassthrough(Stat stat) -{ - Int SavedColour = CurrentColour; - if (visitedStat(stat)) { - CurrentColour = 1; - } - else { - CurrentColour = 2; - } - setColour(); - OriginalPrintStatFuncsForHook[TNUM_STAT(stat)](stat); - CurrentColour = SavedColour; - setColour(); -} - -static void ProfilePrintExprPassthrough(Expr stat) -{ - Int SavedColour = -1; - /* There are two cases we must pass through without touching */ - /* From TNUM_EXPR */ - if(IS_REF_LVAR(stat)) { - OriginalPrintExprFuncsForHook[EXPR_REF_LVAR](stat); - } else if(IS_INTEXPR(stat)) { - OriginalPrintExprFuncsForHook[EXPR_INT](stat); - } else { - SavedColour = CurrentColour; - if (visitedStat(stat)) { - CurrentColour = 1; - } - else { - CurrentColour = 2; - } - setColour(); - OriginalPrintExprFuncsForHook[TNUM_STAT(stat)](stat); - CurrentColour = SavedColour; - setColour(); - } -} - -static struct PrintHooks profilePrintHooks = - {ProfilePrintStatPassthrough, ProfilePrintExprPassthrough}; - -static Obj activate_colored_output_from_profile(void) -{ - HashLock(&profileState); - - if(profileState.ColouringOutput) { - HashUnlock(&profileState); - return Fail; - } - - ActivatePrintHooks(&profilePrintHooks); - - profileState.ColouringOutput = 1; - CurrentColour = 0; - setColour(); - - HashUnlock(&profileState); - - return True; -} - -static Obj deactivate_colored_output_from_profile(void) -{ - HashLock(&profileState); - - if(!profileState.ColouringOutput) { - HashUnlock(&profileState); - return Fail; - } - - DeactivatePrintHooks(&profilePrintHooks); - - profileState.ColouringOutput = 0; - CurrentColour = 0; - setColour(); - - HashUnlock(&profileState); - - return True; -} - -static Obj FuncACTIVATE_COLOR_PROFILING(Obj self, Obj arg) -{ - if(arg == True) - { - return activate_colored_output_from_profile(); - } - else if(arg == False) - { - return deactivate_colored_output_from_profile(); - } - else - return Fail; -} - - - - /**************************************************************************** ** *F * * * * * * * * * * * * * initialize module * * * * * * * * * * * * * * * @@ -977,7 +854,6 @@ static StructGVarFunc GVarFuncs[] = { resolution), GVAR_FUNC_0ARGS(DEACTIVATE_PROFILING), GVAR_FUNC_0ARGS(IsLineByLineProfileActive), - GVAR_FUNC_1ARGS(ACTIVATE_COLOR_PROFILING, arg), { 0, 0, 0, 0, 0 } };