5. Compile Options

The logging features in OpenSER can be tuned using several define flags at the compile time. One of them is the possibility to debug memory operations.

If you want to change these flags, you have to edit the “Makefile.defs” file from “sip_router” directory. You have to change the value of the “DEFS” variable (somewhere around the line 290). Next example shows a possibility of how this variable could look.

Example 3. Compile flags

...
DEFS+= $(extra_defs) \
	 -DNAME='"$(MAIN_NAME)"' -DVERSION='"$(RELEASE)"' -DARCH='"$(ARCH)"' \
	 -DOS='"$(OS)"' -DCOMPILER='"$(CC_VER)"' -D__CPU_$(ARCH) -D__OS_$(OS) \
	 -DCFG_DIR='"$(cfg-target)"'\
	 -DPKG_MALLOC \
	 -DSHM_MEM  -DSHM_MMAP \
	 -DDNS_IP_HACK \
	 -DUSE_IPV6 \
	 -DUSE_MCAST \
	 -DUSE_TCP \
	 -DDISABLE_NAGLE \
	 -DF_MALLOC
...

5.1. Debug Flags

The precompiler flags in OpenSER that influences the message logging are presented in the next list.

  • -DNO_DEBUG - turns off some of the debug messages (DBG(...))

  • -DNO_LOG - completely turns off all the logging (and DBG(...))

  • -DEXTRA_DEBUG - enables more debug messages

  • -DDBG_QM_MALLOC - will cause OpenSER to keep and display lot of debugging information about memory operations: file name, function, line number of malloc/free call for each block, extra error checking (trying to free the same pointer twice, trying to free a pointer alloc'ed with a different malloc etc.)

5.2. Memory Debugging

When memory debugging is turned on at compilation, then OpenSER prints a huge amount of debug messages. Some CVS versions of OpenSER (mainly before a release) will have memory debugging turned on by default.

If you want to get rid of all these memory debug messages edit the “Makefile.defs” file and delete -DDBG_QM_MALLOC from the list of compilation flags (from the value of the “DEFS” variable).

OpenSER uses a special memory manager designed to be fast for operations and sizes that OpenSER usually deals with. It is incompatible with memory debugging, so when you turn off the memory debugging you have to add the flag that enables fast memory allocation. This flag is named F_MALOC (-DF_MALLOC in the value of DEFS variable.)

Next example shows what to edit in the “Makefile.defs” to disable memory debugging and enable the fast memory manager.

NOTE: after changing the “Makefile.defs” file you have to recompile and reinstall OpenSER and all the modules you use (you can do it with the following commands: make proper; make all; make install).

Example 4. Disable memory debugging

...
DEFS+= $(extra_defs) \
	 -DNAME='"$(MAIN_NAME)"' -DVERSION='"$(RELEASE)"' -DARCH='"$(ARCH)"' \
	 -DOS='"$(OS)"' -DCOMPILER='"$(CC_VER)"' -D__CPU_$(ARCH) -D__OS_$(OS) \
	 -DCFG_DIR='"$(cfg-target)"'\
	 -DPKG_MALLOC \
	 -DSHM_MEM  -DSHM_MMAP \
	 -DDNS_IP_HACK \
	 -DUSE_IPV6 \
	 -DUSE_MCAST \
	 -DUSE_TCP \
	 -DDISABLE_NAGLE \
	 -DDBG_QM_MALLOC \    <=== delete this line
	 -DDBG_F_MALLOC \     <=== add this line
...