This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Encoding of logs

Hello everyone,

(target C6678, CCS 5.5, BIOS 1.25, XDCTools 3.25)

Here's a question concerning Logs

There is the "The target representation of a recorded event"

typedef struct Log_EventRec{

    Types_Timestamp64 tstamp;
    // time event was written
    Bits32 serial;
    // serial number of event
    Types_Event evt;
    // target encoding of an Event
    IArg arg[Log_NUMARGS];
    // arguments passed via Log_write/print
} Log_EventRec;
with Types_Event being typedef Bits32 Types_Event;
The documentation also states
"An Event is represented on the target as a 32-bit value that can be decoded offline to recover the Event information defined in a corresponding metaonly EventDesc."
With EventDesc
var obj = new Log.EventDesc;
 
    obj.mask = Bits16  ...
    // event enable mask
    obj.level = Diags.EventLevel  ...
    // event level relative to other events
    obj.msg = String  ...
    // event "printf" message format string
It looks like EventDesc total size is > 32 bits
My question is : how is the whole large EventDesc structure encoded into a small 32-bit Types_Event  ?
Thank you,
Clement
  • Clement,
    Log_Event and Types_Event are not the same type. Let's first describe the relationship between Log_Event and Log.EventDesc. In Log.xdc, they are bound by the following definition:
    @Encoded typedef EventDesc Event;
    This means that Log_Event is a runtime type that encodes the metaonly type Log.EventDesc. This guide describes it in more details: http://rtsc.eclipse.org/docs-tip/Using_Encoded_Types.
    The module that defines an encoded type also defines the encoding algorithm. In Log.xs, there is function Event$decode that creates a string, which is then used as an initializer for an Event in the generated C file. The output of that function would be something like this:
    (((Log_Event)640) << 16 | 4).
    Because Log_Event is defined as 32 bit type, this whole expression is a 32 bit value where 640 is 'id', a kind of a pointer to obj.msg, and 4 is a combination of obj.mask and obj.level.

    Types_Event is not defined as an encoded type, but it is used in a similar way to encode an 'id' and the type Types_Site. You can see that encoding in the file Types__epilogue.h, in the macro xdc_runtime_Types_makeEvent.

  • Sasha,

    Thank you for your detailled answer.

    It makes way more sense now.

    The relation between the 'id' (640 in your example) and the EventDesc msg field is a bit mysterious though.
    I don't really need to know more details so don't bother.

    Regards,

    Clement