Skip to content

Commit

Permalink
kernel: permanently enable some debug checks
Browse files Browse the repository at this point in the history
These checks, formerly controlled by

 * CHECK_FOR_CLASH_IN_INIT_SWEEP_FUNC,
 * DEBUG_HANDLER_REGISTRATION,
 * DEBUG_GLOBAL_BAGS,
 * DEBUG_LOADING,

are cheap one-time costs, so there is no reason not to always activate them.
Previously, by hiding them behind compile time flags, they were effectively
never used by anybody.
  • Loading branch information
fingolfin committed Jan 9, 2018
1 parent 7995903 commit 234ae09
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 69 deletions.
21 changes: 6 additions & 15 deletions src/calls.c
Original file line number Diff line number Diff line change
Expand Up @@ -944,14 +944,11 @@ void InitHandlerFunc (
Pr( "No room left for function handler\n", 0L, 0L );
SyExit(1);
}
#ifdef DEBUG_HANDLER_REGISTRATION
{
UInt i;
for (i = 0; i < NHandlerFuncs; i++)

for (UInt i = 0; i < NHandlerFuncs; i++)
if (!strcmp(HandlerFuncs[i].cookie, cookie))
Pr("Duplicate cookie %s\n", (Int)cookie, 0L);
}
#endif
Pr("Duplicate cookie %s\n", (Int)cookie, 0L);

HandlerFuncs[NHandlerFuncs].hdlr = hdlr;
HandlerFuncs[NHandlerFuncs].cookie = cookie;
HandlerSortingStatus = 0; /* no longer sorted by handler or cookie */
Expand All @@ -964,9 +961,6 @@ void InitHandlerFunc (
**
*f CheckHandlersBag( <bag> ) . . . . . . check that handlers are initialised
*/

#ifdef DEBUG_HANDLER_REGISTRATION

static void CheckHandlersBag(
Bag bag )
{
Expand Down Expand Up @@ -994,14 +988,11 @@ static void CheckHandlersBag(
}
}

void CheckAllHandlers(
void )
void CheckAllHandlers(void)
{
CallbackForAllBags( CheckHandlersBag);
CallbackForAllBags(CheckHandlersBag);
}

#endif

static int IsLessHandlerInfo (
TypeHandlerInfo * h1,
TypeHandlerInfo * h2,
Expand Down
3 changes: 3 additions & 0 deletions src/calls.h
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,9 @@ extern ObjFunc HandlerOfCookie (

extern void SortHandlers( UInt byWhat );

extern void CheckAllHandlers(void);


/****************************************************************************
**
*F NewFunction( <name>, <narg>, <nams>, <hdlr> ) . . . make a new function
Expand Down
4 changes: 1 addition & 3 deletions src/gap.c
Original file line number Diff line number Diff line change
Expand Up @@ -3191,9 +3191,7 @@ void InitializeGap (
# if !defined(BOEHM_GC)
WarnInitGlobalBag = 1;
# endif
# ifdef DEBUG_HANDLER_REGISTRATION
CheckAllHandlers();
# endif
CheckAllHandlers();

SyInitializing = 1;
for ( i = 0; i < NrBuiltinModules; i++ ) {
Expand Down
57 changes: 17 additions & 40 deletions src/gasman.c
Original file line number Diff line number Diff line change
Expand Up @@ -478,20 +478,10 @@ void InitSweepFuncBags (
UInt type,
TNumSweepFuncBags sweep_func )
{
#ifdef CHECK_FOR_CLASH_IN_INIT_SWEEP_FUNC
char str[256];

if ( TabSweepFuncBags[type] != 0 ) {
str[0] = 0;
strncat( str, "warning: sweep function for type ", 33 );
str[33] = '0' + ((type/100) % 10);
str[34] = '0' + ((type/ 10) % 10);
str[35] = '0' + ((type/ 1) % 10);
str[36] = 0;
strncat( str, " already installed\n", 19 );
SyFputs( str, 0 );
Pr("warning: sweep function for type %d already installed\n", type, 0);
}
#endif

TabSweepFuncBags[type] = sweep_func;
}

Expand Down Expand Up @@ -519,20 +509,10 @@ void InitMarkFuncBags (
UInt type,
TNumMarkFuncBags mark_func )
{
#ifdef CHECK_FOR_CLASH_IN_INIT_MARK_FUNC
char str[256];

if ( TabMarkFuncBags[type] != MarkAllSubBagsDefault ) {
str[0] = 0;
strncat( str, "warning: mark function for type ", 32 );
str[32] = '0' + ((type/100) % 10);
str[33] = '0' + ((type/ 10) % 10);
str[34] = '0' + ((type/ 1) % 10);
str[35] = 0;
strncat( str, " already installed\n", 19 );
SyFputs( str, 0 );
Pr("warning: mark function for type %d already installed\n", type, 0);
}
#endif

TabMarkFuncBags[type] = mark_func;
}

Expand Down Expand Up @@ -757,18 +737,18 @@ void InitGlobalBag (
(*AbortFuncBags)(
"Panic: Gasman cannot handle so many global variables" );
}
#ifdef DEBUG_GLOBAL_BAGS
{
UInt i;
if (cookie != (Char *)0)
for (i = 0; i < GlobalBags.nr; i++)
if ( 0 == strcmp(GlobalBags.cookie[i], cookie) )
if (GlobalBags.addr[i] == addr)
Pr("Duplicate global bag entry %s\n", (Int)cookie, 0L);
else
Pr("Duplicate global bag cookie %s\n", (Int)cookie, 0L);

if (cookie != 0) {
for (UInt i = 0; i < GlobalBags.nr; i++) {
if (0 == strcmp(GlobalBags.cookie[i], cookie)) {
if (GlobalBags.addr[i] == addr)
Pr("Duplicate global bag entry %s\n", (Int)cookie, 0L);
else
Pr("Duplicate global bag cookie %s\n", (Int)cookie, 0L);
}
}
}
#endif

if ( WarnInitGlobalBag ) {
Pr( "#W global bag '%s' initialized\n", (Int)cookie, 0L );
}
Expand All @@ -779,7 +759,6 @@ void InitGlobalBag (
}



static Int IsLessGlobal (
const Char * cookie1,
const Char * cookie2,
Expand Down Expand Up @@ -919,18 +898,16 @@ Bag NextBagRestoring( UInt type, UInt flags, UInt size )
header->size = size;
header->link = NextMptrRestoring;
NextMptrRestoring++;
#ifdef DEBUG_LOADING

if ((Bag *)NextMptrRestoring >= OldBags)
(*AbortFuncBags)("Overran Masterpointer area");
#endif

for (i = 0; i < WORDS_BAG(size); i++)
*AllocBags++ = (Bag)0;

#ifdef DEBUG_LOADING
if (AllocBags > EndBags)
(*AbortFuncBags)("Overran data area");
#endif

#ifdef COUNT_BAGS
InfoBags[type].nrLive += 1;
InfoBags[type].nrAll += 1;
Expand Down
5 changes: 0 additions & 5 deletions src/saveload.c
Original file line number Diff line number Diff line change
Expand Up @@ -447,16 +447,11 @@ static void LoadBagData ( void )
flags = LoadUInt1();
size = LoadUInt();

#ifdef DEBUG_LOADING
{
if (InfoBags[type].name == NULL)
{
Pr("Bad type %d, size %d\n",type,size);
exit(1);
}
}

#endif

/* Get GASMAN to set up the bag for me */
bag = NextBagRestoring( type, flags, size );
Expand Down
6 changes: 0 additions & 6 deletions src/system.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,6 @@
/* define to get information while restoring */
/* #undef DEBUG_LOADING */

/* define to debug registering of global bags */
/* #undef DEBUG_GLOBAL_BAGS */

/* define to debug registering of function handlers */
/* #undef DEBUG_HANDLER_REGISTRATION */


/* * * * * * * * * * * * * debugging GASMAN * * * * * * * * * * * * * * * */

Expand Down

0 comments on commit 234ae09

Please sign in to comment.