6.2. The trace approach

Many times the code returned by the invoked function is not sufficient to understand what's happening: libjf is developed using an "exception oriented programming style" I named "sequential programming" some times ago. The idea at the root of this programming style is: "nidification is a bad thing, try to write code with as small nidification as possible".

To see the "stack trace" of the called function, you must do two things:

Once you performed these two steps, you can run your program again:
tiian@linux:~/tutorial> ./jf_strerror
libjf error: ERROR: object is corrupted (-9)

When running a complex application, mask "0xffffffff" will produce a lot of messages, too many messages. To determine the value you need, take a look to file jf/jf_trace.h: you can activate/deactivate the trace feature at module level and get only the messages you need. This is an excerpt of jf/jf_trace.h:

 * trace module for library module "jf_cache_file"
#define JF_TRACE_MOD_LIB_CACHE_FILE                                  0x00000001

 * trace module for library module "jf_crash_simul"
#define JF_TRACE_MOD_LIB_CRASH_SIMUL                                 0x00000002

 * trace module for library module "jf_file"
#define JF_TRACE_MOD_LIB_FILE                                        0x00000004

 * trace module for library module "jf_journal_file_tab"
#define JF_TRACE_MOD_LIB_JOURNAL_FILE_TAB                            0x00000008

 * trace module for library module "jf_utils"
#define JF_TRACE_MOD_LIB_UTILS                                       0x00000010

 * trace module for library module "jf_journal"
#define JF_TRACE_MOD_LIB_JOURNAL                                     0x00000020
if you need only messages printed by "jf_journal" and "jf_file" modules, you have to set JF_TRACE_MASK to "0x00000024". Any combination of values is allowed.


Don't use a library built with "debug" feature in production environment: performances may degrade even if JF_TRACE_MASK is not set.

6.2.1. How can I guess if libjf was compiled with debug feature?

If you don't remember how libjf was compiled or someone but you installed it, you can retrieve configuration features with this command:

tiian@linux:~> strings /opt/libjf/lib/libjf | grep 'feature/'
feature/timer = yes
feature/debug = yes
feature/crash_simul = no
feature/cache_stress = no
feature/extra_check = no
pay attention the actual name of the library is system dependent: it could be libjf.a, libjf.so, libjf.sl, etc...