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 197
 <INITIAL>{CHILDREN}	{ count(); yylval.strval=yytext; return CHILDREN; }
198 198
 <INITIAL>{CHECK_VIA}	{ count(); yylval.strval=yytext; return CHECK_VIA; }
199 199
 <INITIAL>{SYN_BRANCH}	{ count(); yylval.strval=yytext; return SYN_BRANCH; }
200
+<INITIAL>{MEMLOG}	{ count(); yylval.strval=yytext; return MEMLOG; }
200 201
 <INITIAL>{SIP_WARNING}	{ count(); yylval.strval=yytext; return SIP_WARNING; }
201 202
 <INITIAL>{FIFO}	{ count(); yylval.strval=yytext; return FIFO; }
202 203
 <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 265
 		| CHECK_VIA EQUAL error { yyerror("boolean value expected"); }
266 266
 		| SYN_BRANCH EQUAL NUMBER { syn_branch=$3; }
267 267
 		| SYN_BRANCH EQUAL error { yyerror("boolean value expected"); }
268
+		| MEMLOG EQUAL NUMBER { memlog=$3; }
269
+		| MEMLOG EQUAL error { yyerror("int value expected"); }
268 270
 		| SIP_WARNING EQUAL NUMBER { sip_warning=$3; }
269 271
 		| SIP_WARNING EQUAL error { yyerror("boolean value expected"); }
270 272
 		| 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 262
 	int h;
263 263
 	int size;
264 264
 
265
-	LOG(L_INFO, "fm_status (%p):\n", qm);
265
+	LOG(memlog, "fm_status (%p):\n", qm);
266 266
 	if (!qm) return;
267 267
 
268
-	LOG(L_INFO, " heap size= %d\n", qm->size);
268
+	LOG(memlog, " heap size= %d\n", qm->size);
269 269
 #ifdef DBG_F_MALLOC
270
-	LOG(L_INFO, " used= %d, used+overhead=%d, free=%d\n",
270
+	LOG(memlog, " used= %d, used+overhead=%d, free=%d\n",
271 271
 			qm->used, qm->real_used, qm->size-qm->real_used);
272
-	LOG(L_INFO, " max used (+overhead)= %d\n", qm->max_real_used);
272
+	LOG(memlog, " max used (+overhead)= %d\n", qm->max_real_used);
273 273
 #endif
274 274
 	/*
275
-	LOG(L_INFO, "dumping all fragments:\n");
275
+	LOG(memlog, "dumping all fragments:\n");
276 276
 	for (f=qm->first_frag, i=0;((char*)f<(char*)qm->last_frag) && (i<10);
277 277
 			f=FRAG_NEXT(f), i++){
278
-		LOG(L_INFO, "    %3d. %c  address=%x  size=%d\n", i, 
278
+		LOG(memlog, "    %3d. %c  address=%x  size=%d\n", i, 
279 279
 				(f->u.reserved)?'a':'N',
280 280
 				(char*)f+sizeof(struct fm_frag), f->size);
281 281
 #ifdef DBG_F_MALLOC
282
-		LOG(L_INFO, "            %s from %s: %s(%d)\n",
282
+		LOG(memlog, "            %s from %s: %s(%d)\n",
283 283
 				(f->u.is_free)?"freed":"alloc'd", f->file, f->func, f->line);
284 284
 #endif
285 285
 	}
286 286
 */
287
-	LOG(L_INFO, "dumping free list:\n");
287
+	LOG(memlog, "dumping free list:\n");
288 288
 	for(h=0,i=0,size=0;h<F_HASH_SIZE;h++){
289 289
 		
290 290
 		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"
291
+		if (j) LOG(memlog, "hash = %3d fragments no.: %5d,\n\t\t"
292 292
 							" bucket size: %9d - %9d (first %9d)\n",
293 293
 							h, j, UN_HASH(h),
294 294
 							((h<F_MALLOC_OPTIMIZE/ROUNDTO)?1:2)*UN_HASH(h),
... ...
@@ -296,7 +297,7 @@ void fm_status(struct fm_block* qm)
296 296
 				);
297 297
 		/*
298 298
 		{
299
-			LOG(L_INFO, "   %5d.[%3d:%3d] %c  address=%x  size=%d(%x)\n",
299
+			LOG(memlog, "   %5d.[%3d:%3d] %c  address=%x  size=%d(%x)\n",
300 300
 					i, h, j,
301 301
 					(f->u.reserved)?'a':'N',
302 302
 					(char*)f+sizeof(struct fm_frag), f->size, f->size);
... ...
@@ -307,8 +308,8 @@ void fm_status(struct fm_block* qm)
307 307
 		}
308 308
 	*/
309 309
 	}
310
-	LOG(L_INFO, "TOTAL: %6d free fragments = %6d free bytes\n", i, size);
311
-	LOG(L_INFO, "-----------------------------\n");
310
+	LOG(memlog, "TOTAL: %6d free fragments = %6d free bytes\n", i, size);
311
+	LOG(memlog, "-----------------------------\n");
312 312
 }
313 313
 
314 314
 
... ...
@@ -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 392
 	int i,j;
393 393
 	int h;
394 394
 
395
-	LOG(L_INFO, "qm_status (%p):\n", qm);
395
+	LOG(memlog, "qm_status (%p):\n", qm);
396 396
 	if (!qm) return;
397 397
 
398
-	LOG(L_INFO, " heap size= %d\n", qm->size);
399
-	LOG(L_INFO, " used= %d, used+overhead=%d, free=%d\n",
398
+	LOG(memlog, " heap size= %d\n", qm->size);
399
+	LOG(memlog, " used= %d, used+overhead=%d, free=%d\n",
400 400
 			qm->used, qm->real_used, qm->size-qm->real_used);
401
-	LOG(L_INFO, " max used (+overhead)= %d\n", qm->max_real_used);
401
+	LOG(memlog, " max used (+overhead)= %d\n", qm->max_real_used);
402 402
 	
403
-	LOG(L_INFO, "dumping all allocked. fragments:\n");
403
+	LOG(memlog, "dumping all allocked. fragments:\n");
404 404
 	for (f=qm->first_frag, i=0;(char*)f<(char*)qm->last_frag_end;f=FRAG_NEXT(f)
405 405
 			,i++){
406 406
 		if (! f->u.is_free){
407
-			LOG(L_INFO, "    %3d. %c  address=%p  size=%d\n", i, 
407
+			LOG(memlog, "    %3d. %c  address=%p  size=%d\n", i, 
408 408
 				(f->u.is_free)?'a':'N',
409 409
 				(char*)f+sizeof(struct qm_frag), f->size);
410 410
 #ifdef DBG_QM_MALLOC
411
-			LOG(L_INFO, "            %s from %s: %s(%d)\n",
411
+			LOG(memlog, "            %s from %s: %s(%d)\n",
412 412
 				(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",
413
+			LOG(memlog, "        start check=%x, end check= %x, %x\n",
414 414
 				f->check, FRAG_END(f)->check1, FRAG_END(f)->check2);
415 415
 #endif
416 416
 		}
417 417
 	}
418
-	LOG(L_INFO, "dumping free list stats :\n");
418
+	LOG(memlog, "dumping free list stats :\n");
419 419
 	for(h=0,i=0;h<QM_HASH_SIZE;h++){
420 420
 		
421 421
 		for (f=qm->free_hash[h].head.u.nxt_free,j=0; 
422 422
 				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);
423
+			if (j) LOG(memlog, "hash= %3d. fragments no.: %5d\n", h, j);
424 424
 	}
425
-	LOG(L_INFO, "-----------------------------\n");
425
+	LOG(memlog, "-----------------------------\n");
426 426
 }
427 427
 
428 428
 
... ...
@@ -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 401
 
402 402
 void dump_frag( struct vqm_frag* f, int i )
403 403
 {
404
-	LOG(L_INFO, "    %3d. address=%p  real size=%d bucket=%d\n", i, 
404
+	LOG(memlog, "    %3d. address=%p  real size=%d bucket=%d\n", i, 
405 405
 		(char*)f+sizeof(struct vqm_frag), f->size, f->u.inuse.bucket);
406 406
 #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",
407
+	LOG(memlog, "            demanded size=%d\n", f->demanded_size );
408
+	LOG(memlog, "            alloc'd from %s: %s(%d)\n",
409 409
 		f->file, f->func, f->line);
410
-	LOG(L_INFO, "        start check=%x, end check= %.*s\n",
410
+	LOG(memlog, "        start check=%x, end check= %.*s\n",
411 411
 			f->check, END_CHECK_PATTERN_LEN, f->end_check );
412 412
 #endif
413 413
 }
... ...
@@ -417,16 +418,16 @@ void vqm_status(struct vqm_block* qm)
417 417
 	struct vqm_frag* f;
418 418
 	unsigned int i,on_list;
419 419
 
420
-	LOG(L_INFO, "vqm_status (%p):\n", qm);
420
+	LOG(memlog, "vqm_status (%p):\n", qm);
421 421
 	if (!qm) return;
422
-	LOG(L_INFO, " heap size= %d, available: %d\n", 
422
+	LOG(memlog, " heap size= %d, available: %d\n", 
423 423
 		qm->core_end-qm->init_core, qm->free_core );
424 424
 	
425
-	LOG(L_INFO, "dumping unfreed fragments:\n");
425
+	LOG(memlog, "dumping unfreed fragments:\n");
426 426
 	for (f=(struct vqm_frag*)qm->init_core, i=0;(char*)f<(char*)qm->core;
427 427
 		f=FRAG_NEXT(f) ,i++) if ( FRAG_ISUSED(f) ) dump_frag(f, i);
428 428
 
429
-	LOG(L_INFO, "dumping unfreed big fragments:\n");
429
+	LOG(memlog, "dumping unfreed big fragments:\n");
430 430
     for (f=(struct vqm_frag*)qm->big_chunks,i=0;(char*)f<(char*)qm->core_end;
431 431
 		f=FRAG_NEXT(f) ,i++) if ( FRAG_ISUSED(f) ) dump_frag( f, i );
432 432
 
... ...
@@ -438,7 +439,7 @@ void vqm_status(struct vqm_block* qm)
438 438
 			i, qm->usage[i], on_list );
439 439
 	}
440 440
 #endif
441
-	LOG(L_INFO, "-----------------------------\n");
441
+	LOG(memlog, "-----------------------------\n");
442 442
 }
443 443
 
444 444