1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143
|
#ifndef lint
static char *RCSid = "$Id: dbgfuncs.c,v 1.8 2003/10/05 09:04:25 florian Exp $";
#endif
/*
* The Regina Rexx Interpreter
* Copyright (C) 1992-1994 Anders Christensen <anders@pvv.unit.no>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the Free
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include "rexx.h"
#include <stdio.h>
#include <string.h>
#include <assert.h>
#ifdef REGINA_DEBUG_MEMORY
streng *dbg_freelists( tsd_t *TSD, cparamboxptr dummy )
{
show_free_lists(TSD);
return nullstringptr() ;
}
#endif
streng *dbg_traceback( tsd_t *TSD, cparamboxptr dummy )
{
traceback(TSD) ;
dummy = dummy; /* keep compiler happy */
return nullstringptr() ;
}
#ifndef NDEBUG
streng *dbg_dumpvars( tsd_t *TSD, cparamboxptr dummy )
{
dumpvars(TSD);
dummy = dummy; /* keep compiler happy */
return nullstringptr() ;
}
#ifdef TRACEMEM
streng *dbg_memorystats( tsd_t *TSD, cparamboxptr parms )
{
/* memory_stats(TSD) ; */ /* FIXME, FGC: Shouldn't memory_stats() deleted? */
return nullstringptr() ;
}
streng *dbg_allocated( tsd_t *TSD, cparamboxptr parms )
{
char ch=' ' ;
streng *ptr=NULL ;
checkparam( parms, 0, 1 , "ALLOCATED" ) ;
if (!parms->value)
ch = 'S' ;
else
ch = getonechar( TSD, parms->value, "ALLOCATED", 1 ) ;
switch ( ch )
{
case 'A' :
ptr = int_to_streng( TSD,have_allocated(TSD, MEM_ALLOC)) ;
break ;
case 'L' :
ptr = int_to_streng( TSD,have_allocated(TSD, MEM_LEAKED)) ;
break ;
case 'C' :
ptr = int_to_streng( TSD,have_allocated(TSD, MEM_CURRENT)) ;
break ;
case 'S' :
ptr = Str_makeTSD( 132 ) ;
sprintf( ptr->value,"Memory: Allocated=%d, Current=%d, Leaked=%d",
have_allocated(TSD, MEM_ALLOC),
have_allocated(TSD, MEM_CURRENT),
have_allocated(TSD, MEM_LEAKED)) ;
ptr->len = strlen( ptr->value ) ;
assert( ptr->len <= ptr->max ) ;
break ;
default:
exiterror( ERR_INCORRECT_CALL, 28, "ALLOCATED", "ALCS", tmpstr_of( TSD, parms->value ) ) ;
}
return( ptr ) ;
}
#endif
streng *dbg_dumptree( tsd_t *TSD, cparamboxptr dummy )
{
dumptree( TSD, TSD->systeminfo->tree.root, 1, 1 ) ;
dummy = dummy; /* keep compiler happy */
return nullstringptr() ;
}
#ifdef TRACEMEM
streng *dbg_listleaked( tsd_t *TSD, cparamboxptr parms )
{
char ch=0 ;
int i=0 ;
checkparam( parms, 0, 1 , "LISTLEAKED" ) ;
if (parms->value)
ch = getonechar( TSD, parms->value, "LISTLEAKED", 1 ) ;
else
ch = 'L' ;
if (ch=='N')
i = listleaked( TSD, MEMTRC_NONE ) ;
else if (ch=='L')
i = listleaked( TSD, MEMTRC_LEAKED ) ;
else if (ch=='A')
i = listleaked( TSD, MEMTRC_ALL ) ;
else
exiterror( ERR_INCORRECT_CALL, 28, "LISTLEAKED", "ALN", tmpstr_of( TSD, parms->value ) ) ;
return int_to_streng( TSD, i ) ;
}
#endif
#endif /* !NDEBUG */
|