2003-09-14 00:06:09 +00:00
|
|
|
/*
|
|
|
|
*******************************************************************************
|
|
|
|
*
|
|
|
|
* Copyright (C) 2003, International Business Machines
|
|
|
|
* Corporation and others. All Rights Reserved.
|
|
|
|
*
|
|
|
|
*******************************************************************************
|
|
|
|
* file name: utrace.h
|
|
|
|
* encoding: US-ASCII
|
|
|
|
* tab size: 8 (not used)
|
|
|
|
* indentation:4
|
|
|
|
*
|
|
|
|
* created on: 2003aug06
|
|
|
|
* created by: Markus W. Scherer
|
|
|
|
*
|
|
|
|
* Definitions for ICU tracing/logging.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __UTRACE_H__
|
|
|
|
#define __UTRACE_H__
|
|
|
|
|
|
|
|
#include <stdarg.h>
|
|
|
|
#include "unicode/utypes.h"
|
|
|
|
|
|
|
|
U_CDECL_BEGIN
|
|
|
|
|
2003-10-31 21:50:18 +00:00
|
|
|
/**
|
|
|
|
* Trace severity levels. Higher levels increase the verbosity of the trace output.
|
|
|
|
* @see utrace_setLevel
|
|
|
|
* @draft ICU 2.8
|
|
|
|
*/
|
|
|
|
|
2003-09-14 00:06:09 +00:00
|
|
|
enum UTraceLevel {
|
2003-11-12 07:00:38 +00:00
|
|
|
/** Disable all tracing */
|
2003-09-14 00:06:09 +00:00
|
|
|
UTRACE_OFF=-1,
|
2003-11-12 07:00:38 +00:00
|
|
|
/** Trace error conditions only */
|
2003-10-31 21:50:18 +00:00
|
|
|
UTRACE_ERROR=0,
|
2003-11-12 07:00:38 +00:00
|
|
|
/** Trace errors and warnings */
|
2003-10-31 21:50:18 +00:00
|
|
|
UTRACE_WARNING=3,
|
2003-11-12 07:00:38 +00:00
|
|
|
/** Trace opens and closes of ICU services */
|
2003-10-31 21:50:18 +00:00
|
|
|
UTRACE_OPEN_CLOSE=5,
|
2003-11-12 07:00:38 +00:00
|
|
|
/** Trace an intermediate number of ICU operations */
|
2003-10-31 21:50:18 +00:00
|
|
|
UTRACE_INFO=7,
|
2003-11-12 07:00:38 +00:00
|
|
|
/** Trace the maximum number of ICU operations */
|
2003-10-31 21:50:18 +00:00
|
|
|
UTRACE_VERBOSE=9
|
2003-09-14 00:06:09 +00:00
|
|
|
};
|
|
|
|
typedef enum UTraceLevel UTraceLevel;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Setter for the trace level.
|
|
|
|
* @param traceLevel A UTraceLevel value.
|
|
|
|
* @draft ICU 2.8
|
|
|
|
*/
|
|
|
|
U_CAPI void U_EXPORT2
|
|
|
|
utrace_setLevel(int32_t traceLevel);
|
|
|
|
|
2003-10-31 21:50:18 +00:00
|
|
|
/**
|
|
|
|
* Getter for the trace level.
|
|
|
|
* @param traceLevel A UTraceLevel value.
|
|
|
|
* @draft ICU 2.8
|
|
|
|
*/
|
|
|
|
U_CAPI int32_t U_EXPORT2
|
|
|
|
utrace_getLevel();
|
|
|
|
|
2003-10-31 02:19:42 +00:00
|
|
|
/* Trace function pointers types ----------------------------- */
|
2003-09-20 01:21:23 +00:00
|
|
|
|
2003-11-04 01:01:04 +00:00
|
|
|
/**
|
|
|
|
* Type signature for the trace function to be called when entering a function.
|
|
|
|
* @param context value supplied at the time the trace functions are set.
|
|
|
|
* @param fnNumber Enum value indicating the ICU function being entered.
|
|
|
|
* @draft ICU 2.8
|
|
|
|
*/
|
2003-10-31 02:19:42 +00:00
|
|
|
typedef void U_CALLCONV
|
|
|
|
UTraceEntry(const void *context, int32_t fnNumber);
|
2003-09-24 00:58:35 +00:00
|
|
|
|
2003-11-04 01:01:04 +00:00
|
|
|
/**
|
|
|
|
* Type signature for the trace function to be called when exiting from a function.
|
|
|
|
* @param context value supplied at the time the trace functions are set.
|
|
|
|
* @param fnNumber Enum value indicating the ICU function being exited.
|
2003-11-12 07:00:38 +00:00
|
|
|
* @param retType the UTraceExitVal indicating the number and types of
|
|
|
|
* variable arguments that follow.
|
|
|
|
* @param argType values returned by the function being traced, may include
|
|
|
|
* one or both of the function's return value and a
|
|
|
|
* UErrorCode parameter value.
|
|
|
|
* @see UTraceExitVal
|
2003-11-04 01:01:04 +00:00
|
|
|
* @draft ICU 2.8
|
|
|
|
*/
|
2003-10-31 02:19:42 +00:00
|
|
|
typedef void U_CALLCONV
|
|
|
|
UTraceExit(const void *context, int32_t fnNumber,
|
2003-11-12 07:00:38 +00:00
|
|
|
int32_t argType, va_list args);
|
2003-09-20 01:21:23 +00:00
|
|
|
|
2003-11-04 01:01:04 +00:00
|
|
|
/**
|
|
|
|
* Type signature for the trace function to be called from within an ICU function
|
|
|
|
* to display data or messages.
|
|
|
|
* @param context value supplied at the time the trace functions are set.
|
|
|
|
* @param fnNumber Enum value indicating the ICU function being exited.
|
|
|
|
* @draft ICU 2.8
|
|
|
|
*/
|
2003-10-31 02:19:42 +00:00
|
|
|
typedef void U_CALLCONV
|
|
|
|
UTraceData(const void *context, int32_t fnNumber, int32_t level,
|
|
|
|
const char *fmt, va_list args);
|
2003-09-20 01:21:23 +00:00
|
|
|
|
2003-09-14 00:06:09 +00:00
|
|
|
/**
|
2003-10-31 02:19:42 +00:00
|
|
|
* Set ICU Tracing functions. Installs application-provided tracing
|
|
|
|
* functions into ICU. After doing this, subsequent ICU operations
|
|
|
|
* will call back to the installed functions, providing a trace
|
2003-11-12 07:00:38 +00:00
|
|
|
* of the use of ICU. Passing a NULL pointer for a tracing function
|
|
|
|
* is allowed, and inhibits tracing action at points where that function
|
|
|
|
* would be called.
|
|
|
|
*
|
2003-10-31 02:19:42 +00:00
|
|
|
* @param context an uninterpretted pointer. Whatever is passed in
|
|
|
|
* here will in turn be passed to each of the tracing
|
|
|
|
* functions UTraceEntry, UTraceExit and UTraceData.
|
|
|
|
* ICU does not use or alter this pointer.
|
|
|
|
* @param e Callback function to be called on entry to a
|
|
|
|
* a traced ICU function.
|
|
|
|
* @param x Callback function to be called on exit from a
|
|
|
|
* traced ICU function.
|
|
|
|
* @param d Callback function to be called from within a
|
|
|
|
* traced ICU function, for the purpose of providing
|
|
|
|
* data to the trace.
|
2003-10-31 21:50:18 +00:00
|
|
|
*
|
|
|
|
* @draft ICU 2.8
|
2003-10-31 02:19:42 +00:00
|
|
|
*/
|
2003-09-14 00:06:09 +00:00
|
|
|
U_CAPI void U_EXPORT2
|
2003-10-31 02:19:42 +00:00
|
|
|
utrace_setFunctions(const void *context,
|
2003-10-31 21:50:18 +00:00
|
|
|
UTraceEntry *e, UTraceExit *x, UTraceData *d);
|
2003-09-14 00:06:09 +00:00
|
|
|
|
2003-10-31 21:50:18 +00:00
|
|
|
/**
|
2003-11-04 01:01:04 +00:00
|
|
|
* Get the currently installed ICU tracing functions. Note that a null function
|
|
|
|
* pointer will be returned if no trace function has been set.
|
|
|
|
*
|
2003-10-31 21:50:18 +00:00
|
|
|
* @param context The currently installed tracing context.
|
|
|
|
* @param e The currently installed UTraceEntry function.
|
|
|
|
* @param x The currently installed UTraceExit function.
|
|
|
|
* @param d The currently installed UTraceData function.
|
|
|
|
* @draft ICU 2.8
|
|
|
|
*/
|
|
|
|
U_CAPI void U_EXPORT2
|
|
|
|
utrace_getFunctions(const void **context,
|
|
|
|
UTraceEntry **e, UTraceExit **x, UTraceData **d);
|
2003-09-20 01:21:23 +00:00
|
|
|
|
2003-09-14 00:06:09 +00:00
|
|
|
|
2003-10-31 21:50:18 +00:00
|
|
|
|
|
|
|
/*
|
2003-09-14 00:06:09 +00:00
|
|
|
*
|
|
|
|
* ICU trace format string syntax
|
|
|
|
*
|
2003-10-31 21:50:18 +00:00
|
|
|
* Format Strings are passed to UTraceData functions, and define the
|
|
|
|
* number and types of the trace data being passed on each call.
|
2003-10-31 02:19:42 +00:00
|
|
|
*
|
2003-10-31 21:50:18 +00:00
|
|
|
* The UTraceData function, which is supplied by the application,
|
|
|
|
* not by ICU, can either forward the trace data (passed via
|
|
|
|
* varargs) and the format string back to ICU for formatting into
|
|
|
|
* a displayable string, or it can interpret the format itself,
|
|
|
|
* and do as it wishes with the trace data.
|
2003-10-31 02:19:42 +00:00
|
|
|
*
|
|
|
|
*
|
|
|
|
* Goals for the format string
|
2003-09-14 00:06:09 +00:00
|
|
|
* - basic data output
|
|
|
|
* - easy to use for trace programmer
|
|
|
|
* - sufficient provision for data types for trace output readability
|
|
|
|
* - well-defined types and binary portable APIs
|
|
|
|
*
|
|
|
|
* Non-goals
|
|
|
|
* - printf compatibility
|
|
|
|
* - fancy formatting
|
|
|
|
* - argument reordering and other internationalization features
|
|
|
|
*
|
|
|
|
* ICU trace format strings contain plain text with argument inserts,
|
|
|
|
* much like standard printf format strings.
|
|
|
|
* Each insert begins with a '%', then optionally contains a 'v',
|
|
|
|
* then exactly one type character.
|
|
|
|
* Two '%' in a row represent a '%' instead of an insert.
|
|
|
|
* The trace format strings need not have \n at the end.
|
|
|
|
*
|
2003-10-31 21:50:18 +00:00
|
|
|
*
|
|
|
|
* Types
|
|
|
|
* -----
|
2003-09-14 00:06:09 +00:00
|
|
|
*
|
|
|
|
* Type characters:
|
|
|
|
* - c A char character in the default codepage.
|
2003-11-04 01:01:04 +00:00
|
|
|
* - s A NUL-terminated char * string in the default codepage.
|
|
|
|
* - S A UChar * string. Requires two params, (ptr, length). Length=-1 for nul term.
|
2003-09-14 00:06:09 +00:00
|
|
|
* - b A byte (8-bit integer).
|
2003-10-31 02:19:42 +00:00
|
|
|
* - h A 16-bit integer. Also a 16 bit Unicode code unit.
|
|
|
|
* - d A 32-bit integer. Also a 20 bit Unicode code point value.
|
2003-09-14 00:06:09 +00:00
|
|
|
* - l A 64-bit integer.
|
|
|
|
* - p A data pointer.
|
|
|
|
*
|
2003-10-31 21:50:18 +00:00
|
|
|
* Vectors
|
|
|
|
* -------
|
|
|
|
*
|
|
|
|
* If the 'v' is not specified, then one item of the specified type
|
|
|
|
* is passed in.
|
|
|
|
* If the 'v' (for "vector") is specified, then a vector of items of the
|
|
|
|
* specified type is passed in, via a pointer to the first item
|
|
|
|
* and an int32_t value for the length of the vector.
|
2003-11-04 01:01:04 +00:00
|
|
|
* Length==-1 means zero or NUL termination. Works for vectors of all types.
|
2003-10-31 21:50:18 +00:00
|
|
|
*
|
|
|
|
* Note: %vS is a vector of (UChar *) strings. The strings must
|
2003-11-04 01:01:04 +00:00
|
|
|
* be nul terminated as there is no way to provide a
|
2003-10-31 21:50:18 +00:00
|
|
|
* separate length parameter for each string. The length
|
|
|
|
* parameter (required for all vectors) is the number of
|
|
|
|
* strings, not the length of the strings.
|
|
|
|
*
|
|
|
|
* Examples
|
|
|
|
* --------
|
|
|
|
*
|
|
|
|
* These examples show the parameters that will be passed to an application's
|
|
|
|
* UTraceData() function for various formats.
|
|
|
|
*
|
2003-09-14 00:06:09 +00:00
|
|
|
* - the precise formatting is up to the application!
|
|
|
|
* - the examples use type casts for arguments only to _show_ the types of
|
|
|
|
* arguments without needing variable declarations in the examples;
|
|
|
|
* the type casts will not be necessary in actual code
|
|
|
|
*
|
2003-10-31 21:50:18 +00:00
|
|
|
* UTraceDataFunc(context, fnNumber, level,
|
|
|
|
* "There is a character %c in the string %s.", // Format String
|
|
|
|
* (char)c, (const char *)s); // varargs parameters
|
|
|
|
* -> There is a character 0x42 'B' in the string "Bravo".
|
2003-09-14 00:06:09 +00:00
|
|
|
*
|
2003-10-31 21:50:18 +00:00
|
|
|
* UTraceDataFunc(context, fnNumber, level,
|
2003-09-14 00:06:09 +00:00
|
|
|
* "Vector of bytes %vb vector of chars %vc",
|
|
|
|
* (const uint8_t *)bytes, (int32_t)bytesLength,
|
|
|
|
* (const char *)chars, (int32_t)charsLength);
|
2003-10-31 21:50:18 +00:00
|
|
|
* -> Vector of bytes
|
2003-09-14 00:06:09 +00:00
|
|
|
* 42 63 64 3f [4]
|
2003-10-31 21:50:18 +00:00
|
|
|
* vector of chars
|
2003-09-14 00:06:09 +00:00
|
|
|
* "Bcd?"[4]
|
|
|
|
*
|
2003-10-31 21:50:18 +00:00
|
|
|
* UTraceDataFunc(context, fnNumber, level,
|
2003-09-14 00:06:09 +00:00
|
|
|
* "An int32_t %d and a whole bunch of them %vd",
|
|
|
|
* (int32_t)-5, (const int32_t *)ints, (int32_t)intsLength);
|
2003-10-31 21:50:18 +00:00
|
|
|
* -> An int32_t 0xfffffffb and a whole bunch of them
|
2003-09-14 00:06:09 +00:00
|
|
|
* fffffffb 00000005 0000010a [3]
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2003-10-31 02:19:42 +00:00
|
|
|
* Trace output Formatter. An application's UTraceData tracing functions may call
|
|
|
|
* back to this function to format the trace output in a
|
|
|
|
* human readable form. Note that a UTraceData function is not
|
|
|
|
* required to format the data; it could, for example, save it in
|
|
|
|
* in the raw form it was received (more compact), leaving
|
|
|
|
* formatting for a later trace analyis tool.
|
2003-09-20 01:21:23 +00:00
|
|
|
* @param outBuf pointer to a buffer to receive the formatted output. Output
|
2003-11-04 01:01:04 +00:00
|
|
|
* will be nul terminated if there is space in the buffer -
|
2003-09-20 01:21:23 +00:00
|
|
|
* if the length of the requested output < the output buffer size.
|
|
|
|
* @param capacity Length of the output buffer.
|
|
|
|
* @param indent Number of spaces to indent the output. Intended to allow
|
|
|
|
* data displayed from nested functions to be indented for readability.
|
|
|
|
* @param fmt Format specification for the data to output
|
|
|
|
* @param args Data to be formatted.
|
2003-11-04 01:01:04 +00:00
|
|
|
* @return Length of formatted output, including the terminating NUL.
|
2003-09-25 17:58:08 +00:00
|
|
|
* If buffer capacity is insufficient, the required capacity is returned.
|
2003-10-31 02:19:42 +00:00
|
|
|
* @draft ICU 2.8
|
2003-09-14 00:06:09 +00:00
|
|
|
*/
|
|
|
|
U_CAPI int32_t U_EXPORT2
|
|
|
|
utrace_format(char *outBuf, int32_t capacity,
|
2003-09-20 01:21:23 +00:00
|
|
|
int32_t indent, const char *fmt, va_list args);
|
2003-09-14 00:06:09 +00:00
|
|
|
|
|
|
|
|
2003-10-31 02:19:42 +00:00
|
|
|
/**
|
|
|
|
* Traced Function Exit return types.
|
|
|
|
* Flags indicating the number and types of varargs included in a call
|
|
|
|
* to a UTraceExit function.
|
|
|
|
* Bits 0-3: The function return type. First variable param.
|
|
|
|
* Bit 4: Flag for presence of U_ErrorCode status param.
|
|
|
|
* @draft ICU 2.8
|
|
|
|
*/
|
|
|
|
enum UTraceExitVal {
|
2003-11-12 07:00:38 +00:00
|
|
|
/** The traced function returns no value */
|
2003-10-31 02:19:42 +00:00
|
|
|
UTRACE_EXITV_NONE = 0,
|
2003-11-12 07:00:38 +00:00
|
|
|
/** The traced function returns an int32_t, or compatible, type. */
|
2003-10-31 02:19:42 +00:00
|
|
|
UTRACE_EXITV_I32 = 1,
|
2003-11-12 07:00:38 +00:00
|
|
|
/** The traced function returns a pointer */
|
2003-10-31 02:19:42 +00:00
|
|
|
UTRACE_EXITV_PTR = 2,
|
2003-11-12 07:00:38 +00:00
|
|
|
/** The traced function returns a UBool */
|
2003-10-31 02:19:42 +00:00
|
|
|
UTRACE_EXITV_BOOL = 3,
|
2003-11-12 07:00:38 +00:00
|
|
|
/** Mask to extract the return type values from a UTraceExitVal */
|
2003-10-31 02:19:42 +00:00
|
|
|
UTRACE_EXITV_MASK = 0xf,
|
2003-11-12 07:00:38 +00:00
|
|
|
/** Bit indicating that the traced function includes a UErrorCode parameter */
|
2003-10-31 02:19:42 +00:00
|
|
|
UTRACE_EXITV_STATUS = 0x10
|
|
|
|
};
|
|
|
|
typedef enum UTraceExitVal UTraceExitVal;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Trace formatter for UTraceExit, function exit tracing.
|
|
|
|
* UTraceExit may optionally receive two data items: a function return value
|
|
|
|
* and a UErrorCode status value.
|
|
|
|
*
|
|
|
|
* @param outBuf pointer to a buffer to receive the formatted output.Output
|
2003-11-04 01:01:04 +00:00
|
|
|
* will be nul terminated if there is space in the buffer -
|
2003-10-31 02:19:42 +00:00
|
|
|
* if the length of the requested output < the output buffer size.
|
|
|
|
* @param capacity Length of the output buffer.
|
|
|
|
* @param indent Number of spaces to indent the output. Intended to allow
|
|
|
|
* data displayed from nested functions to be indented for readability.
|
|
|
|
* @param fnNumber An index specifying the function that is exiting.
|
|
|
|
* @param argType Flags specifying the number and types of data values.
|
2003-11-04 01:01:04 +00:00
|
|
|
* @param args Data to be formatted. If argType parameter indicates that a function
|
|
|
|
* return value exists, it will be the first varargs param. The
|
|
|
|
* function's UErrorCode status will be next, when applicable.
|
|
|
|
* @return Length of formatted output, including the terminating NUL.
|
2003-10-31 02:19:42 +00:00
|
|
|
* If buffer capacity is insufficient, the required capacity is returned.
|
2003-10-31 21:50:18 +00:00
|
|
|
* @draft ICU 2.8
|
2003-10-31 02:19:42 +00:00
|
|
|
*/
|
|
|
|
|
2003-09-24 00:58:35 +00:00
|
|
|
U_CAPI void U_EXPORT2
|
|
|
|
utrace_formatExit(char *outBuf, int32_t capacity, int32_t indent,
|
|
|
|
int32_t fnNumber, int32_t argtype, va_list args);
|
|
|
|
|
2003-09-14 00:06:09 +00:00
|
|
|
/* Trace function numbers --------------------------------------------------- */
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the name of a function from its trace function number.
|
|
|
|
*
|
|
|
|
* @param fnNumber The trace number for an ICU function.
|
|
|
|
* @return The name string for the function.
|
|
|
|
*
|
|
|
|
* @see UTraceFunctionNumber
|
|
|
|
* @draft ICU 2.8
|
|
|
|
*/
|
|
|
|
U_CAPI const char * U_EXPORT2
|
|
|
|
utrace_functionName(int32_t fnNumber);
|
|
|
|
|
2003-10-31 21:50:18 +00:00
|
|
|
/**
|
|
|
|
* These are the ICU functions that will be traced when tracing is enabled.
|
|
|
|
*/
|
2003-09-14 00:06:09 +00:00
|
|
|
enum UTraceFunctionNumber {
|
2003-09-20 01:21:23 +00:00
|
|
|
UTRACE_FUNCTION_START=0,
|
|
|
|
UTRACE_U_INIT=UTRACE_FUNCTION_START,
|
|
|
|
UTRACE_U_CLEANUP,
|
|
|
|
UTRACE_FUNCTION_LIMIT,
|
2003-09-14 00:06:09 +00:00
|
|
|
|
2003-09-20 01:21:23 +00:00
|
|
|
UTRACE_CONVERSION_START=0x1000,
|
|
|
|
UTRACE_UCNV_OPEN=UTRACE_CONVERSION_START,
|
2003-09-14 00:06:09 +00:00
|
|
|
UTRACE_UCNV_CLOSE,
|
|
|
|
UTRACE_UCNV_FLUSH_CACHE,
|
2003-09-20 01:21:23 +00:00
|
|
|
UTRACE_CONVERSION_LIMIT,
|
2003-09-14 00:06:09 +00:00
|
|
|
|
2003-09-20 01:21:23 +00:00
|
|
|
UTRACE_COLLATION_START=0x2000,
|
|
|
|
UTRACE_UCOL_OPEN=UTRACE_COLLATION_START,
|
2003-09-14 00:06:09 +00:00
|
|
|
UTRACE_UCOL_CLOSE,
|
|
|
|
UTRACE_UCOL_STRCOLL,
|
|
|
|
UTRACE_UCOL_GET_SORTKEY,
|
2003-09-24 00:58:35 +00:00
|
|
|
UTRACE_UCOL_GETLOCALE,
|
|
|
|
UTRACE_UCOL_NEXTSORTKEYPART,
|
|
|
|
UTRACE_UCOL_STRCOLLITER,
|
|
|
|
UTRACE_COLLATION_LIMIT
|
2003-09-14 00:06:09 +00:00
|
|
|
};
|
|
|
|
typedef enum UTraceFunctionNumber UTraceFunctionNumber;
|
|
|
|
|
|
|
|
U_CDECL_END
|
|
|
|
|
|
|
|
#endif
|