LOG_printf
2-192
LOG_printf does not provide a conversion character for code pointers. If
you are using the ’C55x large model, you can use the %p character to
print code pointers.
Since LOG_printf does not provide a conversion character for long
integers, you may want to use 0x%p instead. Another solution is to use
bitwise shifting and ANDing to break a 32-bit number into its 16-bit
counterparts. In following example,
(Int)(maincount >> 16)
is the
upper 16 bits of maincount shifted into the 16-bits of an Int. And,
(Int)(maincount & 0xffff)
is the lower 16 bits of maincount.
%s
Character string
This character can only be used with constant string pointers.
That is, the string must appear in the source and be passed to
LOG_printf
. For example, the following is supported:
char *msg = "Hello world!";
LOG_printf(&trace, "%s", msg);
However, the following example is not supported:
char msg[100];
strcpy(msg, "Hello world!");
LOG_printf(&trace, "%s", msg);
If the string appears in the COFF file and a pointer to the
string is passed to
LOG_printf
, then the string in the COFF
file is used by the Event Log to generate the output.
If the string can not be found in the COFF file, the format
string is replaced with
*** ERROR: 0x%x 0x%x ***\n
,
which displays all arguments in hexadecimal.
%r
Symbol from symbol table
This is an extension of the standard
printf
format tokens. This
character treats its parameter as a pointer to be looked up in
the symbol table of the executable and displayed. That is,
%r
displays the symbol (defined in the executable) whose value
matches the value passed to
%r
. For example:
Int testval = 17;
LOG_printf("%r = %d", &testval, testval);
displays:
testval = 17
If no symbol is found for the value passed to
%r
, the Event
Log uses the string
<unknown symbol>
.
%p
data pointer
Conversion Character
Description