1    /* 
     2     *  Copyright (c) 2008 Texas Instruments. All rights reserved.
     3     *  This program and the accompanying materials are made available under the
     4     *  terms of the Eclipse Public License v1.0 and Eclipse Distribution License
     5     *  v. 1.0 which accompanies this distribution. The Eclipse Public License is
     6     *  available at http://www.eclipse.org/legal/epl-v10.html and the Eclipse
     7     *  Distribution License is available at
     8     *  http://www.eclipse.org/org/documents/edl-v10.php.
     9     *
    10     *  Contributors:
    11     *      Texas Instruments - initial implementation
    12     * */
    13    /*
    14     *  ======== Log.xdc ========
    15     */
    16    
    17    /*!
    18     *  ======== Log ========
    19     *  Event logging manager
    20     *
    21     *  RTSC modules and the application code generate `{@link #Event Log_Event}`
    22     *  events by calling the `Log` module's functions. The `Log` module then
    23     *  passes those events to an `{@link ILogger}` instance assigned to the event
    24     *  originating module, specified by that module's configuration parameter
    25     *  `common$.logger`. `ILogger` instances handle events, usually converting
    26     *  events to `{@link #EventRec Log_EventRec}` records prior to recording,
    27     *  transmitting, or displaying them.
    28     *
    29     *  All events generated by a target module are stored and displayed by an
    30     *  `ILogger`, examples of which are instances of
    31     *  `{@link LoggerBuf xdc.runtime.LoggerBuf}` or
    32     *  `{@link LoggerSys xdc.runtime.LoggerSys}`. At runtime, modules
    33     *  generate events through this module, rather than invoking directly their
    34     *  `ILogger`s. By doing so,  modules can be configured to use different
    35     *  `ILogger` implementations without any changes to their source code.
    36     *
    37     *  A logger instance can accept `Log` events from any module, but a module
    38     *  can put `Log` events to only one logger instance. There can be one or
    39     *  more logger instances in a system. All `Log` calls that are not in a
    40     *  module are controlled by the module `{@link Main xdc.runtime.Main}`.
    41     *  For example, top-level application code or any existing sources that
    42     *  simply call the `Log` or `Assert` methods implicitly use the logger
    43     *  associated with the `Main` module.
    44     *
    45     *  The generation of a `Log` event is controlled by a module's diagnostics
    46     *  mask, which is described in details in `{@link Diags}`. Each `Log` event
    47     *  is associated with a mask. `Log` events are generated only when a
    48     *  particular bit is set in both the `Log` event mask
    49     *  and the module's diagnostics mask. For example, a `Log` event mask with
    50     *  the `{@link Diags#USER1 USER1}` bit set is generated only when the `USER1`
    51     *  bit is also set in the module's diagnostics mask.
    52     *
    53     *  There are two ways to generate `Log` events:
    54     *
    55     *  @p(blist)
    56     *  - `{@link #write8 Log_write()}`, which is tailored for module writers
    57     *  and takes full advantage of the XDC configuration model. For example,
    58     *  the message string associated with the `Log` event need not be a part of
    59     *  the final application, significantly reducing the "footprint overhead"
    60     *  of embedding diagnostics in deployed systems. The `Log_write[0-8]()`
    61     *  functions allow up to 8 values to be passed to the logger. They expect
    62     *  the logger to handle any formatting. A `Log` event type allows you to
    63     *  specify the type of event.
    64     *  - `{@link #print6 Log_print()}`, which is designed for arbitrary C code.
    65     *  The `Log_print[0-6]()` functions allow up to 6 values to be passed along
    66     *  with a printf-like format string to the logger. They handle printf-style
    67     *  formatting.
    68     *  @p
    69     *
    70     *  Both functions are controlled by the module's diagnostics mask. Their
    71     *  storage or output is defined by the logger that is assigned to the
    72     *  module that calls the `Log` methods or to the
    73     *  `{@link Main xdc.runtime.Main}` module if the caller is not part of a
    74     *  module.
    75     *
    76     *  The `Log` function call sites are implemented in such a way that an
    77     *  optimizer can completely eliminate `Log` code from the program if the
    78     *  `Log` functions have been permanently disabled at configuration time. If
    79     *  the `Log` functions are permanently turned on at configuration time,
    80     *  then the optimizer can eliminate all runtime conditional checking and
    81     *  simply invoke the `Log` functions directly. Runtime checking is performed
    82     *  only when the `Log` functions are configured to be runtime modifiable.
    83     *
    84     *  The Log calls can also be completely removed by defining the symbol
    85     *  `xdc_runtime_Log_DISABLE_ALL`. This can be done on the compile line, e.g.
    86     *  `-Dxdc_runtime_Log_DISABLE_ALL`. This will completely remove the `Log`
    87     *  statements from any code compiled with this flag, regardless of the
    88     *  application's logging configuration or your compiler's optimization
    89     *  settings.
    90     *
    91     *  It is also possible to remove all logging except for
    92     *  `{@link #error Log_error}`, `{@link #warning Log_warning}`, or
    93     *  `{@link #info Log_info}` statements. This is done by first defining
    94     *  `xdc_runtime_Log_DISABLE_ALL`, followed by defining one or more of the
    95     *  symbols below to leave that type of logging enabled:
    96     *  @p(blist)
    97     *  - `xdc_runtime_Log_ENABLE_ERROR`
    98     *  - `xdc_runtime_Log_ENABLE_WARNING`
    99     *  - `xdc_runtime_Log_ENABLE_INFO`
   100     *  @p
   101     *  For example, to disable all `Log` statements except for `Log_error`, add
   102     *  the following to the compile line:
   103     *  @p(code)
   104     *      -Dxdc_runtime_Log_DISABLE_ALL -Dxdc_runtime_Log_ENABLE_ERROR
   105     *  @p
   106     *
   107     *  @a(Examples)
   108     *  Example 1: The following example defines a `Log` event, uses that `Log`
   109     *  event in a module, and configures the program to generate the `Log`
   110     *  event. In this example, both `USER1` and `USER2` bits are set in the
   111     *  event mask. This means that if either bit is set in the module's
   112     *  diagnostics mask, then the `Log` event will be generated.
   113     *
   114     *  This is a part of the XDC specification file for the `Mod` module
   115     *  (Mod.xdc):
   116     *
   117     *  @p(code)
   118     *  import xdc.runtime.Diags;
   119     *  import xdc.runtime.Log;
   120     *
   121     *  config Log.Event L_someEvent = {
   122     *      mask: Diags.USER1 | Diags.USER2,
   123     *      level: Diags.LEVEL1,
   124     *      msg: "my log event message, arg1: 0x%x, arg2: 0x%x"
   125     *  };
   126     *  @p
   127     *
   128     *  This is a part of the C code implementation of the Mod module:
   129     *
   130     *  @p(code)
   131     *  #include <xdc/runtime/Log.h>
   132     *  UInt x, y;
   133     *
   134     *  Log_write2(Mod_L_someEvent, (IArg)x, (IArg)y);
   135     *  @p
   136     *
   137     *  The following configuration script demonstrates how the application might
   138     *  control the `Log` statements embedded in the `Mod` module at configuration
   139     *  time. In this case, the configuration script arranges for the `Log`
   140     *  statements within the `Mod` module (shown above) to always generate events.
   141     *  Without these configuration statements, no `Log` events would be generated
   142     *  by this module.
   143     *
   144     *  This is part of the XDC configuration file for the application:
   145     *
   146     *  @p(code)
   147     *  var Diags = xdc.useModule('xdc.runtime.Diags');
   148     *  var LoggerSys = xdc.useModule('xdc.runtime.LoggerSys');
   149     *  var Mod = xdc.useModule('my.pkg.Mod');
   150     *  Mod.common$.diags_USER1 = Diags.ALWAYS_ON;
   151     *  Mod.common$.logger = LoggerSys.create();
   152     *  @p
   153     *
   154     *  @p(html)
   155     *  <hr />
   156     *  @p
   157     *
   158     *  Example 2: The following XDC configuration statements turn on enter
   159     *  and exit logging at configuration time for a module. Without any other
   160     *  changes in the runtime code, every time a module `Mod`'s function is
   161     *  being called or exits, an event will be logged.
   162     *
   163     *  @p(code)
   164     *  var Diags = xdc.useModule('xdc.runtime.Diags');
   165     *  var Mod = xdc.useModule('my.pkg.Mod');
   166     *
   167     *  Mod.common$.diags_ENTER = Diags.ALWAYS_ON;
   168     *  Mod.common$.diags_EXIT = Diags.ALWAYS_ON;
   169     *  @p
   170     *
   171     *  @p(html)
   172     *  <hr />
   173     *  @p
   174     *
   175     *  Example 3: The following example configures a module to support enter and
   176     *  exit logging, but defers the actual activation and deactivation of the
   177     *  logging until runtime. See the `{@link Diags#setMask Diags_setMask()}`
   178     *  function for details on specifying the control string.
   179     *
   180     *  This is a part of the XDC configuration file for the application:
   181     *
   182     *  @p(code)
   183     *  var Diags = xdc.useModule('xdc.runtime.Diags');
   184     *  var Mod = xdc.useModule('my.pkg.Mod');
   185     *
   186     *  Mod.common$.diags_ENTER = Diags.RUNTIME_OFF;
   187     *  Mod.common$.diags_EXIT = Diags.RUNTIME_OFF;
   188     *  @p
   189     *
   190     *  This is a part of the C code for the application:
   191     *
   192     *  @p(code)
   193     *  // turn on enter and exit logging in the module
   194     *  Diags_setMask("my.pkg.Mod+EX");
   195     *
   196     *  // turn off enter and exit logging in the module
   197     *  Diags_setMask("my.pkg.Mod-EX");
   198     *  @p
   199     */
   200    
   201    @CustomHeader
   202    
   203    module Log {
   204    
   205        /*!
   206         *  ======== NUMARGS ========
   207         *  Maximum number of arguments supported in `Log` events.
   208         */
   209        const Int NUMARGS = 8;
   210    
   211        /*!
   212         *  ======== PRINTFID ========
   213         *  The `EventId` for `Log_print()` events
   214         */
   215        const EventId PRINTFID = 0;
   216    
   217        /*!
   218         *  ======== EventDesc ========
   219         *  `Log` event descriptor
   220         *
   221         *  Each `Log` event is defined by a `Log` event descriptor.
   222         *
   223         *  The `mask` defines which bits in the module's diagnostics mask
   224         *  enable this `Log` event.  Events "posted" via `Log_write` are only
   225         *  written to the underlying logger if one of the mask's bits matches
   226         *  the caller's module diagnostics settings (see
   227         *  `{@link xdc.runtime.Types#common$}`).
   228         *
   229         *  The 'level' defines the event level of the event. While the diags
   230         *  bits selected in the 'mask' signify the "category" of the event (e.g.
   231         *  Entry/Exit, Analysis, Info), the 'level' field allows you to assign
   232         *  a "priority" or "detail level" to the event relative to other events in
   233         *  that category. There are four event levels defined by
   234         *  '{@link xdc.runtime.Diags#EventLevel}'.
   235         *
   236         *  Filtering of events by level is handled by the ILogger implementation.
   237         *  ILogger implementations which also implement the {@link IFilterLogger}
   238         *  interface support filtering of events based on priority level.
   239         *
   240         *  Specifying an event level is optional. Events that don't specify a
   241         *  level will receive Diags.LEVEL1 by default, making them the highest
   242         *  priority and ensuring that they will not inadvertently be filtered out
   243         *  by level-based filtering.
   244         *
   245         *  The `msg` defines a printf style format string that defines how to
   246         *  render the arguments passed along the event in a `Log_write` call.
   247         *  For a description of the allowable format strings see
   248         *  `{@link #print6}`.
   249         *
   250         *  @see #write8
   251         *  @see #print6
   252         */
   253        metaonly struct EventDesc {
   254            Diags.Mask          mask;   /*! event enable mask */
   255            Diags.EventLevel    level;  /*! event level relative to other events */
   256            String              msg;    /*! event "printf" message format string */
   257        };
   258    
   259        /*!
   260         *  ======== EventRec ========
   261         *  The target representation of a recorded event
   262         *
   263         *  This structure defines how events are recorded on the target.
   264         */
   265        struct EventRec {
   266            Types.Timestamp64 tstamp;   /*! time event was written */
   267            Bits32 serial;              /*! serial number of event */
   268            Types.Event evt;            /*! target encoding of an Event */
   269            IArg arg[NUMARGS];          /*! arguments passed via Log_write/print */
   270        }
   271    
   272        /*!
   273         *  ======== Event ========
   274         *  `Log` event type
   275         *
   276         *  An `Event` is represented on the target as a 32-bit value that can
   277         *  be decoded offline to recover the `Event` information defined in
   278         *  a corresponding metaonly `EventDesc`.  In addition, `Event`s may be
   279         *  decoded at runtime via methods provided in this module; see
   280         *  `{@link #getMask}` and `{@link #getEventId}`.
   281         *
   282         *  When an event is "raised" a `{@link Types#Event Types_Event}` is
   283         *  created which has the same event ID as the `Log_Event` but also
   284         *  encodes the module ID of the caller.  This new event is passed to
   285         *  the underlying `{@link ILogger}` module along with any arguments
   286         *  associated with the event.
   287         *
   288         *  @see #getMask
   289         *  @see #getEventId
   290         */
   291        @Encoded typedef EventDesc Event;
   292    
   293        /*!
   294         *  ======== EventId ========
   295         *  Unique ID embedded in each `{@link #Event}`
   296         *
   297         *  This ID must be used to compare two `Event`s for equality.  Event
   298         *  ids are not guaranteed to remain constant between different
   299         *  configurations of an application.  For example, adding a module
   300         *  may cause the event ids of another module to change.
   301         *
   302         *  However, event ids declared by a module are guaranteed to be
   303         *  consecutive values starting from the first declared
   304         *  `{@link #Event Log_Event}` and increasing to the last declared
   305         *  event.  As a result, clients of a module can efficiently test ranges
   306         *  of events and modules can add new events, such as internal trace
   307         *  events, without breaking clients; simply be careful to add new events
   308         *  after any existing events in you module's `.xdc` specification.
   309         *
   310         *  @see #getEventId
   311         *  @see #Event
   312         */
   313        typedef Types.RopeId EventId;
   314    
   315        /*!
   316         *  ======== L_construct ========
   317         *  Lifecycle event posted when an instance is constructed
   318         */
   319        config Log.Event L_construct = {
   320            mask: Diags.LIFECYCLE,
   321            msg: "<-- construct: %p('%s')"
   322        };
   323    
   324        /*!
   325         *  ======== L_create ========
   326         *  Lifecycle event posted when an instance is created
   327         */
   328        config Log.Event L_create = {
   329            mask: Diags.LIFECYCLE,
   330            msg: "<-- create: %p('%s')"
   331        };
   332    
   333        /*!
   334         *  ======== L_destruct ========
   335         *  Lifecycle event posted when an instance is destructed
   336         */
   337        config Log.Event L_destruct = {
   338            mask: Diags.LIFECYCLE,
   339            msg: "--> destruct: (%p)"
   340        };
   341    
   342        /*!
   343         *  ======== L_delete ========
   344         *  Lifecycle event posted when an instance is deleted
   345         */
   346        config Log.Event L_delete = {
   347            mask: Diags.LIFECYCLE,
   348            msg: "--> delete: (%p)"
   349        };
   350    
   351        /*!
   352         *  ======== L_error ========
   353         *  Error event posted by Log_errorX API
   354         *
   355         *  This event is marked as a STATUS event and given the priority level
   356         *  of ERROR.
   357         *
   358         *  This event prints the Log call site (%$F) and a format string (%$S)
   359         *  which is recursively formatted with any additional arguments.
   360         */
   361        config Log.Event L_error = {
   362            mask: Diags.STATUS,
   363            level: Diags.ERROR,
   364            msg: "ERROR: %$F%$S"
   365        };
   366    
   367        /*!
   368         *  ======== L_warning ========
   369         *  Warning event posted by Log_warningX API
   370         *
   371         *  This event is marked as a STATUS event and given the priority level of
   372         *  WARNING.
   373         *
   374         *  This event prints the Log call site (%$F) and a format string (%$S)
   375         *  which is recursively formatted with any addition arguments.
   376         */
   377        config xdc.runtime.Log.Event L_warning = {
   378            mask: Diags.STATUS,
   379            level: Diags.WARNING,
   380            msg: "WARNING: %$F%$S"
   381        };
   382    
   383        /*!
   384         *  ======== L_info ========
   385         *  Info event posted by Log_infoX API
   386         *
   387         *  This event is marked as an INFO event. The event priority is not
   388         *  specified in the event definition. Rather, it is specified as an
   389         *  argument to the Log_infoX APIs.
   390         *
   391         *  This event prints the Log call site (%$F) and a format string (%$S)
   392         *  which is recursively formatted with any addition arguments.
   393         */
   394        config xdc.runtime.Log.Event L_info = {
   395            mask: Diags.INFO,
   396            msg: "%$F%$S"
   397        };
   398    
   399        /*!
   400         *  ======== L_start ========
   401         *  Benchmark event used to log the start of an operation
   402         *  @_nodoc
   403         *
   404         * @a(Example)
   405         *   The following C code shows how to log a simple
   406         *   benchmark 'start' event along with a user-specified
   407         *   format string describing the event.
   408         *
   409         *  @p(code)
   410         *  #include <xdc/runtime/Log.h>
   411         *  ...
   412         *  Log_write2(Log_L_start, (IArg)"My benchmark event", (IArg)myUniqueId);
   413         *  Log_write2(Log_L_stop, (IArg)"My benchmark event", (IArg)myUniqueId);
   414         *  @p
   415         *  @param(fmt)     a constant string that provides format specifiers for up to 6 additional parameters
   416         *  @param(id)      a unique ID used to match benchmark start and stop events
   417         */
   418        config xdc.runtime.Log.Event L_start = {
   419            mask: Diags.ANALYSIS,
   420            msg: "Start: %$S"};
   421    
   422        /*!
   423         *  ======== L_stop ========
   424         *  Benchmark event used to log the end of an operation
   425         *  @_nodoc
   426         *
   427         *  @a(Example)
   428         *   The following C code shows how to log a simple
   429         *   benchmark 'stop' event along with a user-specified
   430         *   format string describing the event.
   431         *
   432         *  @p(code)
   433         *  #include <xdc/runtime/Log.h>
   434         *  ...
   435         *  Log_write2(Log_L_start, (IArg)"My benchmark event", (IArg)myUniqueId);
   436         *  Log_write2(Log_L_stop, (IArg)"My benchmark event", (IArg)myUniqueId);
   437         *  @p
   438         *  @param(fmt)     a constant string that provides format specifiers for up to 6 additional parameters
   439         *  @param(id)      a unique ID used to match benchmark start and stop events
   440         */
   441        config xdc.runtime.Log.Event L_stop = {
   442            mask: Diags.ANALYSIS,
   443            msg: "Stop: %$S"};
   444    
   445        /*!
   446         *  ======== L_startInstance ========
   447         *  Benchmark event used to log the start of an operation instance
   448         *  @_nodoc
   449         *
   450         *  Event parameter provides instance data to differentiate
   451         *  between multiple instances that can run in parallel.
   452         *
   453         *  @a(Example)
   454         *   The following C code shows how to log a benchmark
   455         *   'startInstance' event along with a user-specified
   456         *   instance identifier and a format string describing the event.
   457         *
   458         *  @p(code)
   459         *  #include <xdc/runtime/Log.h>
   460         *  ...
   461         *  Log_write3(Log_L_startInstance, (IArg)"My benchmark event", (IArg)uniqueId, (IArg)instId);
   462         *  ...
   463         *  Log_write3(Log_L_stopInstance, (IArg)"My benchmark event", (IArg)uniqueId, (IArg)instId);
   464         *  @p
   465         *  @param(fmt)     a constant string that provides format specifiers for up to 6 additional parameters
   466         *  @param(id)      a unique ID used to match benchmark start and stop events
   467         *  @param(instId)  a unique instance ID that can be used to match and instance
   468         */
   469        config xdc.runtime.Log.Event L_startInstance = {
   470            mask: Diags.ANALYSIS,
   471            msg: "StartInstance: %$S"
   472        };
   473    
   474        /*!
   475         *  ======== L_stopInstance ========
   476         *  Benchmark event used to log the end of an operation instance
   477         *  @_nodoc
   478         *
   479         *  Event parameter provides instance data to differentiate
   480         *  between multiple instances that can run in parallel.
   481         *
   482         * @a(Example)
   483         *   The following C code shows how to log a benchmark
   484         *   'stopInstance' event along with a user-specified
   485         *   instance identifier and a format string describing the event.
   486         *
   487         *  @p(code)
   488         *  #include <xdc/runtime/Log.h>
   489         *  ...
   490         *  Log_write3(Log_L_startInstance, (IArg)"My benchmark event", (IArg)uniqueId, (IArg)instId);
   491         *  ...
   492         *  Log_write3(Log_L_stopInstance, (IArg)"My benchmark event", (IArg)uniqueId, (IArg)instId);
   493         *  @p
   494         *  @param(fmt)     a constant string that provides format specifiers for up to 6 additional parameters
   495         *  @param(id)      a unique ID used to match benchmark start and stop events
   496         *  @param(instId)  a unique instance ID that can be used to match and instance
   497         */
   498        config xdc.runtime.Log.Event L_stopInstance = {
   499            mask: Diags.ANALYSIS,
   500            msg: "StopInstance: %$S"
   501        };
   502    
   503        /*!
   504         *  ======== getMask ========
   505         *  Get the `Diags` mask for the specified (encoded) event
   506         *
   507         *  @param(evt) the `Log` event encoding a mask and event ID
   508         *
   509         *  @a(returns) `Diags` mask for the specified event
   510         */
   511        @Macro Diags.Mask getMask(Event evt);
   512    
   513        /*!
   514         *  ======== getRope ========
   515         *  Get RopeId of the Event.msg for the specified (encoded) event
   516         *  @_nodoc
   517         */
   518        @Macro Text.RopeId getRope(Event evt);
   519    
   520        /*!
   521         *  ======== getEventId ========
   522         *  Get event ID of the specified (encoded) event
   523         *
   524         *  This method is used to compare "known" `Log` events with
   525         *  "raised" `{@link Types#Event Types_Event}`.
   526         *
   527         *  @param(evt) the `Log` event encoding a mask and event ID
   528         *
   529         *  @a(returns) event ID of the specified event
   530         *
   531         *  @see Types#getEventId
   532         */
   533        @Macro EventId getEventId(Event evt);
   534    
   535        /*!
   536         *  ======== print0 ========
   537         *  Generate a `Log` "print event" with 0 arguments
   538         *
   539         *  @see #print6
   540         */
   541        @Macro Void print0(Diags.Mask mask, String fmt);
   542    
   543        /*!
   544         *  ======== print1 ========
   545         *  Generate a `Log` "print event" with 1 argument
   546         *
   547         *  @see #print6
   548         */
   549        @Macro Void print1(Diags.Mask mask, String fmt, IArg a1);
   550    
   551        /*!
   552         *  ======== print2 ========
   553         *  Generate a `Log` "print event" with 2 arguments
   554         *
   555         *  @see #print6
   556         */
   557        @Macro Void print2(Diags.Mask mask, String fmt, IArg a1, IArg a2);
   558    
   559        /*!
   560         *  ======== print3 ========
   561         *  Generate a `Log` "print event" with 3 arguments
   562         *
   563         *  @see #print6
   564         */
   565        @Macro Void print3(Diags.Mask mask, String fmt, IArg a1, IArg a2, IArg a3);
   566    
   567        /*!
   568         *  ======== print4 ========
   569         *  Generate a `Log` "print event" with 4 arguments
   570         *
   571         *  @see #print6
   572         */
   573        @Macro Void print4(Diags.Mask mask, String fmt, IArg a1, IArg a2, IArg a3,
   574            IArg a4);
   575    
   576        /*!
   577         *  ======== print5 ========
   578         *  Generate a `Log` "print event" with 5 arguments
   579         *
   580         *  @see #print6
   581         */
   582        @Macro Void print5(Diags.Mask mask, String fmt, IArg a1, IArg a2, IArg a3,
   583            IArg a4, IArg a5);
   584    
   585        /*!
   586         *  ======== print6 ========
   587         *  Generate a `Log` "print event" with 6 arguments
   588         *
   589         *  As a convenience to C (as well as assembly language) programmers,
   590         *  the `Log` module provides a variation of the ever-popular `printf`
   591         *  function.
   592         *  The `print[0-6]` functions generate a `Log` "print event" and route
   593         *  it to the current module's logger.
   594         *
   595         *  The arguments passed to `print[0-6]` may be characters, integers,
   596         *  strings, or pointers.  However, because the declared type of the
   597         *  arguments is `{@link xdc IArg}`, all pointer arguments must be cast
   598         *  to an `IArg` type.  `IArg` is an integral type large enough to hold
   599         *  any pointer or an `int`.  So, casting a pointer to an `IArg` does
   600         *  not cause any loss of information and C's normal integer conversions
   601         *  make the cast unnecessary for integral arguments.
   602         *
   603         *  The format string can use the following conversion characters.
   604         *  However, it is important to recall that all arguments referenced by
   605         *  these conversion characters have been converted to an `IArg`
   606         *  prior to conversion; so, the use of "length modifiers" should be
   607         *  avoided.
   608         *
   609         *  @p(code)
   610         *  Conversion Character    Description
   611         *  ------------------------------------------------
   612         *  %c                      Character
   613         *  %d                      Signed integer
   614         *  %u                      Unsigned integer
   615         *  %x                      Unsigned hexadecimal integer
   616         *  %o                      Unsigned octal integer
   617         *  %s                      Character string
   618         *  %p                      Pointer
   619         *  %f                      Single precision floating point (float)
   620         *  @p
   621         *
   622         *  Format strings, while very convenient, are a well known source of
   623         *  portability problems: each format specification must precisely match
   624         *  the types of the arguments passed. Underlying "printf" functions use
   625         *  the format string to determine how far to advance through their
   626         *  argument list. For targets where pointer types and integers are the
   627         *  same size there are no problems.  However, suppose a target's pointer
   628         *  type is larger than its integer type. In this case, because integer
   629         *  arguments are widened to be of type `IArg`, a format specification of
   630         *  "%d" causes an underlying `printf()` implementation to read the
   631         *  extended part of the integer argument as part of the next argument(!).
   632         *
   633         *  To get around this problem and still allow the use of "natural"
   634         *  format specifications (e.g., `%d` and `%x` with optional width
   635         *  specifications), `{@link System#aprintf()}` is used which assumes
   636         *  that all arguments have been widened to be of type `IArg`.
   637         *
   638         *  See `{@link System#printf}` for complete details.
   639         *
   640         *  The `%f` format specifier is used to print a single precision float
   641         *  value. Note that `%f` assumes that sizeof(Float) <= sizeof(IArg).
   642         *  Most clients that interpret float values expect that they are
   643         *  represented in IEEE 754 floating point format. Therefore, it is
   644         *  recommended that the float values be converted into that format prior
   645         *  to supplying the values to `Log` functions in cases where targets do
   646         *  not generate the float values in IEEE 754 floating point format by
   647         *  default.
   648         *
   649         *  The first argument to a `Log_print` call is the diags category to be
   650         *  associated with the event.
   651         *
   652         *  It is also possible to associate an event level with the event to
   653         *  enable filtering of events based on event level. Conceptually, it is
   654         *  best to regard the event level as completely separate from the event's
   655         *  diags category; however, the priority value actually occupies a part
   656         *  of the diags mask. For this reason, it is possible to specify an event
   657         *  level by OR'ing the level with the diags mask. For example, to print
   658         *  an `Diags_INFO` event of `Diags_LEVEL2`, you'd simply write:
   659         *  (Diags_INFO | Diags_LEVEL2)
   660         *
   661         *  Specifying an event level is optional. `Log_print` calls which do not
   662         *  specify a level will receive the highest priority by default.
   663         *
   664         *  @param(mask)    enable bits and optional detail level for this event
   665         *  @param(fmt)     a `printf` style format string
   666         *  @param(a1)      value for first format conversion character
   667         *  @param(a2)      value for second format conversion character
   668         *  @param(a3)      value for third format conversion character
   669         *  @param(a4)      value for fourth format conversion character
   670         *  @param(a5)      value for fifth format conversion character
   671         *  @param(a6)      value for sixth format conversion character
   672         *
   673         *  @a(Examples)
   674         *  The following example demonstrates a typical usage.
   675         *  @p(code)
   676         *  String  list[];
   677         *  UInt    i;
   678         *
   679         *  Log_print2(Diags_USER2, "list[%u] = %s\n", i, (IArg)list[i]);
   680         *  @p
   681         *  Note that the `IArg` cast above is only necessary for pointer
   682         *  arguments; C's normal parameter conversions implicitly convert
   683         *  integral arguments.
   684         *
   685         *  To simplify the conversion from `float` arguments to `IArg`,
   686         *  the standard header `xdc/std.h` provides a macro, named floatToArg(),
   687         *  to do this conversion in a type safe manner.  So, the following
   688         *  statement will print "`float = 2.3456`":
   689         *  @p(code)
   690         *    Log_print1(Diags_USER1, "float = %f", floatToArg(2.34567));
   691         *  @p
   692         *
   693         *  Note that, if you are formatting events on the target, you must
   694         *  also add support for floating point to ASCII conversion to
   695         *  `{@link System#printf}`; for more information, see the
   696         *  `{@link System#extendedFormats}` reference documenation.  For example:
   697         *  @p(code)
   698         *      var System = xdc.useModule('xdc.runtime.System');
   699         *      System.extendedFormats = "%f";
   700         *  @p
   701         */
   702        @Macro Void print6(Diags.Mask mask, String fmt, IArg a1, IArg a2, IArg a3,
   703            IArg a4, IArg a5, IArg a6);
   704    
   705        /*!
   706         *  ======== error0 ========
   707         *  Generate a `Log` "error event" with 0 arguments
   708         *
   709         *  @see #error5
   710         */
   711        @Macro Void error0(String fmt);
   712    
   713        /*!
   714         *  ======== error1 ========
   715         *  Generate a `Log` "error event" with 1 argument
   716         *
   717         *  @see #error5
   718         */
   719        @Macro Void error1(String fmt, IArg a1);
   720    
   721        /*!
   722         *  ======== error2 ========
   723         *  Generate a `Log` "error event" with 2 arguments
   724         *
   725         *  @see #error5
   726         */
   727        @Macro Void error2(String fmt, IArg a1, IArg a2);
   728    
   729        /*!
   730         *  ======== error3 ========
   731         *  Generate a `Log` "error event" with 3 arguments
   732         *
   733         *  @see #error5
   734         */
   735        @Macro Void error3(String fmt, IArg a1, IArg a2, IArg a3);
   736    
   737        /*!
   738         *  ======== error4 ========
   739         *  Generate a `Log` "error event" with 4 arguments
   740         *
   741         *  @see #error5
   742         */
   743        @Macro Void error4(String fmt, IArg a1, IArg a2, IArg a3,
   744            IArg a4);
   745    
   746        /*!
   747         *  ======== error5 ========
   748         *  Generate a `Log` "error event" with 5 arguments
   749         *
   750         *  The Log_error APIs are intended to allow users to easily log error
   751         *  events in their code. Similar to the Log_print APIs, Log_error does not
   752         *  require that you define an event. You simply pass an informative error
   753         *  string which can optionally be formatted with additional arguments. The
   754         *  error is logged with the predefined event {@link #L_error}.
   755         *
   756         *  Log_error prepends a string to the message which identifies it as an
   757         *  ERROR and specifies the filename and line number of the Log_error call
   758         *  site. A simple example:
   759         *
   760         *  @p(code)
   761         *  Log_error0("Invalid argument");
   762         *  @p
   763         *  This event will be formatted as (assuming that the above call was line
   764         *  35 of "MyCode.c")
   765         *  @p(code)
   766         *  ERROR at "MyCode.c", line 35: Invalid argument
   767         *  @p
   768         *
   769         *  Users may provide additional information in the error event, such as
   770         *  a predefined error code or details of the error. These additional
   771         *  values will be used to format the string passed to Log_error.
   772         *  @see #print6 for information about format strings.
   773         *
   774         *  Log_error does not use a variable length argument list--you must call
   775         *  the appropriate Log_errorX API based on the number of arguments.
   776         *
   777         *  @param(fmt)      a reference to a constant error string / fmt string
   778         *  @param(a1)       value for an additional parameter (e.g. an error code)
   779         *  @param(a2)       value for an additional parameter
   780         *  @param(a3)       value for an additional parameter
   781         *  @param(a4)       value for an additional parameter
   782         *  @param(a5)       value for an additional parameter
   783         *
   784         *  @a(Examples)
   785         *  The following example demonstrates a typical usage.
   786         *  @p(code)
   787         *  Int myArg;
   788         *
   789         *  Log_error1("Invalid argument: %d", myArg);
   790         *  @p
   791         *  The above event is formatted as, for example:
   792         *  @p(code)
   793         *  ERROR: "MyCode.c", line 35: Invalid argument: -1
   794         *  @p
   795         */
   796        @Macro Void error5(String fmt, IArg a1, IArg a2, IArg a3,
   797            IArg a4, IArg a5);
   798    
   799        /*!
   800         *  ======== warning0 ========
   801         *  Generate a `Log` "warning event" with 0 arguments
   802         *
   803         *  @see #warning5
   804         */
   805        @Macro Void warning0(String fmt);
   806    
   807        /*!
   808         *  ======== warning1 ========
   809         *  Generate a `Log` "warning event" with 1 argument
   810         *
   811         *  @see #warning5
   812         */
   813        @Macro Void warning1(String fmt, IArg a1);
   814    
   815        /*!
   816         *  ======== warning2 ========
   817         *  Generate a `Log` "warning event" with 2 arguments
   818         *
   819         *  @see #warning5
   820         */
   821        @Macro Void warning2(String fmt, IArg a1, IArg a2);
   822    
   823        /*!
   824         *  ======== warning3 ========
   825         *  Generate a `Log` "warning event" with 3 arguments
   826         *
   827         *  @see #warning5
   828         */
   829        @Macro Void warning3(String fmt, IArg a1, IArg a2, IArg a3);
   830    
   831        /*!
   832         *  ======== warning4 ========
   833         *  Generate a `Log` "warning event" with 4 arguments
   834         *
   835         *  @see #warning5
   836         */
   837        @Macro Void warning4(String fmt, IArg a1, IArg a2, IArg a3,
   838            IArg a4);
   839    
   840        /*!
   841         *  ======== warning5 ========
   842         *  Generate a `Log` "warning event" with 5 arguments
   843         *
   844         *  The Log_warning APIs provide the same features as the Log_error APIs,
   845         *  but are used to specifically log "warning" events.
   846         *  @see #error5
   847         *
   848         *  The Log_warning APIs are equivalent to the Log_error APIs except that
   849         *  they use the predefined {@link #L_warning} event. Log_warning prepends
   850         *  a string to the message which identifies it as a WARNING and specifies
   851         *  the filename and line number of the Log_warning call site.
   852         *
   853         *  @param(fmt)     reference to a constant warning string / fmt string
   854         *  @param(a1)      value for an additional parameter (e.g. a warning code)
   855         *  @param(a2)      value for an additional parameter
   856         *  @param(a3)      value for an additional parameter
   857         *  @param(a4)      value for an additional parameter
   858         *  @param(a5)      value for an additional parameter
   859         *
   860         *  @a(Examples)
   861         *  The following example demonstrates a typical usage.
   862         *  @p(code)
   863         *  Int myArg;
   864         *
   865         *  Log_warning1("Value may be too high: %d", myArg);
   866         *  @p
   867         *  The above event is formatted as:
   868         *  @p(code)
   869         *  WARNING: "MyCode.c", line 50: Value may be too high: 4096
   870         *  @p
   871         */
   872        @Macro Void warning5(String fmt, IArg a1, IArg a2, IArg a3,
   873            IArg a4, IArg a5);
   874    
   875        /*!
   876         *  ======== info0 ========
   877         *  Generate a `Log` "info event" with 0 arguments
   878         *
   879         *  @see #info5
   880         */
   881        @Macro Void info0(String fmt);
   882    
   883        /*!
   884         *  ======== info1 ========
   885         *  Generate a `Log` "info event" with 1 argument
   886         *
   887         *  @see #info5
   888         */
   889        @Macro Void info1(String fmt, IArg a1);
   890    
   891        /*!
   892         *  ======== info2 ========
   893         *  Generate a `Log` "info event" with 2 arguments
   894         *
   895         *  @see #info5
   896         */
   897        @Macro Void info2(String fmt, IArg a1, IArg a2);
   898    
   899        /*!
   900         *  ======== info3 ========
   901         *  Generate a `Log` "info event" with 3 arguments
   902         *
   903         *  @see #info5
   904         */
   905        @Macro Void info3(String fmt, IArg a1, IArg a2, IArg a3);
   906    
   907        /*!
   908         *  ======== info4 ========
   909         *  Generate a `Log` "info event" with 4 arguments
   910         *
   911         *  @see #info5
   912         */
   913        @Macro Void info4(String fmt, IArg a1, IArg a2, IArg a3, IArg a4);
   914    
   915        /*!
   916         *  ======== info5 ========
   917         *  Generate a `Log` "info event" with 5 arguments
   918         *
   919         *  The Log_info APIs are provided for easily logging generic
   920         *  "informational" events with call site information. They are similar to
   921         *  the Log_print APIs in that they do not require you to define an event--
   922         *  you simply pass an informative printf-style string which can optionally
   923         *  be formatted with additional arguments. The info record is logged with
   924         *  the predefined event '{@link #L_info}'.
   925         *
   926         *  The Log_info APIs log the {@link #L_info} event which uses the 'INFO'
   927         *  diags category. They do not allow you to specify an event priority.
   928         *
   929         *  Log_info prepends the filename and line number of the call site to the
   930         *  message.
   931         *
   932         *  @param(fmt)     reference to a constant event string / fmt string
   933         *  @param(a1)      value for an additional parameter (e.g. an event code)
   934         *  @param(a2)      value for an additional parameter
   935         *  @param(a3)      value for an additional parameter
   936         *  @param(a4)      value for an additional parameter
   937         *  @param(a5)      value for an additional parameter
   938         *
   939         *  @a(Examples)
   940         *  The following example demonstrates a typical usage.
   941         *  @p(code)
   942         *  Int load;
   943         *
   944         *  Log_info1("Current load: %d", load);
   945         *  @p
   946         *  The above event is formatted as, for example:
   947         *  @p(code)
   948         *  "MyCode.c", line 15: Current load: 25
   949         *  @p
   950         */
   951        @Macro Void info5(String fmt, IArg a1, IArg a2, IArg a3, IArg a4, IArg a5);
   952    
   953         /*!
   954         *  ======== put0 ========
   955         *  Unconditionally put the specified Log event with 0 arguments
   956         *
   957         *  @see #put4
   958         */
   959        @Macro Void put0(Log.Event evt, Types.ModuleId mid);
   960    
   961        /*!
   962         *  ======== put1 ========
   963         *  Unconditionally put the specified Log event and 1 argument
   964         *
   965         *  @see #put4
   966         */
   967        @Macro Void put1(Log.Event evt, Types.ModuleId mid, IArg a1);
   968    
   969        /*!
   970         *  ======== put2 ========
   971         *  Unconditionally put the specified Log event and 2 arguments
   972         *
   973         *  @see #put4
   974         */
   975         @Macro Void put2(Log.Event evt, Types.ModuleId mid, IArg a1, IArg a2);
   976    
   977        /*!
   978         *  ======== put4 ========
   979         *  Unconditionally put the specified Log event
   980         *
   981         *  This method unconditionally puts the specified `{@link Event}`
   982         *  `evt` into the log. The `{@link Types#ModuleId}` `mid` should be the
   983         *  module ID of the module which is putting the event.
   984         *
   985         *  @param(evt)     the Log event to put into the log
   986         *  @param(mid)     module ID of the module putting the event
   987         *  @param(a1)      value for first format conversion character
   988         *  @param(a2)      value for second format conversion character
   989         *  @param(a3)      value for third format conversion character
   990         *  @param(a4)      value for fourth format conversion character
   991         *
   992         *  @see #put8
   993         */
   994        @Macro Void put4(Log.Event evt, Types.ModuleId mid, IArg a1, IArg a2,
   995                         IArg a3, IArg a4);
   996    
   997        /*!
   998         *  ======== put8 ========
   999         *  Unconditionally put the specified Log event and 8 arguments
  1000         *
  1001         *  @see #put4
  1002         */
  1003        @Macro Void put8(Log.Event evt, Types.ModuleId mid, IArg a1, IArg a2,
  1004                         IArg a3, IArg a4, IArg a5, IArg a6, IArg a7, IArg a8);
  1005    
  1006        /*!
  1007         *  ======== write0 ========
  1008         *  Generate a `Log` event with 0 arguments
  1009         *
  1010         *  @see #write8
  1011         */
  1012        @Macro Void write0(Event evt);
  1013    
  1014        /*!
  1015         *  ======== write1 ========
  1016         *  Generate a `Log` event with 1 argument
  1017         *
  1018         *  @see #write8
  1019         */
  1020        @Macro Void write1(Event evt, IArg a1);
  1021    
  1022        /*!
  1023         *  ======== write2 ========
  1024         *  Generate a `Log` event with 2 arguments
  1025         *
  1026         *  @see #write8
  1027         */
  1028        @Macro Void write2(Event evt, IArg a1, IArg a2);
  1029    
  1030        /*!
  1031         *  ======== write3 ========
  1032         *  Generate a `Log` event with 3 arguments
  1033         *
  1034         *  @see #write8
  1035         */
  1036        @Macro Void write3(Event evt, IArg a1, IArg a2, IArg a3);
  1037    
  1038        /*!
  1039         *  ======== write4 ========
  1040         *  Generate a `Log` event with 4 arguments
  1041         *
  1042         *  @see #write8
  1043         */
  1044        @Macro Void write4(Event evt, IArg a1, IArg a2, IArg a3, IArg a4);
  1045    
  1046        /*!
  1047         *  ======== write5 ========
  1048         *  Generate a `Log` event with 5 arguments
  1049         *
  1050         *  @see #write8
  1051         */
  1052        @Macro Void write5(Event evt, IArg a1, IArg a2, IArg a3, IArg a4, IArg a5);
  1053    
  1054        /*!
  1055         *  ======== write6 ========
  1056         *  Generate a `Log` event with 6 arguments
  1057         *
  1058         *  @see #write8
  1059         */
  1060        @Macro Void write6(Event evt, IArg a1, IArg a2, IArg a3, IArg a4,
  1061                            IArg a5, IArg a6);
  1062    
  1063        /*!
  1064         *  ======== write7 ========
  1065         *  Generate a `Log` event with 7 arguments
  1066         *
  1067         *  @see #write8
  1068         */
  1069        @Macro Void write7(Event evt, IArg a1, IArg a2, IArg a3, IArg a4,
  1070                            IArg a5, IArg a6, IArg a7);
  1071    
  1072        /*!
  1073         *  ======== write8 ========
  1074         *  Generate a `Log` event with 8 arguments
  1075         *
  1076         *  If the mask in the specified `Log` event has any bit set which is
  1077         *  also set in the current module's diagnostics mask, then this call to
  1078         *  write will "raise" the given `Log` event.
  1079         *
  1080         *  @param(evt)     the `Log` event to write
  1081         *  @param(a1)      value for first format conversion character
  1082         *  @param(a2)      value for second format conversion character
  1083         *  @param(a3)      value for third format conversion character
  1084         *  @param(a4)      value for fourth format conversion character
  1085         *  @param(a5)      value for fifth format conversion character
  1086         *  @param(a6)      value for sixth format conversion character
  1087         *  @param(a7)      value for seventh format conversion character
  1088         *  @param(a8)      value for eighth format conversion character
  1089         */
  1090        @Macro Void write8(Event evt, IArg a1, IArg a2, IArg a3, IArg a4,
  1091                            IArg a5, IArg a6, IArg a7, IArg a8);
  1092    
  1093        /*!
  1094         *  ======== doPrint ========
  1095         *  Render an event as text via `{@link System#printf System_printf}`
  1096         *
  1097         *  This method is not gated and may make more than one call to
  1098         *  `System_printf`.  This utility method is typically used within the
  1099         *  implementation of a logger which initializes
  1100         *  `{@link #EventRec Log_EventRec}` structures based on `Log` events
  1101         *  produced by the application.
  1102         *
  1103         *  @param(evRec)   a non`NULL` pointer to an initialized `Log_EventRec`
  1104         *                  structure to be formated via
  1105         *                  `{@link System#printf System_printf}`.
  1106         */
  1107        Void doPrint(EventRec *evRec);
  1108    
  1109        /*!
  1110         *  @_nodoc
  1111         *  ======== lookupEventMessage ========
  1112         *  Returns the format string for the event with the given id.
  1113         */
  1114        function lookupEventMessage(eventId);
  1115    
  1116        /*!
  1117         *  @_nodoc
  1118         *  ======== getTargetArgSize ========
  1119         *  Returns the target size of a record argument in bytes (not MAUs).
  1120         */
  1121        function getTargetArgSize();
  1122    
  1123        /*!
  1124         *  @_nodoc
  1125         *  ======== lookupEventName ========
  1126         */
  1127        function lookupEventName(eventId);
  1128    
  1129        /*!
  1130         *  @_nodoc
  1131         *  ======== lookupModuleName ========
  1132         */
  1133        function lookupModuleName(modId);
  1134    
  1135        /*!
  1136         *  @_nodoc
  1137         *  ======== getTargetEventRecSize ========
  1138         *  Returns the record size in bytes (not MAUs).
  1139         */
  1140        function getTargetEventRecSize();
  1141    
  1142    internal:
  1143    
  1144        /*
  1145         *  ======== idToInfo ========
  1146         *  Map event ID strings into a string of the form <eventName>::<eventMsg>
  1147         */
  1148        metaonly config String idToInfo[string] = [];
  1149    
  1150    }
  1151    /*
  1152     *  @(#) xdc.runtime; 2, 1, 0,359; 11-16-2011 11:00:16; /db/ztree/library/trees/xdc/xdc-y13x/src/packages/
  1153     */
  1154