TRACE: a useful debugging tool

When debugging fragment generators, as when debugging any piece of software, it's useful to print statements, variable values, etc., to determine what the system is doing. One potential problem with this is that littering code with lots of print statements can affect the code execution time; this of special concern in a system which depends as heavily on execution time as a DAQ. Another problem is that it can be a hassle to recompile the code whenever you want to add or remove a print statement. A package called "TRACE" has been developed at Fermilab which is designed to address these two concerns. TRACE gets set up whenever you source the standard dune-artdaq source file, /path/to/your/dune-artdaq/installation/setupDUNEARTDAQ. You'll notice that in many such source files, there are some Bash statements at the bottom of the source file which configure TRACE:

       export TRACE_FILE=/tmp/trace_example_buffer
       export TRACE_LIMIT_MS="5,1000,2000"

       toffM 15 -n CommandableFragmentGenerator
       tonM 15 -n CommandableFragmentGenerator 

Basically, TRACE is capable of sending print statements to a buffer on a disk defined by the environment variable TRACE_FILE at a much greater speed than print statements can write to stdout, or an ASCII file, etc. It also provides the option of printing statements to stdout, however.There are other environment variables which can further control TRACE's behavior; the TRACE_LIMIT_MS variable, above, is essentially saying "Don't print more than 5 identical messages to stdout in a 1000 millisecond (1 second) time window, and if you hit this limit, pause for 2000 milliseconds (2 seconds) before allowing further prints". Note that TRACE_LIMIT_MS doesn't apply to the statements being saved to the buffer.

The "toffM 15 -n CommandableFragmentGenerator" line tells TRACE that you want it not to print TRACE messages in artdaq's CommandableFragmentGenerator base class that are at level 15, and the following line "tonM 15 -n CommandableFragmentGenerator" tells you want it to. I'll describe what levels are in a moment, but first, the reason for the apparent uselessness of the "toffM" statement is that if you wish to turn off the printing of the message, you must do so by explicitly calling toffM. If you wish to turn off the TRACE statement, with the syntax above all you need to do is comment out the "tonM" statement, but without the "toffM" line it's very easy to forget that you need to call toffM and simply try commenting out tonM, which won't actually make the change you want.

Concerning what "level 15" means: all trace statements have a name and level associated with them. The name in this case is "CommandableFragmentGenerator", and the level in this case is 15. What this means is, in the code above, TRACE statements with name "CommandableFragmentGenerator" and level 15 would get printed. If you look at line 281 of the CommandableFragmentGenerator source code, https://cdcvs.fnal.gov/redmine/projects/artdaq/repository/entry/artdaq/Application/CommandableFragmentGenerator.cc?utf8=✓&rev=v3_00_03a , you'll see

        TLOG_ARB(15, "CommandableFragmentGenerator") << "getDataBufferStats: Calculating buffer size" << TLOG_ENDL;
...this is an example of such a TRACE statement.

Operations

-- JohnChristianFreeman - 2018-03-29

Edit | Attach | Watch | Print version | History: r8 | r4 < r3 < r2 < r1 | Backlinks | Raw View | Raw edit | More topic actions...
Topic revision: r1 - 2018-03-29 - JohnChristianFreeman
 
    • Cern Search Icon Cern Search
    • TWiki Search Icon TWiki Search
    • Google Search Icon Google Search

    CENF All webs login

This site is powered by the TWiki collaboration platform Powered by PerlCopyright & 2008-2022 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
or Ideas, requests, problems regarding TWiki? use Discourse or Send feedback