IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 259


Ignore:
Timestamp:
Mar 19, 2004, 9:04:02 AM (23 years ago)
Author:
rhl
Message:

1/ Required that malloc/calloc/realloc/free be disabled by psMemory.h
2/ Improved (?) psTrace examples

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/doc/draft/utils.tex

    r235 r259  
    185185  and \code{free}.
    186186 
     187\item
     188  The file \file{psMemory.h} shall take steps to ensure that
     189  code calling the functions \code{malloc}, \code{calloc}, \code{realloc},
     190  or \code{free} shall not compile (\eg{} \code{#define malloc(S) for})
     191  unless the symbol \code{PS_ALLOC_MALLOC} is defined.
     192
    187193\item
    188194  In all cases, application code will call
    … …  
    425431that must be collected and saved, even in the production system.
    426432
     433We envision that we will make extensive use of \code{psTrace} throughout
     434the \PS{} code.
     435
    427436\subsection{Tracing APIs}
    428437\hlabel{psTrace}
    … …  
    521530For example, after the commands:
    522531\begin{verbatim}
    523     psSetTraceLevel("aaa.bbb.ccc.ddd", 9);
    524     psSetTraceLevel("aaa.bbb.ccc", 3);
    525     psSetTraceLevel("aaa.bbb.ddd", 4);
    526     psSetTraceLevel("aaa.BBB", 2);
    527     psSetTraceLevel("BBB", 2);
    528     psSetTraceLevel("BBB.XXX.YYY.ZZZ", 5);
    529     psSetTraceLevel("aaa.bbb", 2);
    530     psSetTraceLevel("aaa.bbb.ccc", 9);
    531     psSetTraceLevel("aaa", 1);
     532    psSetTraceLevel("utils.dlist.add.head", 9);
     533    psSetTraceLevel("utils.dlist.add", 3);
     534    psSetTraceLevel("utils.dlist.remove", 4);
     535    psSetTraceLevel("coadd", 2);
     536    psSetTraceLevel("coadd.CR.remove.morphology", 5);
     537    psSetTraceLevel("utils.hash", 2);
     538    psSetTraceLevel("utils.dlist.add", 9);
     539    psSetTraceLevel("utils", 1);
    532540\end{verbatim}
    533541the command \code{psPrintTraceLevels()} should print:
    534542\begin{verbatim}
    535543(root)               0
    536  aaa                 1
    537   bbb                2
    538    ccc               9
    539     ddd              9
    540    ddd               4
    541   BBB                2
    542  BBB                 2
    543   XXX                .
    544    YYY               .
    545     ZZZ              5
    546 \end{verbatim}
     544 utils               1
     545  hash               2
     546  dlist              .
     547   remove            4
     548   add               9
     549    head             9
     550 coadd               2
     551  CR                 .
     552   remove            .
     553    morphology       5
     554\end{verbatim}
     555where \code{.} means that the trace level should be inherited from its parent.
    547556
    548557After this set of \code{psSetTraceLevel} commands, and if
    549558\code{PS_NTRACE} is not defined, the following commands
    550559\begin{verbatim}
    551     psTrace("aaa.bbb.ddd", 2, "(aaa.bbb.ddd) Hello %s\n", "world");
    552     psTrace("aaa", 2, "aaa\n");
    553     psTrace("", 2, "\"\"\n");
    554     psTrace("aaa.bbb", 2, "aaa.bbb\n");
    555     psTrace("aaa.bbb.ddd", 2, "aaa.bbb.ddd\n");
    556     psTrace("aaa.bbb.ddd", 4, "aaa.bbb.ddd\n");
    557     psTrace("aaa.bbb.ddd", 2, "aaa.bbb.ddd\n");
    558     psTrace("aaa.bbb.ccc", 1, "aaa.bbb.ccc\n");
    559     psTrace("aaa.bbb.eee", 2, "aaa.bbb.eee\n");
     560    psTrace("utils.dlist.remove", 2, "Removing psDList key \"%s\"\n", "my_key");
     561    psTrace("utils", 2, "Initialising utilities library\n");
     562    psTrace("", 2, "This is turned on by trace component \"\"");
     563    psTrace("utils.dlist", 2, "Initialising psDList\n");
     564    psTrace("utils.dlist.remove", 4, "Removing psDList key \"%s\" (value: \"%d\")\n", "my_key", 12345);
     565    psTrace("utils.hash.remove", 4, "Removing hash key \"%s\" (value: \"%d\")\n", "my_key", 12345);
     566    psTrace("utils.dlist.add", 1, "Adding psDList key \"%s\"\n", "your_key");
     567    psTrace("utils.dlist.find", 2, "Looking up psDList key \"%s\"\n", "some_key");
     568    psTrace("coadd.CR.remove", 4, "Removing CRs\n");
     569    psTrace("coadd.CR.remove.morphology", 4, "CRs are not fuzzy\n");
    560570\end{verbatim}
    561571should produce this output:
    562572\begin{verbatim}
    563   (aaa.bbb.ddd) Hello world
    564   aaa.bbb
    565   aaa.bbb.ddd
    566     aaa.bbb.ddd
    567   aaa.bbb.ddd
    568  aaa.bbb.ccc
    569   aaa.bbb.eee
    570 \end{verbatim}
     573  Removing psDList key "my_key"
     574    Removing psDList key "my_key" (value: "12345")
     575 Adding psDList key "your_key"
     576    CRs are not fuzzy
     577\end{verbatim}
     578
     579Note that
     580\begin{description}
     581\item
     582  \code{utils.dlist} messages are at level 1, inherited from \code{utils}, so the
     583  \code{Initialising utilities library}, \code{Initialising psDList}, and
     584  \code{Looking up psDList key} messages are \emph{not} printed (the traces are at level 2).
     585
     586\item
     587  \code{utils.dlist.remove} messages are at level 4, and are printed.
     588
     589\item
     590  \code{utils.hash} messages are at level 2, and are not printed (the traces are at level 4)
     591
     592\item
     593  \code{coadd.CR.remove} is at level 2 (inherited from \code{coadd}) so \code{Removing CRs}
     594  isn't printed.  \code{coadd.CR.remove.morphology} is at level 4, so \code{CRs are not fuzzy} is printed.
     595\end{description}
    571596
    572597\subsection{Message Logging}
Note: See TracChangeset for help on using the changeset viewer.