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