Browse code

memlog option introduced

Jiri Kuthan authored on 10/09/2002 10:40:54
Showing 5 changed files
... ...
@@ -100,6 +100,7 @@ MAXBUFFER maxbuffer
100 100
 CHILDREN children
101 101
 CHECK_VIA	check_via
102 102
 SYN_BRANCH syn_branch
103
+MEMLOG	memlog
103 104
 SIP_WARNING sip_warning
104 105
 FIFO fifo
105 106
 FIFO_MODE fifo_mode
... ...
@@ -197,6 +198,7 @@ EAT_ABLE	[\ \t\b\r]
197 198
 <INITIAL>{CHILDREN}	{ count(); yylval.strval=yytext; return CHILDREN; }
198 199
 <INITIAL>{CHECK_VIA}	{ count(); yylval.strval=yytext; return CHECK_VIA; }
199 200
 <INITIAL>{SYN_BRANCH}	{ count(); yylval.strval=yytext; return SYN_BRANCH; }
201
+<INITIAL>{MEMLOG}	{ count(); yylval.strval=yytext; return MEMLOG; }
200 202
 <INITIAL>{SIP_WARNING}	{ count(); yylval.strval=yytext; return SIP_WARNING; }
201 203
 <INITIAL>{FIFO}	{ count(); yylval.strval=yytext; return FIFO; }
202 204
 <INITIAL>{FIFO_MODE}	{ count(); yylval.strval=yytext; return FIFO_MODE; }
... ...
@@ -105,6 +105,7 @@ struct id_list* lst_tmp;
105 105
 %token CHILDREN
106 106
 %token CHECK_VIA
107 107
 %token SYN_BRANCH
108
+%token MEMLOG
108 109
 %token SIP_WARNING
109 110
 %token FIFO
110 111
 %token FIFO_MODE
... ...
@@ -265,6 +266,8 @@ assign_stm:	DEBUG EQUAL NUMBER { debug=$3; }
265 266
 		| CHECK_VIA EQUAL error { yyerror("boolean value expected"); }
266 267
 		| SYN_BRANCH EQUAL NUMBER { syn_branch=$3; }
267 268
 		| SYN_BRANCH EQUAL error { yyerror("boolean value expected"); }
269
+		| MEMLOG EQUAL NUMBER { memlog=$3; }
270
+		| MEMLOG EQUAL error { yyerror("int value expected"); }
268 271
 		| SIP_WARNING EQUAL NUMBER { sip_warning=$3; }
269 272
 		| SIP_WARNING EQUAL error { yyerror("boolean value expected"); }
270 273
 		| FIFO EQUAL STRING { fifo=$3; }
... ...
@@ -8,6 +8,7 @@
8 8
 
9 9
 #include "f_malloc.h"
10 10
 #include "../dprint.h"
11
+#include "../globals.h"
11 12
 
12 13
 
13 14
 /*useful macros*/
... ...
@@ -262,33 +263,33 @@ void fm_status(struct fm_block* qm)
262 263
 	int h;
263 264
 	int size;
264 265
 
265
-	LOG(L_INFO, "fm_status (%p):\n", qm);
266
+	LOG(memlog, "fm_status (%p):\n", qm);
266 267
 	if (!qm) return;
267 268
 
268
-	LOG(L_INFO, " heap size= %d\n", qm->size);
269
+	LOG(memlog, " heap size= %d\n", qm->size);
269 270
 #ifdef DBG_F_MALLOC
270
-	LOG(L_INFO, " used= %d, used+overhead=%d, free=%d\n",
271
+	LOG(memlog, " used= %d, used+overhead=%d, free=%d\n",
271 272
 			qm->used, qm->real_used, qm->size-qm->real_used);
272
-	LOG(L_INFO, " max used (+overhead)= %d\n", qm->max_real_used);
273
+	LOG(memlog, " max used (+overhead)= %d\n", qm->max_real_used);
273 274
 #endif
274 275
 	/*
275
-	LOG(L_INFO, "dumping all fragments:\n");
276
+	LOG(memlog, "dumping all fragments:\n");
276 277
 	for (f=qm->first_frag, i=0;((char*)f<(char*)qm->last_frag) && (i<10);
277 278
 			f=FRAG_NEXT(f), i++){
278
-		LOG(L_INFO, "    %3d. %c  address=%x  size=%d\n", i, 
279
+		LOG(memlog, "    %3d. %c  address=%x  size=%d\n", i, 
279 280
 				(f->u.reserved)?'a':'N',
280 281
 				(char*)f+sizeof(struct fm_frag), f->size);
281 282
 #ifdef DBG_F_MALLOC
282
-		LOG(L_INFO, "            %s from %s: %s(%d)\n",
283
+		LOG(memlog, "            %s from %s: %s(%d)\n",
283 284
 				(f->u.is_free)?"freed":"alloc'd", f->file, f->func, f->line);
284 285
 #endif
285 286
 	}
286 287
 */
287
-	LOG(L_INFO, "dumping free list:\n");
288
+	LOG(memlog, "dumping free list:\n");
288 289
 	for(h=0,i=0,size=0;h<F_HASH_SIZE;h++){
289 290
 		
290 291
 		for (f=qm->free_hash[h],j=0; f; size+=f->size,f=f->u.nxt_free,i++,j++);
291
-		if (j) LOG(L_INFO, "hash = %3d fragments no.: %5d,\n\t\t"
292
+		if (j) LOG(memlog, "hash = %3d fragments no.: %5d,\n\t\t"
292 293
 							" bucket size: %9d - %9d (first %9d)\n",
293 294
 							h, j, UN_HASH(h),
294 295
 							((h<F_MALLOC_OPTIMIZE/ROUNDTO)?1:2)*UN_HASH(h),
... ...
@@ -296,7 +297,7 @@ void fm_status(struct fm_block* qm)
296 297
 				);
297 298
 		/*
298 299
 		{
299
-			LOG(L_INFO, "   %5d.[%3d:%3d] %c  address=%x  size=%d(%x)\n",
300
+			LOG(memlog, "   %5d.[%3d:%3d] %c  address=%x  size=%d(%x)\n",
300 301
 					i, h, j,
301 302
 					(f->u.reserved)?'a':'N',
302 303
 					(char*)f+sizeof(struct fm_frag), f->size, f->size);
... ...
@@ -307,8 +308,8 @@ void fm_status(struct fm_block* qm)
307 308
 		}
308 309
 	*/
309 310
 	}
310
-	LOG(L_INFO, "TOTAL: %6d free fragments = %6d free bytes\n", i, size);
311
-	LOG(L_INFO, "-----------------------------\n");
311
+	LOG(memlog, "TOTAL: %6d free fragments = %6d free bytes\n", i, size);
312
+	LOG(memlog, "-----------------------------\n");
312 313
 }
313 314
 
314 315
 
... ...
@@ -10,6 +10,7 @@
10 10
 
11 11
 #include "q_malloc.h"
12 12
 #include "../dprint.h"
13
+#include "../globals.h"
13 14
 
14 15
 
15 16
 /*useful macros*/
... ...
@@ -392,37 +393,37 @@ void qm_status(struct qm_block* qm)
392 393
 	int i,j;
393 394
 	int h;
394 395
 
395
-	LOG(L_INFO, "qm_status (%p):\n", qm);
396
+	LOG(memlog, "qm_status (%p):\n", qm);
396 397
 	if (!qm) return;
397 398
 
398
-	LOG(L_INFO, " heap size= %d\n", qm->size);
399
-	LOG(L_INFO, " used= %d, used+overhead=%d, free=%d\n",
399
+	LOG(memlog, " heap size= %d\n", qm->size);
400
+	LOG(memlog, " used= %d, used+overhead=%d, free=%d\n",
400 401
 			qm->used, qm->real_used, qm->size-qm->real_used);
401
-	LOG(L_INFO, " max used (+overhead)= %d\n", qm->max_real_used);
402
+	LOG(memlog, " max used (+overhead)= %d\n", qm->max_real_used);
402 403
 	
403
-	LOG(L_INFO, "dumping all allocked. fragments:\n");
404
+	LOG(memlog, "dumping all allocked. fragments:\n");
404 405
 	for (f=qm->first_frag, i=0;(char*)f<(char*)qm->last_frag_end;f=FRAG_NEXT(f)
405 406
 			,i++){
406 407
 		if (! f->u.is_free){
407
-			LOG(L_INFO, "    %3d. %c  address=%p  size=%d\n", i, 
408
+			LOG(memlog, "    %3d. %c  address=%p  size=%d\n", i, 
408 409
 				(f->u.is_free)?'a':'N',
409 410
 				(char*)f+sizeof(struct qm_frag), f->size);
410 411
 #ifdef DBG_QM_MALLOC
411
-			LOG(L_INFO, "            %s from %s: %s(%d)\n",
412
+			LOG(memlog, "            %s from %s: %s(%d)\n",
412 413
 				(f->u.is_free)?"freed":"alloc'd", f->file, f->func, f->line);
413
-			LOG(L_INFO, "        start check=%x, end check= %x, %x\n",
414
+			LOG(memlog, "        start check=%x, end check= %x, %x\n",
414 415
 				f->check, FRAG_END(f)->check1, FRAG_END(f)->check2);
415 416
 #endif
416 417
 		}
417 418
 	}
418
-	LOG(L_INFO, "dumping free list stats :\n");
419
+	LOG(memlog, "dumping free list stats :\n");
419 420
 	for(h=0,i=0;h<QM_HASH_SIZE;h++){
420 421
 		
421 422
 		for (f=qm->free_hash[h].head.u.nxt_free,j=0; 
422 423
 				f!=&(qm->free_hash[h].head); f=f->u.nxt_free, i++, j++);
423
-			if (j) LOG(L_INFO, "hash= %3d. fragments no.: %5d\n", h, j);
424
+			if (j) LOG(memlog, "hash= %3d. fragments no.: %5d\n", h, j);
424 425
 	}
425
-	LOG(L_INFO, "-----------------------------\n");
426
+	LOG(memlog, "-----------------------------\n");
426 427
 }
427 428
 
428 429
 
... ...
@@ -55,6 +55,7 @@
55 55
 #include "../globals.h"
56 56
 #include "vq_malloc.h"
57 57
 #include "../dprint.h"
58
+#include "../globals.h"
58 59
 
59 60
 #define BIG_BUCKET(_qm) ((_qm)->max_small_bucket+1)
60 61
 #define IS_BIGBUCKET(_qm, _bucket) ((_bucket)==BIG_BUCKET(_qm)) 
... ...
@@ -401,13 +402,13 @@ void vqm_free(struct vqm_block* qm, void* p)
401 402
 
402 403
 void dump_frag( struct vqm_frag* f, int i )
403 404
 {
404
-	LOG(L_INFO, "    %3d. address=%p  real size=%d bucket=%d\n", i, 
405
+	LOG(memlog, "    %3d. address=%p  real size=%d bucket=%d\n", i, 
405 406
 		(char*)f+sizeof(struct vqm_frag), f->size, f->u.inuse.bucket);
406 407
 #ifdef DBG_QM_MALLOC
407
-	LOG(L_INFO, "            demanded size=%d\n", f->demanded_size );
408
-	LOG(L_INFO, "            alloc'd from %s: %s(%d)\n",
408
+	LOG(memlog, "            demanded size=%d\n", f->demanded_size );
409
+	LOG(memlog, "            alloc'd from %s: %s(%d)\n",
409 410
 		f->file, f->func, f->line);
410
-	LOG(L_INFO, "        start check=%x, end check= %.*s\n",
411
+	LOG(memlog, "        start check=%x, end check= %.*s\n",
411 412
 			f->check, END_CHECK_PATTERN_LEN, f->end_check );
412 413
 #endif
413 414
 }
... ...
@@ -417,16 +418,16 @@ void vqm_status(struct vqm_block* qm)
417 418
 	struct vqm_frag* f;
418 419
 	unsigned int i,on_list;
419 420
 
420
-	LOG(L_INFO, "vqm_status (%p):\n", qm);
421
+	LOG(memlog, "vqm_status (%p):\n", qm);
421 422
 	if (!qm) return;
422
-	LOG(L_INFO, " heap size= %d, available: %d\n", 
423
+	LOG(memlog, " heap size= %d, available: %d\n", 
423 424
 		qm->core_end-qm->init_core, qm->free_core );
424 425
 	
425
-	LOG(L_INFO, "dumping unfreed fragments:\n");
426
+	LOG(memlog, "dumping unfreed fragments:\n");
426 427
 	for (f=(struct vqm_frag*)qm->init_core, i=0;(char*)f<(char*)qm->core;
427 428
 		f=FRAG_NEXT(f) ,i++) if ( FRAG_ISUSED(f) ) dump_frag(f, i);
428 429
 
429
-	LOG(L_INFO, "dumping unfreed big fragments:\n");
430
+	LOG(memlog, "dumping unfreed big fragments:\n");
430 431
     for (f=(struct vqm_frag*)qm->big_chunks,i=0;(char*)f<(char*)qm->core_end;
431 432
 		f=FRAG_NEXT(f) ,i++) if ( FRAG_ISUSED(f) ) dump_frag( f, i );
432 433
 
... ...
@@ -438,7 +439,7 @@ void vqm_status(struct vqm_block* qm)
438 439
 			i, qm->usage[i], on_list );
439 440
 	}
440 441
 #endif
441
-	LOG(L_INFO, "-----------------------------\n");
442
+	LOG(memlog, "-----------------------------\n");
442 443
 }
443 444
 
444 445