00001 /********************************************************************** 00002 * Copyright 2002 Jeff Rush <jrush@taupro.com> 00003 * Original Copyright 1979-2002 Udanax.com 00004 * 00005 * This file is part of the Udanax xanalogical storage system. 00006 * 00007 * Udanax is free software; you can redistribute it and/or modify it 00008 * under the terms of the GNU General Public License as published by 00009 * the Free Software Foundation; either version 2 of the License, or 00010 * (at your option) any later version. 00011 * 00012 * Udanax is distributed in the hope that it will be useful, but 00013 * WITHOUT ANY WARRANTY; without even the implied warranty of 00014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00015 * GNU General Public License for more details. 00016 * 00017 * You should have received a copy of the GNU General Public License 00018 * along with Udanax; if not, write to the Free Software Foundation, 00019 * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00020 **********************************************************************/ 00021 00030 /* Modification History: 00031 * $Log: allocdebug.cxx,v $ 00032 * Revision 1.8 2004/09/11 13:59:21 jrush 00033 * Changed all fprintf's to stderr to use the Nana library L() macro. Also 00034 * removed a 2-3 minor compiler warnings. 00035 * 00036 * Revision 1.7 2004/09/04 16:02:17 jrush 00037 * Added Doxygen headers before each and every function definition. 00038 * 00039 * Revision 1.6 2002/05/28 04:22:29 jrush 00040 * Adjusted source files to comply with GPL licensing. 00041 * 00042 * Revision 1.5 2002/04/12 11:56:42 jrush 00043 * Reorganized include file layout, renamed xanadu.h to udanax.h and 00044 * typecontext/typecrumcontext to C++ class Context/CrumContext. 00045 * 00046 * Revision 1.4 2002/04/09 21:45:46 jrush 00047 * Renamed class 'tumbler' to 'Tumbler', for consistency with Python sources, 00048 * and changed typeisa from typedef to a subclass, in preparation for cleaning 00049 * up the type/class tree. 00050 * 00051 * Revision 1.3 2002/04/06 17:05:57 jrush 00052 * Switched from referring to 'task' for a client connection to 'session', 00053 * and converted the typetask typedef/struct into a Session C++ class. 00054 * 00055 * Revision 1.2 2002/02/14 09:27:43 jrush 00056 * Cleaned up source: 00057 * 00058 * 1. ran thru the indent tool to achieve a standard look, 00059 * 2. added structured comments at top for use with DOxygen reporting 00060 * as well as CVS keywords, 00061 * 3. fixed compiler warnings re ambiguous assign/compares, 00062 * needed casts and unused/uninitialized variables, 00063 * 4. fixed funcs that didn't specify a return type, 00064 * 5. centralized prototypes in protos.h, removing incomplete ones, 00065 * 6. cleaned up use of bool/BOOLEAN type to suit C++ type, 00066 * 7. fixed initializer nesting in tumbler constants, 00067 * 8. renamed vars that conflict with C++ keywords (new, this), 00068 * 9. fixed global/extern confusion re some global vars. 00069 * 00070 */ 00071 00072 #include "udanax.h" 00073 00081 static void 00082 analyzeanddebug( 00083 char *ptr) 00084 { /* ptr to thing with alloc header and * tag header */ 00085 #ifndef DISTRIBUTION 00086 tagtype tag; 00087 char *tagptr; 00088 HEADER *allocptr; 00089 00090 allocptr = (HEADER *) ptr; 00091 tagptr = ptr + sizeof(HEADER); 00092 tag = *tagptr; 00093 ptr = tagptr + sizeof(tagtype); 00094 /* L("\n size is %d ", ((HEADER *)allocptr)->s.size * sizeof(HEADER)); */ 00095 if (tag == SESSTAG) { /* undifferientated session alloced stuff */ 00096 00097 } /* else if(tag & SESSTAG){ //tagged * session alloced stuff// switch(tag * 00098 * &~SESSTAG){ } } */ 00099 else { 00100 switch (tag) { 00101 case INTTAG: 00102 L("int in allocspace \n"); 00103 break; 00104 00105 case ITEMTAG: 00106 L("item in allocspace \n"); 00107 dumpitem((typeitem *) ptr); 00108 break; 00109 00110 case CONTEXTTAG: 00111 L("context %x in allocspace \n", (int) ptr); 00112 dumpcontext((Context *) ptr); 00113 break; 00114 00115 case CONTEXT2DTAG: 00116 L("context2d %x in allocspace \n", (int) ptr); 00117 break; 00118 00119 case CRUMCONTEXTTAG: 00120 L("crumcontext in allocspace \n"); 00121 break; 00122 00123 case CUCTAG: 00124 break; /* L("cuc in allocspace"); dump(ptr); break; */ 00125 00126 case CBCTAG: 00127 break; /* L("cbc in allocspace"); dump(ptr); break; */ 00128 00129 case SPANTAG: 00130 L("span in allocspace \n"); 00131 dumpspan((typespan *) ptr); 00132 break; 00133 00134 case TUMBLERTAG: 00135 L("tumbler in allocspace \n"); 00136 dumptumbler((Tumbler *) ptr); 00137 break; 00138 00139 case ISPANTAG: 00140 L("aspan in allocspace \n"); 00141 break; 00142 00143 case VSPANTAG: 00144 L("vspan in allocspace \n"); 00145 break; 00146 00147 case SPORGLTAG: 00148 L("sporgl in allocspace \n"); 00149 break; 00150 00151 case LINKTAG: 00152 L("link in allocspace \n"); 00153 break; 00154 00155 case VSPECTAG: 00156 L("vspec in allocspace \n"); 00157 break; 00158 00159 case FREEDISKLOAFTAG: 00160 L("freediskloaf in allocspace \n"); 00161 break; 00162 00163 default: 00164 L("randomunidentified thing in allocspace \n"); 00165 break; 00166 } 00167 } 00168 #endif 00169 } 00170 00178 void 00179 lookatalloc2( 00180 HEADER *abaseallocated) 00181 { /* baseallocated is statics in alloc.d */ 00182 #ifndef DISTRIBUTION 00183 register HEADER *p; 00184 unsigned allocated = 0, unallocated = 0, maxunallocatedblock = 0; /* in header units */ 00185 00186 p = abaseallocated->s.ptr; 00187 for (; p < abaseallocated->s.ptr + abaseallocated->s.size;) { 00188 if (!p->s.ptr) { /* allocated */ 00189 analyzeanddebug((char *) p); 00190 allocated += p->s.size; 00191 } else { /* unallocated */ 00192 unallocated += p->s.size; 00193 maxunallocatedblock = max(p->s.size, maxunallocatedblock); 00194 } 00195 /* step past current one */ 00196 p = p + p->s.size; 00197 00198 } 00199 L(" allocated = %d unallocated = %d maxunallocatedblock = %d\n", allocated * sizeof(HEADER), 00200 unallocated * sizeof(HEADER), maxunallocatedblock * sizeof(HEADER)); 00201 #endif 00202 }
1.3.4