- default log level switched to 0: this means that in the absence
of -d* commandline parameters or of the debug=no in ser.cfg, only
errors and other critical messages will be logged (no warnings,
info, notice or dbg).
... | ... |
@@ -49,6 +49,11 @@ modules: |
49 | 49 |
Vias a.s.o) and not on the original message |
50 | 50 |
|
51 | 51 |
core: |
52 |
+ - default log level switched to 0 (only messages < L_WARN will be printed |
|
53 |
+ by default) |
|
54 |
+ - separate memdbg log level which controls the memory/malloc related |
|
55 |
+ debug messages (to see them ser must be compiled with malloc debuging: |
|
56 |
+ -DDBG_QM_MALLOC or -DDBG_FM_MALLOC and memdbg must be <= debug ) |
|
52 | 57 |
- added named routes: names can be used instead of numbers in all the |
53 | 58 |
route commads or route declarations. route(number) is equivalent to |
54 | 59 |
route("number"). |
... | ... |
@@ -229,6 +229,7 @@ CHILDREN children |
229 | 229 |
CHECK_VIA check_via |
230 | 230 |
SYN_BRANCH syn_branch |
231 | 231 |
MEMLOG "memlog"|"mem_log" |
232 |
+MEMDBG "memdbg"|"mem_dbg" |
|
232 | 233 |
SIP_WARNING sip_warning |
233 | 234 |
SERVER_SIGNATURE server_signature |
234 | 235 |
REPLY_TO_VIA reply_to_via |
... | ... |
@@ -418,6 +419,7 @@ EAT_ABLE [\ \t\b\r] |
418 | 419 |
<INITIAL>{CHECK_VIA} { count(); yylval.strval=yytext; return CHECK_VIA; } |
419 | 420 |
<INITIAL>{SYN_BRANCH} { count(); yylval.strval=yytext; return SYN_BRANCH; } |
420 | 421 |
<INITIAL>{MEMLOG} { count(); yylval.strval=yytext; return MEMLOG; } |
422 |
+<INITIAL>{MEMDBG} { count(); yylval.strval=yytext; return MEMDBG; } |
|
421 | 423 |
<INITIAL>{SIP_WARNING} { count(); yylval.strval=yytext; return SIP_WARNING; } |
422 | 424 |
<INITIAL>{USER} { count(); yylval.strval=yytext; return USER; } |
423 | 425 |
<INITIAL>{GROUP} { count(); yylval.strval=yytext; return GROUP; } |
... | ... |
@@ -236,6 +236,7 @@ static struct socket_id* mk_listen_id(char*, int, int); |
236 | 236 |
%token CHECK_VIA |
237 | 237 |
%token SYN_BRANCH |
238 | 238 |
%token MEMLOG |
239 |
+%token MEMDBG |
|
239 | 240 |
%token SIP_WARNING |
240 | 241 |
%token SERVER_SIGNATURE |
241 | 242 |
%token REPLY_TO_VIA |
... | ... |
@@ -504,6 +505,8 @@ assign_stm: |
504 | 505 |
| SYN_BRANCH EQUAL error { yyerror("boolean value expected"); } |
505 | 506 |
| MEMLOG EQUAL NUMBER { memlog=$3; } |
506 | 507 |
| MEMLOG EQUAL error { yyerror("int value expected"); } |
508 |
+ | MEMDBG EQUAL NUMBER { memdbg=$3; } |
|
509 |
+ | MEMDBG EQUAL error { yyerror("int value expected"); } |
|
507 | 510 |
| SIP_WARNING EQUAL NUMBER { sip_warning=$3; } |
508 | 511 |
| SIP_WARNING EQUAL error { yyerror("boolean value expected"); } |
509 | 512 |
| USER EQUAL STRING { user=$3; } |
... | ... |
@@ -139,6 +139,8 @@ extern int is_main; |
139 | 139 |
|
140 | 140 |
/* debugging level for dumping memory status */ |
141 | 141 |
extern int memlog; |
142 |
+/* debugging level for malloc debugging messages */ |
|
143 |
+extern int memdbg; |
|
142 | 144 |
|
143 | 145 |
/* debugging level for timer debugging (see -DTIMER_DEBUG) */ |
144 | 146 |
extern int timerlog; |
... | ... |
@@ -242,7 +242,7 @@ int tls_disable = 0; /* 1 if tls is disabled */ |
242 | 242 |
struct process_table *pt=0; /*array with children pids, 0= main proc, |
243 | 243 |
alloc'ed in shared mem if possible*/ |
244 | 244 |
int sig_flag = 0; /* last signal received */ |
245 |
-int debug = L_NOTICE; |
|
245 |
+int debug = L_DEFAULT; /* print only msg. < L_WARN */ |
|
246 | 246 |
int dont_fork = 0; |
247 | 247 |
int log_stderr = 0; |
248 | 248 |
/* log facility (see syslog(3)) */ |
... | ... |
@@ -254,6 +254,8 @@ int check_via = 0; |
254 | 254 |
int syn_branch = 1; |
255 | 255 |
/* debugging level for memory stats */ |
256 | 256 |
int memlog = L_DBG; |
257 |
+/* debugging level for the malloc debug messages */ |
|
258 |
+int memdbg = L_DBG; |
|
257 | 259 |
/* debugging level for timer debugging */ |
258 | 260 |
int timerlog = L_WARN; |
259 | 261 |
/* should replies include extensive warnings? by default yes, |
... | ... |
@@ -37,6 +37,7 @@ |
37 | 37 |
* 2005-12-12 fixed realloc shrink real_used accounting (andrei) |
38 | 38 |
* fixed initial size (andrei) |
39 | 39 |
* 2006-02-03 fixed realloc out of mem. free bug (andrei) |
40 |
+ * 2006-04-07 s/DBG/MDBG (andrei) |
|
40 | 41 |
*/ |
41 | 42 |
|
42 | 43 |
|
... | ... |
@@ -48,6 +49,7 @@ |
48 | 49 |
#include "f_malloc.h" |
49 | 50 |
#include "../dprint.h" |
50 | 51 |
#include "../globals.h" |
52 |
+#include "memdbg.h" |
|
51 | 53 |
|
52 | 54 |
|
53 | 55 |
/*useful macros*/ |
... | ... |
@@ -256,7 +258,7 @@ void* fm_malloc(struct fm_block* qm, unsigned long size) |
256 | 258 |
int hash; |
257 | 259 |
|
258 | 260 |
#ifdef DBG_F_MALLOC |
259 |
- DBG("fm_malloc(%p, %lu) called from %s: %s(%d)\n", qm, size, file, func, |
|
261 |
+ MDBG("fm_malloc(%p, %lu) called from %s: %s(%d)\n", qm, size, file, func, |
|
260 | 262 |
line); |
261 | 263 |
#endif |
262 | 264 |
/*size must be a multiple of 8*/ |
... | ... |
@@ -292,7 +294,7 @@ found: |
292 | 294 |
frag->func=func; |
293 | 295 |
frag->line=line; |
294 | 296 |
frag->check=ST_CHECK_PATTERN; |
295 |
- DBG("fm_malloc(%p, %lu) returns address %p \n", qm, size, |
|
297 |
+ MDBG("fm_malloc(%p, %lu) returns address %p \n", qm, size, |
|
296 | 298 |
(char*)frag+sizeof(struct fm_frag)); |
297 | 299 |
#else |
298 | 300 |
fm_split_frag(qm, frag, size); |
... | ... |
@@ -320,7 +322,7 @@ void fm_free(struct fm_block* qm, void* p) |
320 | 322 |
unsigned long size; |
321 | 323 |
|
322 | 324 |
#ifdef DBG_F_MALLOC |
323 |
- DBG("fm_free(%p, %p), called from %s: %s(%d)\n", qm, p, file, func, line); |
|
325 |
+ MDBG("fm_free(%p, %p), called from %s: %s(%d)\n", qm, p, file, func, line); |
|
324 | 326 |
if (p>(void*)qm->last_frag || p<(void*)qm->first_frag){ |
325 | 327 |
LOG(L_CRIT, "BUG: fm_free: bad pointer %p (out of memory block!) - " |
326 | 328 |
"aborting\n", p); |
... | ... |
@@ -333,8 +335,8 @@ void fm_free(struct fm_block* qm, void* p) |
333 | 335 |
} |
334 | 336 |
f=(struct fm_frag*) ((char*)p-sizeof(struct fm_frag)); |
335 | 337 |
#ifdef DBG_F_MALLOC |
336 |
- DBG("fm_free: freeing block alloc'ed from %s: %s(%ld)\n", f->file, f->func, |
|
337 |
- f->line); |
|
338 |
+ MDBG("fm_free: freeing block alloc'ed from %s: %s(%ld)\n", |
|
339 |
+ f->file, f->func, f->line); |
|
338 | 340 |
#endif |
339 | 341 |
size=f->size; |
340 | 342 |
#if defined(DBG_F_MALLOC) || defined(MALLOC_STATS) |
... | ... |
@@ -366,7 +368,7 @@ void* fm_realloc(struct fm_block* qm, void* p, unsigned long size) |
366 | 368 |
int hash; |
367 | 369 |
|
368 | 370 |
#ifdef DBG_F_MALLOC |
369 |
- DBG("fm_realloc(%p, %p, %lu) called from %s: %s(%d)\n", qm, p, size, |
|
371 |
+ MDBG("fm_realloc(%p, %p, %lu) called from %s: %s(%d)\n", qm, p, size, |
|
370 | 372 |
file, func, line); |
371 | 373 |
if ((p)&&(p>(void*)qm->last_frag || p<(void*)qm->first_frag)){ |
372 | 374 |
LOG(L_CRIT, "BUG: fm_free: bad pointer %p (out of memory block!) - " |
... | ... |
@@ -391,7 +393,7 @@ void* fm_realloc(struct fm_block* qm, void* p, unsigned long size) |
391 | 393 |
#endif |
392 | 394 |
f=(struct fm_frag*) ((char*)p-sizeof(struct fm_frag)); |
393 | 395 |
#ifdef DBG_F_MALLOC |
394 |
- DBG("fm_realloc: realloc'ing frag %p alloc'ed from %s: %s(%ld)\n", |
|
396 |
+ MDBG("fm_realloc: realloc'ing frag %p alloc'ed from %s: %s(%ld)\n", |
|
395 | 397 |
f, f->file, f->func, f->line); |
396 | 398 |
#endif |
397 | 399 |
size=ROUNDUP(size); |
... | ... |
@@ -399,7 +401,7 @@ void* fm_realloc(struct fm_block* qm, void* p, unsigned long size) |
399 | 401 |
if (f->size > size){ |
400 | 402 |
/* shrink */ |
401 | 403 |
#ifdef DBG_F_MALLOC |
402 |
- DBG("fm_realloc: shrinking from %lu to %lu\n", f->size, size); |
|
404 |
+ MDBG("fm_realloc: shrinking from %lu to %lu\n", f->size, size); |
|
403 | 405 |
fm_split_frag(qm, f, size, file, "frag. from fm_realloc", line); |
404 | 406 |
#else |
405 | 407 |
fm_split_frag(qm, f, size); |
... | ... |
@@ -411,7 +413,7 @@ void* fm_realloc(struct fm_block* qm, void* p, unsigned long size) |
411 | 413 |
}else if (f->size<size){ |
412 | 414 |
/* grow */ |
413 | 415 |
#ifdef DBG_F_MALLOC |
414 |
- DBG("fm_realloc: growing from %lu to %lu\n", f->size, size); |
|
416 |
+ MDBG("fm_realloc: growing from %lu to %lu\n", f->size, size); |
|
415 | 417 |
#endif |
416 | 418 |
diff=size-f->size; |
417 | 419 |
n=FRAG_NEXT(f); |
... | ... |
@@ -471,12 +473,12 @@ void* fm_realloc(struct fm_block* qm, void* p, unsigned long size) |
471 | 473 |
}else{ |
472 | 474 |
/* do nothing */ |
473 | 475 |
#ifdef DBG_F_MALLOC |
474 |
- DBG("fm_realloc: doing nothing, same size: %lu - %lu\n", |
|
476 |
+ MDBG("fm_realloc: doing nothing, same size: %lu - %lu\n", |
|
475 | 477 |
f->size, size); |
476 | 478 |
#endif |
477 | 479 |
} |
478 | 480 |
#ifdef DBG_F_MALLOC |
479 |
- DBG("fm_realloc: returning %p\n", p); |
|
481 |
+ MDBG("fm_realloc: returning %p\n", p); |
|
480 | 482 |
#endif |
481 | 483 |
return p; |
482 | 484 |
} |
... | ... |
@@ -121,11 +121,12 @@ |
121 | 121 |
# define pkg_status() shm_status() |
122 | 122 |
#else |
123 | 123 |
# include <stdlib.h> |
124 |
+# include "memdbg.h" |
|
124 | 125 |
# define pkg_malloc(s) \ |
125 | 126 |
( { void *v; v=malloc((s)); \ |
126 |
- DBG("malloc %p size %d end %p\n", v, s, (char*)v+(s));\ |
|
127 |
+ MDBG("malloc %p size %d end %p\n", v, s, (char*)v+(s));\ |
|
127 | 128 |
v; } ) |
128 |
-# define pkg_free(p) do{ DBG("free %p\n", (p)); free((p)); }while(0); |
|
129 |
+# define pkg_free(p) do{ MDBG("free %p\n", (p)); free((p)); }while(0); |
|
129 | 130 |
# define pkg_status() |
130 | 131 |
#endif |
131 | 132 |
|
132 | 133 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,45 @@ |
1 |
+/* |
|
2 |
+ * $Id$ |
|
3 |
+ * |
|
4 |
+ * Copyright (C) 2006 iptelorg GmbH |
|
5 |
+ * |
|
6 |
+ * Permission to use, copy, modify, and distribute this software for any |
|
7 |
+ * purpose with or without fee is hereby granted, provided that the above |
|
8 |
+ * copyright notice and this permission notice appear in all copies. |
|
9 |
+ * |
|
10 |
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES |
|
11 |
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF |
|
12 |
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR |
|
13 |
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
|
14 |
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN |
|
15 |
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF |
|
16 |
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
|
17 |
+ */ |
|
18 |
+/* malloc debug messages |
|
19 |
+ * History: |
|
20 |
+ * -------- |
|
21 |
+ * 2006-04-07 created by andrei |
|
22 |
+ */ |
|
23 |
+ |
|
24 |
+ |
|
25 |
+#ifndef _memdbg_h |
|
26 |
+#define _memdbg_h |
|
27 |
+ |
|
28 |
+extern int memdbg; |
|
29 |
+ |
|
30 |
+#ifdef NO_DEBUG |
|
31 |
+ #ifdef __SUNPRO_C |
|
32 |
+ #define MDBG(...) |
|
33 |
+ #else |
|
34 |
+ #define MDBG(fmt, args...) |
|
35 |
+ #endif |
|
36 |
+#else /* NO_DEBUG */ |
|
37 |
+ #ifdef __SUNPRO_C |
|
38 |
+ #define MDBG(...) LOG(memdbg, __VA_ARGS__) |
|
39 |
+ #else |
|
40 |
+ #define MDBG(fmt, args...) LOG(memdbg, fmt, ## args) |
|
41 |
+ #endif |
|
42 |
+#endif /* NO_DEBUG */ |
|
43 |
+ |
|
44 |
+ |
|
45 |
+#endif |
... | ... |
@@ -38,6 +38,7 @@ |
38 | 38 |
* 2005-12-12 fixed realloc shrink real_used & used accounting; |
39 | 39 |
* fixed initial size (andrei) |
40 | 40 |
* 2006-02-03 fixed realloc out of mem. free bug (andrei) |
41 |
+ * 2006-04-07 s/DBG/MDBG (andrei) |
|
41 | 42 |
*/ |
42 | 43 |
|
43 | 44 |
|
... | ... |
@@ -50,6 +51,7 @@ |
50 | 51 |
#include "q_malloc.h" |
51 | 52 |
#include "../dprint.h" |
52 | 53 |
#include "../globals.h" |
54 |
+#include "memdbg.h" |
|
53 | 55 |
|
54 | 56 |
|
55 | 57 |
/*useful macros*/ |
... | ... |
@@ -364,7 +366,7 @@ void* qm_malloc(struct qm_block* qm, unsigned long size) |
364 | 366 |
unsigned int list_cntr; |
365 | 367 |
|
366 | 368 |
list_cntr = 0; |
367 |
- DBG("qm_malloc(%p, %lu) called from %s: %s(%d)\n", qm, size, file, func, |
|
369 |
+ MDBG("qm_malloc(%p, %lu) called from %s: %s(%d)\n", qm, size, file, func, |
|
368 | 370 |
line); |
369 | 371 |
#endif |
370 | 372 |
/*size must be a multiple of 8*/ |
... | ... |
@@ -403,7 +405,7 @@ void* qm_malloc(struct qm_block* qm, unsigned long size) |
403 | 405 |
f->check=ST_CHECK_PATTERN; |
404 | 406 |
/* FRAG_END(f)->check1=END_CHECK_PATTERN1; |
405 | 407 |
FRAG_END(f)->check2=END_CHECK_PATTERN2;*/ |
406 |
- DBG("qm_malloc(%p, %lu) returns address %p frag. %p (size=%lu) on %d" |
|
408 |
+ MDBG("qm_malloc(%p, %lu) returns address %p frag. %p (size=%lu) on %d" |
|
407 | 409 |
" -th hit\n", |
408 | 410 |
qm, size, (char*)f+sizeof(struct qm_frag), f, f->size, list_cntr ); |
409 | 411 |
#endif |
... | ... |
@@ -427,7 +429,7 @@ void qm_free(struct qm_block* qm, void* p) |
427 | 429 |
unsigned long size; |
428 | 430 |
|
429 | 431 |
#ifdef DBG_QM_MALLOC |
430 |
- DBG("qm_free(%p, %p), called from %s: %s(%d)\n", qm, p, file, func, line); |
|
432 |
+ MDBG("qm_free(%p, %p), called from %s: %s(%d)\n", qm, p, file, func, line); |
|
431 | 433 |
if (p>(void*)qm->last_frag_end || p<(void*)qm->first_frag){ |
432 | 434 |
LOG(L_CRIT, "BUG: qm_free: bad pointer %p (out of memory block!) - " |
433 | 435 |
"aborting\n", p); |
... | ... |
@@ -448,7 +450,7 @@ void qm_free(struct qm_block* qm, void* p) |
448 | 450 |
f->file, f->func, f->line); |
449 | 451 |
abort(); |
450 | 452 |
} |
451 |
- DBG("qm_free: freeing frag. %p alloc'ed from %s: %s(%ld)\n", |
|
453 |
+ MDBG("qm_free: freeing frag. %p alloc'ed from %s: %s(%ld)\n", |
|
452 | 454 |
f, f->file, f->func, f->line); |
453 | 455 |
#endif |
454 | 456 |
size=f->size; |
... | ... |
@@ -513,7 +515,7 @@ void* qm_realloc(struct qm_block* qm, void* p, unsigned long size) |
513 | 515 |
|
514 | 516 |
|
515 | 517 |
#ifdef DBG_QM_MALLOC |
516 |
- DBG("qm_realloc(%p, %p, %lu) called from %s: %s(%d)\n", qm, p, size, |
|
518 |
+ MDBG("qm_realloc(%p, %p, %lu) called from %s: %s(%d)\n", qm, p, size, |
|
517 | 519 |
file, func, line); |
518 | 520 |
if ((p)&&(p>(void*)qm->last_frag_end || p<(void*)qm->first_frag)){ |
519 | 521 |
LOG(L_CRIT, "BUG: qm_free: bad pointer %p (out of memory block!) - " |
... | ... |
@@ -540,7 +542,7 @@ void* qm_realloc(struct qm_block* qm, void* p, unsigned long size) |
540 | 542 |
f=(struct qm_frag*) ((char*)p-sizeof(struct qm_frag)); |
541 | 543 |
#ifdef DBG_QM_MALLOC |
542 | 544 |
qm_debug_frag(qm, f); |
543 |
- DBG("qm_realloc: realloc'ing frag %p alloc'ed from %s: %s(%ld)\n", |
|
545 |
+ MDBG("qm_realloc: realloc'ing frag %p alloc'ed from %s: %s(%ld)\n", |
|
544 | 546 |
f, f->file, f->func, f->line); |
545 | 547 |
if (f->u.is_free){ |
546 | 548 |
LOG(L_CRIT, "BUG:qm_realloc: trying to realloc an already freed " |
... | ... |
@@ -554,9 +556,9 @@ void* qm_realloc(struct qm_block* qm, void* p, unsigned long size) |
554 | 556 |
orig_size=f->size; |
555 | 557 |
/* shrink */ |
556 | 558 |
#ifdef DBG_QM_MALLOC |
557 |
- DBG("qm_realloc: shrinking from %lu to %lu\n", f->size, size); |
|
559 |
+ MDBG("qm_realloc: shrinking from %lu to %lu\n", f->size, size); |
|
558 | 560 |
if(split_frag(qm, f, size, file, "fragm. from qm_realloc", line)!=0){ |
559 |
- DBG("qm_realloc : shrinked successful\n"); |
|
561 |
+ MDBG("qm_realloc : shrinked successful\n"); |
|
560 | 562 |
#else |
561 | 563 |
if(split_frag(qm, f, size)!=0){ |
562 | 564 |
#endif |
... | ... |
@@ -568,7 +570,7 @@ void* qm_realloc(struct qm_block* qm, void* p, unsigned long size) |
568 | 570 |
}else if (f->size < size){ |
569 | 571 |
/* grow */ |
570 | 572 |
#ifdef DBG_QM_MALLOC |
571 |
- DBG("qm_realloc: growing from %lu to %lu\n", f->size, size); |
|
573 |
+ MDBG("qm_realloc: growing from %lu to %lu\n", f->size, size); |
|
572 | 574 |
#endif |
573 | 575 |
orig_size=f->size; |
574 | 576 |
diff=size-f->size; |
... | ... |
@@ -614,12 +616,12 @@ void* qm_realloc(struct qm_block* qm, void* p, unsigned long size) |
614 | 616 |
}else{ |
615 | 617 |
/* do nothing */ |
616 | 618 |
#ifdef DBG_QM_MALLOC |
617 |
- DBG("qm_realloc: doing nothing, same size: %lu - %lu\n", |
|
619 |
+ MDBG("qm_realloc: doing nothing, same size: %lu - %lu\n", |
|
618 | 620 |
f->size, size); |
619 | 621 |
#endif |
620 | 622 |
} |
621 | 623 |
#ifdef DBG_QM_MALLOC |
622 |
- DBG("qm_realloc: returning %p\n", p); |
|
624 |
+ MDBG("qm_realloc: returning %p\n", p); |
|
623 | 625 |
#endif |
624 | 626 |
return p; |
625 | 627 |
} |
... | ... |
@@ -42,6 +42,7 @@ |
42 | 42 |
#include "shm_mem.h" |
43 | 43 |
#include "../config.h" |
44 | 44 |
#include "../globals.h" |
45 |
+#include "memdbg.h" |
|
45 | 46 |
|
46 | 47 |
#ifdef SHM_MMAP |
47 | 48 |
|
... | ... |
@@ -107,7 +108,7 @@ void* _shm_resize( void* p , unsigned int s) |
107 | 108 |
# ifdef DBG_QM_MALLOC |
108 | 109 |
# ifdef VQ_MALLOC |
109 | 110 |
f=(struct vqm_frag*) ((char*)p-sizeof(struct vqm_frag)); |
110 |
- DBG("_shm_resize(%p, %d), called from %s: %s(%d)\n", |
|
111 |
+ MDBG("_shm_resize(%p, %d), called from %s: %s(%d)\n", |
|
111 | 112 |
p, s, file, func, line); |
112 | 113 |
VQM_DEBUG_FRAG(shm_block, f); |
113 | 114 |
if (p>(void *)shm_block->core_end || p<(void*)shm_block->init_core){ |