xref: /aosp_15_r20/external/icu/libandroidicu/include/unicode/utrace.h (revision 0e209d3975ff4a8c132096b14b0e9364a753506e)
1*0e209d39SAndroid Build Coastguard Worker // © 2016 and later: Unicode, Inc. and others.
2*0e209d39SAndroid Build Coastguard Worker // License & terms of use: http://www.unicode.org/copyright.html
3*0e209d39SAndroid Build Coastguard Worker /*
4*0e209d39SAndroid Build Coastguard Worker *******************************************************************************
5*0e209d39SAndroid Build Coastguard Worker *
6*0e209d39SAndroid Build Coastguard Worker *   Copyright (C) 2003-2013, International Business Machines
7*0e209d39SAndroid Build Coastguard Worker *   Corporation and others.  All Rights Reserved.
8*0e209d39SAndroid Build Coastguard Worker *
9*0e209d39SAndroid Build Coastguard Worker *******************************************************************************
10*0e209d39SAndroid Build Coastguard Worker *   file name:  utrace.h
11*0e209d39SAndroid Build Coastguard Worker *   encoding:   UTF-8
12*0e209d39SAndroid Build Coastguard Worker *   tab size:   8 (not used)
13*0e209d39SAndroid Build Coastguard Worker *   indentation:4
14*0e209d39SAndroid Build Coastguard Worker *
15*0e209d39SAndroid Build Coastguard Worker *   created on: 2003aug06
16*0e209d39SAndroid Build Coastguard Worker *   created by: Markus W. Scherer
17*0e209d39SAndroid Build Coastguard Worker *
18*0e209d39SAndroid Build Coastguard Worker *   Definitions for ICU tracing/logging.
19*0e209d39SAndroid Build Coastguard Worker *
20*0e209d39SAndroid Build Coastguard Worker */
21*0e209d39SAndroid Build Coastguard Worker 
22*0e209d39SAndroid Build Coastguard Worker #ifndef __UTRACE_H__
23*0e209d39SAndroid Build Coastguard Worker #define __UTRACE_H__
24*0e209d39SAndroid Build Coastguard Worker 
25*0e209d39SAndroid Build Coastguard Worker #include <stdarg.h>
26*0e209d39SAndroid Build Coastguard Worker #include "unicode/utypes.h"
27*0e209d39SAndroid Build Coastguard Worker 
28*0e209d39SAndroid Build Coastguard Worker /**
29*0e209d39SAndroid Build Coastguard Worker  * \file
30*0e209d39SAndroid Build Coastguard Worker  * \brief C API:  Definitions for ICU tracing/logging.
31*0e209d39SAndroid Build Coastguard Worker  *
32*0e209d39SAndroid Build Coastguard Worker  * This provides API for debugging the internals of ICU without the use of
33*0e209d39SAndroid Build Coastguard Worker  * a traditional debugger.
34*0e209d39SAndroid Build Coastguard Worker  *
35*0e209d39SAndroid Build Coastguard Worker  * By default, tracing is disabled in ICU. If you need to debug ICU with
36*0e209d39SAndroid Build Coastguard Worker  * tracing, please compile ICU with the --enable-tracing configure option.
37*0e209d39SAndroid Build Coastguard Worker  */
38*0e209d39SAndroid Build Coastguard Worker 
39*0e209d39SAndroid Build Coastguard Worker U_CDECL_BEGIN
40*0e209d39SAndroid Build Coastguard Worker 
41*0e209d39SAndroid Build Coastguard Worker /**
42*0e209d39SAndroid Build Coastguard Worker  * Trace severity levels.  Higher levels increase the verbosity of the trace output.
43*0e209d39SAndroid Build Coastguard Worker  * @see utrace_setLevel
44*0e209d39SAndroid Build Coastguard Worker  * @stable ICU 2.8
45*0e209d39SAndroid Build Coastguard Worker  */
46*0e209d39SAndroid Build Coastguard Worker typedef enum UTraceLevel {
47*0e209d39SAndroid Build Coastguard Worker     /** Disable all tracing  @stable ICU 2.8*/
48*0e209d39SAndroid Build Coastguard Worker     UTRACE_OFF=-1,
49*0e209d39SAndroid Build Coastguard Worker     /** Trace error conditions only  @stable ICU 2.8*/
50*0e209d39SAndroid Build Coastguard Worker     UTRACE_ERROR=0,
51*0e209d39SAndroid Build Coastguard Worker     /** Trace errors and warnings  @stable ICU 2.8*/
52*0e209d39SAndroid Build Coastguard Worker     UTRACE_WARNING=3,
53*0e209d39SAndroid Build Coastguard Worker     /** Trace opens and closes of ICU services  @stable ICU 2.8*/
54*0e209d39SAndroid Build Coastguard Worker     UTRACE_OPEN_CLOSE=5,
55*0e209d39SAndroid Build Coastguard Worker     /** Trace an intermediate number of ICU operations  @stable ICU 2.8*/
56*0e209d39SAndroid Build Coastguard Worker     UTRACE_INFO=7,
57*0e209d39SAndroid Build Coastguard Worker     /** Trace the maximum number of ICU operations  @stable ICU 2.8*/
58*0e209d39SAndroid Build Coastguard Worker     UTRACE_VERBOSE=9
59*0e209d39SAndroid Build Coastguard Worker } UTraceLevel;
60*0e209d39SAndroid Build Coastguard Worker 
61*0e209d39SAndroid Build Coastguard Worker /**
62*0e209d39SAndroid Build Coastguard Worker  *  These are the ICU functions that will be traced when tracing is enabled.
63*0e209d39SAndroid Build Coastguard Worker  *  @stable ICU 2.8
64*0e209d39SAndroid Build Coastguard Worker  */
65*0e209d39SAndroid Build Coastguard Worker typedef enum UTraceFunctionNumber {
66*0e209d39SAndroid Build Coastguard Worker     UTRACE_FUNCTION_START=0,
67*0e209d39SAndroid Build Coastguard Worker     UTRACE_U_INIT=UTRACE_FUNCTION_START,
68*0e209d39SAndroid Build Coastguard Worker     UTRACE_U_CLEANUP,
69*0e209d39SAndroid Build Coastguard Worker 
70*0e209d39SAndroid Build Coastguard Worker #ifndef U_HIDE_DEPRECATED_API
71*0e209d39SAndroid Build Coastguard Worker     /**
72*0e209d39SAndroid Build Coastguard Worker      * One more than the highest normal collation trace location.
73*0e209d39SAndroid Build Coastguard Worker      * @deprecated ICU 58 The numeric value may change over time, see ICU ticket #12420.
74*0e209d39SAndroid Build Coastguard Worker      */
75*0e209d39SAndroid Build Coastguard Worker     UTRACE_FUNCTION_LIMIT,
76*0e209d39SAndroid Build Coastguard Worker #endif  // U_HIDE_DEPRECATED_API
77*0e209d39SAndroid Build Coastguard Worker 
78*0e209d39SAndroid Build Coastguard Worker     UTRACE_CONVERSION_START=0x1000,
79*0e209d39SAndroid Build Coastguard Worker     UTRACE_UCNV_OPEN=UTRACE_CONVERSION_START,
80*0e209d39SAndroid Build Coastguard Worker     UTRACE_UCNV_OPEN_PACKAGE,
81*0e209d39SAndroid Build Coastguard Worker     UTRACE_UCNV_OPEN_ALGORITHMIC,
82*0e209d39SAndroid Build Coastguard Worker     UTRACE_UCNV_CLONE,
83*0e209d39SAndroid Build Coastguard Worker     UTRACE_UCNV_CLOSE,
84*0e209d39SAndroid Build Coastguard Worker     UTRACE_UCNV_FLUSH_CACHE,
85*0e209d39SAndroid Build Coastguard Worker     UTRACE_UCNV_LOAD,
86*0e209d39SAndroid Build Coastguard Worker     UTRACE_UCNV_UNLOAD,
87*0e209d39SAndroid Build Coastguard Worker 
88*0e209d39SAndroid Build Coastguard Worker #ifndef U_HIDE_DEPRECATED_API
89*0e209d39SAndroid Build Coastguard Worker     /**
90*0e209d39SAndroid Build Coastguard Worker      * One more than the highest normal collation trace location.
91*0e209d39SAndroid Build Coastguard Worker      * @deprecated ICU 58 The numeric value may change over time, see ICU ticket #12420.
92*0e209d39SAndroid Build Coastguard Worker      */
93*0e209d39SAndroid Build Coastguard Worker     UTRACE_CONVERSION_LIMIT,
94*0e209d39SAndroid Build Coastguard Worker #endif  // U_HIDE_DEPRECATED_API
95*0e209d39SAndroid Build Coastguard Worker 
96*0e209d39SAndroid Build Coastguard Worker     UTRACE_COLLATION_START=0x2000,
97*0e209d39SAndroid Build Coastguard Worker     UTRACE_UCOL_OPEN=UTRACE_COLLATION_START,
98*0e209d39SAndroid Build Coastguard Worker     UTRACE_UCOL_CLOSE,
99*0e209d39SAndroid Build Coastguard Worker     UTRACE_UCOL_STRCOLL,
100*0e209d39SAndroid Build Coastguard Worker     UTRACE_UCOL_GET_SORTKEY,
101*0e209d39SAndroid Build Coastguard Worker     UTRACE_UCOL_GETLOCALE,
102*0e209d39SAndroid Build Coastguard Worker     UTRACE_UCOL_NEXTSORTKEYPART,
103*0e209d39SAndroid Build Coastguard Worker     UTRACE_UCOL_STRCOLLITER,
104*0e209d39SAndroid Build Coastguard Worker     UTRACE_UCOL_OPEN_FROM_SHORT_STRING,
105*0e209d39SAndroid Build Coastguard Worker     UTRACE_UCOL_STRCOLLUTF8, /**< @stable ICU 50 */
106*0e209d39SAndroid Build Coastguard Worker 
107*0e209d39SAndroid Build Coastguard Worker #ifndef U_HIDE_DEPRECATED_API
108*0e209d39SAndroid Build Coastguard Worker     /**
109*0e209d39SAndroid Build Coastguard Worker      * One more than the highest normal collation trace location.
110*0e209d39SAndroid Build Coastguard Worker      * @deprecated ICU 58 The numeric value may change over time, see ICU ticket #12420.
111*0e209d39SAndroid Build Coastguard Worker      */
112*0e209d39SAndroid Build Coastguard Worker     UTRACE_COLLATION_LIMIT,
113*0e209d39SAndroid Build Coastguard Worker #endif  // U_HIDE_DEPRECATED_API
114*0e209d39SAndroid Build Coastguard Worker 
115*0e209d39SAndroid Build Coastguard Worker     /**
116*0e209d39SAndroid Build Coastguard Worker      * The lowest resource/data location.
117*0e209d39SAndroid Build Coastguard Worker      * @stable ICU 65
118*0e209d39SAndroid Build Coastguard Worker      */
119*0e209d39SAndroid Build Coastguard Worker     UTRACE_UDATA_START=0x3000,
120*0e209d39SAndroid Build Coastguard Worker 
121*0e209d39SAndroid Build Coastguard Worker     /**
122*0e209d39SAndroid Build Coastguard Worker      * Indicates that a value was read from a resource bundle. Provides three
123*0e209d39SAndroid Build Coastguard Worker      * C-style strings to UTraceData: type, file name, and resource path. The
124*0e209d39SAndroid Build Coastguard Worker      * possible types are:
125*0e209d39SAndroid Build Coastguard Worker      *
126*0e209d39SAndroid Build Coastguard Worker      * - "string" (a string value was accessed)
127*0e209d39SAndroid Build Coastguard Worker      * - "binary" (a binary value was accessed)
128*0e209d39SAndroid Build Coastguard Worker      * - "intvector" (a integer vector value was accessed)
129*0e209d39SAndroid Build Coastguard Worker      * - "int" (a signed integer value was accessed)
130*0e209d39SAndroid Build Coastguard Worker      * - "uint" (a unsigned integer value was accessed)
131*0e209d39SAndroid Build Coastguard Worker      * - "get" (a path was loaded, but the value was not accessed)
132*0e209d39SAndroid Build Coastguard Worker      * - "getalias" (a path was loaded, and an alias was resolved)
133*0e209d39SAndroid Build Coastguard Worker      *
134*0e209d39SAndroid Build Coastguard Worker      * @stable ICU 65
135*0e209d39SAndroid Build Coastguard Worker      */
136*0e209d39SAndroid Build Coastguard Worker     UTRACE_UDATA_RESOURCE=UTRACE_UDATA_START,
137*0e209d39SAndroid Build Coastguard Worker 
138*0e209d39SAndroid Build Coastguard Worker     /**
139*0e209d39SAndroid Build Coastguard Worker      * Indicates that a resource bundle was opened.
140*0e209d39SAndroid Build Coastguard Worker      *
141*0e209d39SAndroid Build Coastguard Worker      * Provides one C-style string to UTraceData: file name.
142*0e209d39SAndroid Build Coastguard Worker      * @stable ICU 65
143*0e209d39SAndroid Build Coastguard Worker      */
144*0e209d39SAndroid Build Coastguard Worker     UTRACE_UDATA_BUNDLE,
145*0e209d39SAndroid Build Coastguard Worker 
146*0e209d39SAndroid Build Coastguard Worker     /**
147*0e209d39SAndroid Build Coastguard Worker      * Indicates that a data file was opened, but not *.res files.
148*0e209d39SAndroid Build Coastguard Worker      *
149*0e209d39SAndroid Build Coastguard Worker      * Provides one C-style string to UTraceData: file name.
150*0e209d39SAndroid Build Coastguard Worker      *
151*0e209d39SAndroid Build Coastguard Worker      * @stable ICU 65
152*0e209d39SAndroid Build Coastguard Worker      */
153*0e209d39SAndroid Build Coastguard Worker     UTRACE_UDATA_DATA_FILE,
154*0e209d39SAndroid Build Coastguard Worker 
155*0e209d39SAndroid Build Coastguard Worker     /**
156*0e209d39SAndroid Build Coastguard Worker      * Indicates that a *.res file was opened.
157*0e209d39SAndroid Build Coastguard Worker      *
158*0e209d39SAndroid Build Coastguard Worker      * This differs from UTRACE_UDATA_BUNDLE because a res file is typically
159*0e209d39SAndroid Build Coastguard Worker      * opened only once per application runtime, but the bundle corresponding
160*0e209d39SAndroid Build Coastguard Worker      * to that res file may be opened many times.
161*0e209d39SAndroid Build Coastguard Worker      *
162*0e209d39SAndroid Build Coastguard Worker      * Provides one C-style string to UTraceData: file name.
163*0e209d39SAndroid Build Coastguard Worker      *
164*0e209d39SAndroid Build Coastguard Worker      * @stable ICU 65
165*0e209d39SAndroid Build Coastguard Worker      */
166*0e209d39SAndroid Build Coastguard Worker     UTRACE_UDATA_RES_FILE,
167*0e209d39SAndroid Build Coastguard Worker 
168*0e209d39SAndroid Build Coastguard Worker #ifndef U_HIDE_INTERNAL_API
169*0e209d39SAndroid Build Coastguard Worker     /**
170*0e209d39SAndroid Build Coastguard Worker      * One more than the highest normal resource/data trace location.
171*0e209d39SAndroid Build Coastguard Worker      * @internal The numeric value may change over time, see ICU ticket #12420.
172*0e209d39SAndroid Build Coastguard Worker      */
173*0e209d39SAndroid Build Coastguard Worker     UTRACE_RES_DATA_LIMIT,
174*0e209d39SAndroid Build Coastguard Worker #endif  // U_HIDE_INTERNAL_API
175*0e209d39SAndroid Build Coastguard Worker 
176*0e209d39SAndroid Build Coastguard Worker     /**
177*0e209d39SAndroid Build Coastguard Worker      * The lowest break iterator location.
178*0e209d39SAndroid Build Coastguard Worker      * @stable ICU 67
179*0e209d39SAndroid Build Coastguard Worker      */
180*0e209d39SAndroid Build Coastguard Worker     UTRACE_UBRK_START=0x4000,
181*0e209d39SAndroid Build Coastguard Worker 
182*0e209d39SAndroid Build Coastguard Worker     /**
183*0e209d39SAndroid Build Coastguard Worker      * Indicates that a character instance of break iterator was created.
184*0e209d39SAndroid Build Coastguard Worker      *
185*0e209d39SAndroid Build Coastguard Worker      * @stable ICU 67
186*0e209d39SAndroid Build Coastguard Worker      */
187*0e209d39SAndroid Build Coastguard Worker     UTRACE_UBRK_CREATE_CHARACTER = UTRACE_UBRK_START,
188*0e209d39SAndroid Build Coastguard Worker 
189*0e209d39SAndroid Build Coastguard Worker     /**
190*0e209d39SAndroid Build Coastguard Worker      * Indicates that a word instance of break iterator was created.
191*0e209d39SAndroid Build Coastguard Worker      *
192*0e209d39SAndroid Build Coastguard Worker      * @stable ICU 67
193*0e209d39SAndroid Build Coastguard Worker      */
194*0e209d39SAndroid Build Coastguard Worker     UTRACE_UBRK_CREATE_WORD,
195*0e209d39SAndroid Build Coastguard Worker 
196*0e209d39SAndroid Build Coastguard Worker     /**
197*0e209d39SAndroid Build Coastguard Worker      * Indicates that a line instance of break iterator was created.
198*0e209d39SAndroid Build Coastguard Worker      *
199*0e209d39SAndroid Build Coastguard Worker      * Provides one C-style string to UTraceData: the lb value ("",
200*0e209d39SAndroid Build Coastguard Worker      * "loose", "strict", or "normal").
201*0e209d39SAndroid Build Coastguard Worker      *
202*0e209d39SAndroid Build Coastguard Worker      * @stable ICU 67
203*0e209d39SAndroid Build Coastguard Worker      */
204*0e209d39SAndroid Build Coastguard Worker     UTRACE_UBRK_CREATE_LINE,
205*0e209d39SAndroid Build Coastguard Worker 
206*0e209d39SAndroid Build Coastguard Worker     /**
207*0e209d39SAndroid Build Coastguard Worker      * Indicates that a sentence instance of break iterator was created.
208*0e209d39SAndroid Build Coastguard Worker      *
209*0e209d39SAndroid Build Coastguard Worker      * @stable ICU 67
210*0e209d39SAndroid Build Coastguard Worker      */
211*0e209d39SAndroid Build Coastguard Worker     UTRACE_UBRK_CREATE_SENTENCE,
212*0e209d39SAndroid Build Coastguard Worker 
213*0e209d39SAndroid Build Coastguard Worker     /**
214*0e209d39SAndroid Build Coastguard Worker      * Indicates that a title instance of break iterator was created.
215*0e209d39SAndroid Build Coastguard Worker      *
216*0e209d39SAndroid Build Coastguard Worker      * @stable ICU 67
217*0e209d39SAndroid Build Coastguard Worker      */
218*0e209d39SAndroid Build Coastguard Worker     UTRACE_UBRK_CREATE_TITLE,
219*0e209d39SAndroid Build Coastguard Worker 
220*0e209d39SAndroid Build Coastguard Worker     /**
221*0e209d39SAndroid Build Coastguard Worker      * Indicates that an internal dictionary break engine was created.
222*0e209d39SAndroid Build Coastguard Worker      *
223*0e209d39SAndroid Build Coastguard Worker      * Provides one C-style string to UTraceData: the script code of what
224*0e209d39SAndroid Build Coastguard Worker      * the break engine cover ("Hani", "Khmr", "Laoo", "Mymr", or "Thai").
225*0e209d39SAndroid Build Coastguard Worker      *
226*0e209d39SAndroid Build Coastguard Worker      * @stable ICU 67
227*0e209d39SAndroid Build Coastguard Worker      */
228*0e209d39SAndroid Build Coastguard Worker     UTRACE_UBRK_CREATE_BREAK_ENGINE,
229*0e209d39SAndroid Build Coastguard Worker 
230*0e209d39SAndroid Build Coastguard Worker #ifndef U_HIDE_INTERNAL_API
231*0e209d39SAndroid Build Coastguard Worker     /**
232*0e209d39SAndroid Build Coastguard Worker      * One more than the highest normal break iterator trace location.
233*0e209d39SAndroid Build Coastguard Worker      * @internal The numeric value may change over time, see ICU ticket #12420.
234*0e209d39SAndroid Build Coastguard Worker      */
235*0e209d39SAndroid Build Coastguard Worker     UTRACE_UBRK_LIMIT,
236*0e209d39SAndroid Build Coastguard Worker #endif  // U_HIDE_INTERNAL_API
237*0e209d39SAndroid Build Coastguard Worker 
238*0e209d39SAndroid Build Coastguard Worker } UTraceFunctionNumber;
239*0e209d39SAndroid Build Coastguard Worker 
240*0e209d39SAndroid Build Coastguard Worker /**
241*0e209d39SAndroid Build Coastguard Worker  * Setter for the trace level.
242*0e209d39SAndroid Build Coastguard Worker  * @param traceLevel A UTraceLevel value.
243*0e209d39SAndroid Build Coastguard Worker  * @stable ICU 2.8
244*0e209d39SAndroid Build Coastguard Worker  */
245*0e209d39SAndroid Build Coastguard Worker U_CAPI void U_EXPORT2
246*0e209d39SAndroid Build Coastguard Worker utrace_setLevel(int32_t traceLevel);
247*0e209d39SAndroid Build Coastguard Worker 
248*0e209d39SAndroid Build Coastguard Worker /**
249*0e209d39SAndroid Build Coastguard Worker  * Getter for the trace level.
250*0e209d39SAndroid Build Coastguard Worker  * @return The UTraceLevel value being used by ICU.
251*0e209d39SAndroid Build Coastguard Worker  * @stable ICU 2.8
252*0e209d39SAndroid Build Coastguard Worker  */
253*0e209d39SAndroid Build Coastguard Worker U_CAPI int32_t U_EXPORT2
254*0e209d39SAndroid Build Coastguard Worker utrace_getLevel(void);
255*0e209d39SAndroid Build Coastguard Worker 
256*0e209d39SAndroid Build Coastguard Worker /* Trace function pointers types  ----------------------------- */
257*0e209d39SAndroid Build Coastguard Worker 
258*0e209d39SAndroid Build Coastguard Worker /**
259*0e209d39SAndroid Build Coastguard Worker   *  Type signature for the trace function to be called when entering a function.
260*0e209d39SAndroid Build Coastguard Worker   *  @param context value supplied at the time the trace functions are set.
261*0e209d39SAndroid Build Coastguard Worker   *  @param fnNumber Enum value indicating the ICU function being entered.
262*0e209d39SAndroid Build Coastguard Worker   *  @stable ICU 2.8
263*0e209d39SAndroid Build Coastguard Worker   */
264*0e209d39SAndroid Build Coastguard Worker typedef void U_CALLCONV
265*0e209d39SAndroid Build Coastguard Worker UTraceEntry(const void *context, int32_t fnNumber);
266*0e209d39SAndroid Build Coastguard Worker 
267*0e209d39SAndroid Build Coastguard Worker /**
268*0e209d39SAndroid Build Coastguard Worker   *  Type signature for the trace function to be called when exiting from a function.
269*0e209d39SAndroid Build Coastguard Worker   *  @param context value supplied at the time the trace functions are set.
270*0e209d39SAndroid Build Coastguard Worker   *  @param fnNumber Enum value indicating the ICU function being exited.
271*0e209d39SAndroid Build Coastguard Worker   *  @param fmt     A formatting string that describes the number and types
272*0e209d39SAndroid Build Coastguard Worker   *                 of arguments included with the variable args.  The fmt
273*0e209d39SAndroid Build Coastguard Worker   *                 string has the same form as the utrace_vformat format
274*0e209d39SAndroid Build Coastguard Worker   *                 string.
275*0e209d39SAndroid Build Coastguard Worker   *  @param args    A variable arguments list.  Contents are described by
276*0e209d39SAndroid Build Coastguard Worker   *                 the fmt parameter.
277*0e209d39SAndroid Build Coastguard Worker   *  @see   utrace_vformat
278*0e209d39SAndroid Build Coastguard Worker   *  @stable ICU 2.8
279*0e209d39SAndroid Build Coastguard Worker   */
280*0e209d39SAndroid Build Coastguard Worker typedef void U_CALLCONV
281*0e209d39SAndroid Build Coastguard Worker UTraceExit(const void *context, int32_t fnNumber,
282*0e209d39SAndroid Build Coastguard Worker            const char *fmt, va_list args);
283*0e209d39SAndroid Build Coastguard Worker 
284*0e209d39SAndroid Build Coastguard Worker /**
285*0e209d39SAndroid Build Coastguard Worker   *  Type signature for the trace function to be called from within an ICU function
286*0e209d39SAndroid Build Coastguard Worker   *  to display data or messages.
287*0e209d39SAndroid Build Coastguard Worker   *  @param context  value supplied at the time the trace functions are set.
288*0e209d39SAndroid Build Coastguard Worker   *  @param fnNumber Enum value indicating the ICU function being exited.
289*0e209d39SAndroid Build Coastguard Worker   *  @param level    The current tracing level
290*0e209d39SAndroid Build Coastguard Worker   *  @param fmt      A format string describing the tracing data that is supplied
291*0e209d39SAndroid Build Coastguard Worker   *                  as variable args
292*0e209d39SAndroid Build Coastguard Worker   *  @param args     The data being traced, passed as variable args.
293*0e209d39SAndroid Build Coastguard Worker   *  @stable ICU 2.8
294*0e209d39SAndroid Build Coastguard Worker   */
295*0e209d39SAndroid Build Coastguard Worker typedef void U_CALLCONV
296*0e209d39SAndroid Build Coastguard Worker UTraceData(const void *context, int32_t fnNumber, int32_t level,
297*0e209d39SAndroid Build Coastguard Worker            const char *fmt, va_list args);
298*0e209d39SAndroid Build Coastguard Worker 
299*0e209d39SAndroid Build Coastguard Worker /**
300*0e209d39SAndroid Build Coastguard Worker   *  Set ICU Tracing functions.  Installs application-provided tracing
301*0e209d39SAndroid Build Coastguard Worker   *  functions into ICU.  After doing this, subsequent ICU operations
302*0e209d39SAndroid Build Coastguard Worker   *  will call back to the installed functions, providing a trace
303*0e209d39SAndroid Build Coastguard Worker   *  of the use of ICU.  Passing a NULL pointer for a tracing function
304*0e209d39SAndroid Build Coastguard Worker   *  is allowed, and inhibits tracing action at points where that function
305*0e209d39SAndroid Build Coastguard Worker   *  would be called.
306*0e209d39SAndroid Build Coastguard Worker   *  <p>
307*0e209d39SAndroid Build Coastguard Worker   *  Tracing and Threads:  Tracing functions are global to a process, and
308*0e209d39SAndroid Build Coastguard Worker   *  will be called in response to ICU operations performed by any
309*0e209d39SAndroid Build Coastguard Worker   *  thread.  If tracing of an individual thread is desired, the
310*0e209d39SAndroid Build Coastguard Worker   *  tracing functions must themselves filter by checking that the
311*0e209d39SAndroid Build Coastguard Worker   *  current thread is the desired thread.
312*0e209d39SAndroid Build Coastguard Worker   *
313*0e209d39SAndroid Build Coastguard Worker   *  @param context an uninterpreted pointer.  Whatever is passed in
314*0e209d39SAndroid Build Coastguard Worker   *                 here will in turn be passed to each of the tracing
315*0e209d39SAndroid Build Coastguard Worker   *                 functions UTraceEntry, UTraceExit and UTraceData.
316*0e209d39SAndroid Build Coastguard Worker   *                 ICU does not use or alter this pointer.
317*0e209d39SAndroid Build Coastguard Worker   *  @param e       Callback function to be called on entry to a
318*0e209d39SAndroid Build Coastguard Worker   *                 a traced ICU function.
319*0e209d39SAndroid Build Coastguard Worker   *  @param x       Callback function to be called on exit from a
320*0e209d39SAndroid Build Coastguard Worker   *                 traced ICU function.
321*0e209d39SAndroid Build Coastguard Worker   *  @param d       Callback function to be called from within a
322*0e209d39SAndroid Build Coastguard Worker   *                 traced ICU function, for the purpose of providing
323*0e209d39SAndroid Build Coastguard Worker   *                 data to the trace.
324*0e209d39SAndroid Build Coastguard Worker   *
325*0e209d39SAndroid Build Coastguard Worker   *  @stable ICU 2.8
326*0e209d39SAndroid Build Coastguard Worker   */
327*0e209d39SAndroid Build Coastguard Worker U_CAPI void U_EXPORT2
328*0e209d39SAndroid Build Coastguard Worker utrace_setFunctions(const void *context,
329*0e209d39SAndroid Build Coastguard Worker                     UTraceEntry *e, UTraceExit *x, UTraceData *d);
330*0e209d39SAndroid Build Coastguard Worker 
331*0e209d39SAndroid Build Coastguard Worker /**
332*0e209d39SAndroid Build Coastguard Worker   * Get the currently installed ICU tracing functions.   Note that a null function
333*0e209d39SAndroid Build Coastguard Worker   *   pointer will be returned if no trace function has been set.
334*0e209d39SAndroid Build Coastguard Worker   *
335*0e209d39SAndroid Build Coastguard Worker   * @param context  The currently installed tracing context.
336*0e209d39SAndroid Build Coastguard Worker   * @param e        The currently installed UTraceEntry function.
337*0e209d39SAndroid Build Coastguard Worker   * @param x        The currently installed UTraceExit function.
338*0e209d39SAndroid Build Coastguard Worker   * @param d        The currently installed UTraceData function.
339*0e209d39SAndroid Build Coastguard Worker   * @stable ICU 2.8
340*0e209d39SAndroid Build Coastguard Worker   */
341*0e209d39SAndroid Build Coastguard Worker U_CAPI void U_EXPORT2
342*0e209d39SAndroid Build Coastguard Worker utrace_getFunctions(const void **context,
343*0e209d39SAndroid Build Coastguard Worker                     UTraceEntry **e, UTraceExit **x, UTraceData **d);
344*0e209d39SAndroid Build Coastguard Worker 
345*0e209d39SAndroid Build Coastguard Worker 
346*0e209d39SAndroid Build Coastguard Worker 
347*0e209d39SAndroid Build Coastguard Worker /*
348*0e209d39SAndroid Build Coastguard Worker  *
349*0e209d39SAndroid Build Coastguard Worker  * ICU trace format string syntax
350*0e209d39SAndroid Build Coastguard Worker  *
351*0e209d39SAndroid Build Coastguard Worker  * Format Strings are passed to UTraceData functions, and define the
352*0e209d39SAndroid Build Coastguard Worker  * number and types of the trace data being passed on each call.
353*0e209d39SAndroid Build Coastguard Worker  *
354*0e209d39SAndroid Build Coastguard Worker  * The UTraceData function, which is supplied by the application,
355*0e209d39SAndroid Build Coastguard Worker  * not by ICU, can either forward the trace data (passed via
356*0e209d39SAndroid Build Coastguard Worker  * varargs) and the format string back to ICU for formatting into
357*0e209d39SAndroid Build Coastguard Worker  * a displayable string, or it can interpret the format itself,
358*0e209d39SAndroid Build Coastguard Worker  * and do as it wishes with the trace data.
359*0e209d39SAndroid Build Coastguard Worker  *
360*0e209d39SAndroid Build Coastguard Worker  *
361*0e209d39SAndroid Build Coastguard Worker  * Goals for the format string
362*0e209d39SAndroid Build Coastguard Worker  * - basic data output
363*0e209d39SAndroid Build Coastguard Worker  * - easy to use for trace programmer
364*0e209d39SAndroid Build Coastguard Worker  * - sufficient provision for data types for trace output readability
365*0e209d39SAndroid Build Coastguard Worker  * - well-defined types and binary portable APIs
366*0e209d39SAndroid Build Coastguard Worker  *
367*0e209d39SAndroid Build Coastguard Worker  * Non-goals
368*0e209d39SAndroid Build Coastguard Worker  * - printf compatibility
369*0e209d39SAndroid Build Coastguard Worker  * - fancy formatting
370*0e209d39SAndroid Build Coastguard Worker  * - argument reordering and other internationalization features
371*0e209d39SAndroid Build Coastguard Worker  *
372*0e209d39SAndroid Build Coastguard Worker  * ICU trace format strings contain plain text with argument inserts,
373*0e209d39SAndroid Build Coastguard Worker  * much like standard printf format strings.
374*0e209d39SAndroid Build Coastguard Worker  * Each insert begins with a '%', then optionally contains a 'v',
375*0e209d39SAndroid Build Coastguard Worker  * then exactly one type character.
376*0e209d39SAndroid Build Coastguard Worker  * Two '%' in a row represent a '%' instead of an insert.
377*0e209d39SAndroid Build Coastguard Worker  * The trace format strings need not have \n at the end.
378*0e209d39SAndroid Build Coastguard Worker  *
379*0e209d39SAndroid Build Coastguard Worker  *
380*0e209d39SAndroid Build Coastguard Worker  * Types
381*0e209d39SAndroid Build Coastguard Worker  * -----
382*0e209d39SAndroid Build Coastguard Worker  *
383*0e209d39SAndroid Build Coastguard Worker  * Type characters:
384*0e209d39SAndroid Build Coastguard Worker  * - c A char character in the default codepage.
385*0e209d39SAndroid Build Coastguard Worker  * - s A NUL-terminated char * string in the default codepage.
386*0e209d39SAndroid Build Coastguard Worker  * - S A UChar * string.  Requires two params, (ptr, length).  Length=-1 for nul term.
387*0e209d39SAndroid Build Coastguard Worker  * - b A byte (8-bit integer).
388*0e209d39SAndroid Build Coastguard Worker  * - h A 16-bit integer.  Also a 16 bit Unicode code unit.
389*0e209d39SAndroid Build Coastguard Worker  * - d A 32-bit integer.  Also a 20 bit Unicode code point value.
390*0e209d39SAndroid Build Coastguard Worker  * - l A 64-bit integer.
391*0e209d39SAndroid Build Coastguard Worker  * - p A data pointer.
392*0e209d39SAndroid Build Coastguard Worker  *
393*0e209d39SAndroid Build Coastguard Worker  * Vectors
394*0e209d39SAndroid Build Coastguard Worker  * -------
395*0e209d39SAndroid Build Coastguard Worker  *
396*0e209d39SAndroid Build Coastguard Worker  * If the 'v' is not specified, then one item of the specified type
397*0e209d39SAndroid Build Coastguard Worker  * is passed in.
398*0e209d39SAndroid Build Coastguard Worker  * If the 'v' (for "vector") is specified, then a vector of items of the
399*0e209d39SAndroid Build Coastguard Worker  * specified type is passed in, via a pointer to the first item
400*0e209d39SAndroid Build Coastguard Worker  * and an int32_t value for the length of the vector.
401*0e209d39SAndroid Build Coastguard Worker  * Length==-1 means zero or NUL termination.  Works for vectors of all types.
402*0e209d39SAndroid Build Coastguard Worker  *
403*0e209d39SAndroid Build Coastguard Worker  * Note:  %vS is a vector of (UChar *) strings.  The strings must
404*0e209d39SAndroid Build Coastguard Worker  *        be nul terminated as there is no way to provide a
405*0e209d39SAndroid Build Coastguard Worker  *        separate length parameter for each string.  The length
406*0e209d39SAndroid Build Coastguard Worker  *        parameter (required for all vectors) is the number of
407*0e209d39SAndroid Build Coastguard Worker  *        strings, not the length of the strings.
408*0e209d39SAndroid Build Coastguard Worker  *
409*0e209d39SAndroid Build Coastguard Worker  * Examples
410*0e209d39SAndroid Build Coastguard Worker  * --------
411*0e209d39SAndroid Build Coastguard Worker  *
412*0e209d39SAndroid Build Coastguard Worker  * These examples show the parameters that will be passed to an application's
413*0e209d39SAndroid Build Coastguard Worker  *   UTraceData() function for various formats.
414*0e209d39SAndroid Build Coastguard Worker  *
415*0e209d39SAndroid Build Coastguard Worker  * - the precise formatting is up to the application!
416*0e209d39SAndroid Build Coastguard Worker  * - the examples use type casts for arguments only to _show_ the types of
417*0e209d39SAndroid Build Coastguard Worker  *   arguments without needing variable declarations in the examples;
418*0e209d39SAndroid Build Coastguard Worker  *   the type casts will not be necessary in actual code
419*0e209d39SAndroid Build Coastguard Worker  *
420*0e209d39SAndroid Build Coastguard Worker  * UTraceDataFunc(context, fnNumber, level,
421*0e209d39SAndroid Build Coastguard Worker  *              "There is a character %c in the string %s.",   // Format String
422*0e209d39SAndroid Build Coastguard Worker  *              (char)c, (const char *)s);                     // varargs parameters
423*0e209d39SAndroid Build Coastguard Worker  * ->   There is a character 0x42 'B' in the string "Bravo".
424*0e209d39SAndroid Build Coastguard Worker  *
425*0e209d39SAndroid Build Coastguard Worker  * UTraceDataFunc(context, fnNumber, level,
426*0e209d39SAndroid Build Coastguard Worker  *              "Vector of bytes %vb vector of chars %vc",
427*0e209d39SAndroid Build Coastguard Worker  *              (const uint8_t *)bytes, (int32_t)bytesLength,
428*0e209d39SAndroid Build Coastguard Worker  *              (const char *)chars, (int32_t)charsLength);
429*0e209d39SAndroid Build Coastguard Worker  * ->  Vector of bytes
430*0e209d39SAndroid Build Coastguard Worker  *      42 63 64 3f [4]
431*0e209d39SAndroid Build Coastguard Worker  *     vector of chars
432*0e209d39SAndroid Build Coastguard Worker  *      "Bcd?"[4]
433*0e209d39SAndroid Build Coastguard Worker  *
434*0e209d39SAndroid Build Coastguard Worker  * UTraceDataFunc(context, fnNumber, level,
435*0e209d39SAndroid Build Coastguard Worker  *              "An int32_t %d and a whole bunch of them %vd",
436*0e209d39SAndroid Build Coastguard Worker  *              (int32_t)-5, (const int32_t *)ints, (int32_t)intsLength);
437*0e209d39SAndroid Build Coastguard Worker  * ->   An int32_t 0xfffffffb and a whole bunch of them
438*0e209d39SAndroid Build Coastguard Worker  *      fffffffb 00000005 0000010a [3]
439*0e209d39SAndroid Build Coastguard Worker  *
440*0e209d39SAndroid Build Coastguard Worker  */
441*0e209d39SAndroid Build Coastguard Worker 
442*0e209d39SAndroid Build Coastguard Worker 
443*0e209d39SAndroid Build Coastguard Worker 
444*0e209d39SAndroid Build Coastguard Worker /**
445*0e209d39SAndroid Build Coastguard Worker   *  Trace output Formatter.  An application's UTraceData tracing functions may call
446*0e209d39SAndroid Build Coastguard Worker   *                 back to this function to format the trace output in a
447*0e209d39SAndroid Build Coastguard Worker   *                 human readable form.  Note that a UTraceData function may choose
448*0e209d39SAndroid Build Coastguard Worker   *                 to not format the data;  it could, for example, save it in
449*0e209d39SAndroid Build Coastguard Worker   *                 in the raw form it was received (more compact), leaving
450*0e209d39SAndroid Build Coastguard Worker   *                 formatting for a later trace analysis tool.
451*0e209d39SAndroid Build Coastguard Worker   *  @param outBuf  pointer to a buffer to receive the formatted output.  Output
452*0e209d39SAndroid Build Coastguard Worker   *                 will be nul terminated if there is space in the buffer -
453*0e209d39SAndroid Build Coastguard Worker   *                 if the length of the requested output < the output buffer size.
454*0e209d39SAndroid Build Coastguard Worker   *  @param capacity  Length of the output buffer.
455*0e209d39SAndroid Build Coastguard Worker   *  @param indent  Number of spaces to indent the output.  Intended to allow
456*0e209d39SAndroid Build Coastguard Worker   *                 data displayed from nested functions to be indented for readability.
457*0e209d39SAndroid Build Coastguard Worker   *  @param fmt     Format specification for the data to output
458*0e209d39SAndroid Build Coastguard Worker   *  @param args    Data to be formatted.
459*0e209d39SAndroid Build Coastguard Worker   *  @return        Length of formatted output, including the terminating NUL.
460*0e209d39SAndroid Build Coastguard Worker   *                 If buffer capacity is insufficient, the required capacity is returned.
461*0e209d39SAndroid Build Coastguard Worker   *  @stable ICU 2.8
462*0e209d39SAndroid Build Coastguard Worker   */
463*0e209d39SAndroid Build Coastguard Worker U_CAPI int32_t U_EXPORT2
464*0e209d39SAndroid Build Coastguard Worker utrace_vformat(char *outBuf, int32_t capacity,
465*0e209d39SAndroid Build Coastguard Worker               int32_t indent, const char *fmt,  va_list args);
466*0e209d39SAndroid Build Coastguard Worker 
467*0e209d39SAndroid Build Coastguard Worker /**
468*0e209d39SAndroid Build Coastguard Worker   *  Trace output Formatter.  An application's UTraceData tracing functions may call
469*0e209d39SAndroid Build Coastguard Worker   *                 this function to format any additional trace data, beyond that
470*0e209d39SAndroid Build Coastguard Worker   *                 provided by default, in human readable form with the same
471*0e209d39SAndroid Build Coastguard Worker   *                 formatting conventions used by utrace_vformat().
472*0e209d39SAndroid Build Coastguard Worker   *  @param outBuf  pointer to a buffer to receive the formatted output.  Output
473*0e209d39SAndroid Build Coastguard Worker   *                 will be nul terminated if there is space in the buffer -
474*0e209d39SAndroid Build Coastguard Worker   *                 if the length of the requested output < the output buffer size.
475*0e209d39SAndroid Build Coastguard Worker   *  @param capacity  Length of the output buffer.
476*0e209d39SAndroid Build Coastguard Worker   *  @param indent  Number of spaces to indent the output.  Intended to allow
477*0e209d39SAndroid Build Coastguard Worker   *                 data displayed from nested functions to be indented for readability.
478*0e209d39SAndroid Build Coastguard Worker   *  @param fmt     Format specification for the data to output
479*0e209d39SAndroid Build Coastguard Worker   *  @param ...     Data to be formatted.
480*0e209d39SAndroid Build Coastguard Worker   *  @return        Length of formatted output, including the terminating NUL.
481*0e209d39SAndroid Build Coastguard Worker   *                 If buffer capacity is insufficient, the required capacity is returned.
482*0e209d39SAndroid Build Coastguard Worker   *  @stable ICU 2.8
483*0e209d39SAndroid Build Coastguard Worker   */
484*0e209d39SAndroid Build Coastguard Worker U_CAPI int32_t U_EXPORT2
485*0e209d39SAndroid Build Coastguard Worker utrace_format(char *outBuf, int32_t capacity,
486*0e209d39SAndroid Build Coastguard Worker               int32_t indent, const char *fmt,  ...);
487*0e209d39SAndroid Build Coastguard Worker 
488*0e209d39SAndroid Build Coastguard Worker 
489*0e209d39SAndroid Build Coastguard Worker 
490*0e209d39SAndroid Build Coastguard Worker /* Trace function numbers --------------------------------------------------- */
491*0e209d39SAndroid Build Coastguard Worker 
492*0e209d39SAndroid Build Coastguard Worker /**
493*0e209d39SAndroid Build Coastguard Worker  * Get the name of a function from its trace function number.
494*0e209d39SAndroid Build Coastguard Worker  *
495*0e209d39SAndroid Build Coastguard Worker  * @param fnNumber The trace number for an ICU function.
496*0e209d39SAndroid Build Coastguard Worker  * @return The name string for the function.
497*0e209d39SAndroid Build Coastguard Worker  *
498*0e209d39SAndroid Build Coastguard Worker  * @see UTraceFunctionNumber
499*0e209d39SAndroid Build Coastguard Worker  * @stable ICU 2.8
500*0e209d39SAndroid Build Coastguard Worker  */
501*0e209d39SAndroid Build Coastguard Worker U_CAPI const char * U_EXPORT2
502*0e209d39SAndroid Build Coastguard Worker utrace_functionName(int32_t fnNumber);
503*0e209d39SAndroid Build Coastguard Worker 
504*0e209d39SAndroid Build Coastguard Worker U_CDECL_END
505*0e209d39SAndroid Build Coastguard Worker 
506*0e209d39SAndroid Build Coastguard Worker #endif
507