1 .\"***************************************************************************
2 .\" Copyright 2019,2020 Thomas E. Dickey *
3 .\" Copyright 2000-2016,2017 Free Software Foundation, Inc. *
5 .\" Permission is hereby granted, free of charge, to any person obtaining a *
6 .\" copy of this software and associated documentation files (the *
7 .\" "Software"), to deal in the Software without restriction, including *
8 .\" without limitation the rights to use, copy, modify, merge, publish, *
9 .\" distribute, distribute with modifications, sublicense, and/or sell *
10 .\" copies of the Software, and to permit persons to whom the Software is *
11 .\" furnished to do so, subject to the following conditions: *
13 .\" The above copyright notice and this permission notice shall be included *
14 .\" in all copies or substantial portions of the Software. *
16 .\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
17 .\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
18 .\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
19 .\" IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
20 .\" DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
21 .\" OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
22 .\" THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
24 .\" Except as contained in this notice, the name(s) of the above copyright *
25 .\" holders shall not be used in advertising or otherwise to promote the *
26 .\" sale, use or other dealings in this Software without prior written *
28 .\"***************************************************************************
30 .\" $Id: curs_trace.3x,v 1.21 2020/02/02 23:34:34 tom Exp $
55 \fB_tracemouse\fR \- \fBcurses\fR debugging routines
59 \fB#include <curses.h>\fR
61 \fBunsigned curses_trace(const unsigned \fP\fIparam\fP\fB);\fR
63 \fBvoid _tracef(const char *\fP\fIformat\fP\fB, ...);\fR
65 \fBchar *_traceattr(attr_t \fP\fIattr\fP\fB);\fR
67 \fBchar *_traceattr2(int \fP\fIbuffer\fP\fB, chtype \fP\fIch\fP\fB);\fR
69 \fBchar *_tracecchar_t(const cchar_t *\fP\fIstring\fP\fB);\fR
71 \fBchar *_tracecchar_t2(int \fP\fIbuffer\fP\fB, const cchar_t *\fP\fIstring\fP\fB);\fR
73 \fBchar *_tracechar(int \fP\fIch\fP\fB);\fR
75 \fBchar *_tracechtype(chtype \fP\fIch\fP\fB);\fR
77 \fBchar *_tracechtype2(int \fP\fIbuffer\fP\fB, chtype \fP\fIch\fP\fB);\fR
79 \fBvoid _tracedump(const char *\fP\fIlabel\fP\fB, WINDOW *\fP\fIwin\fP\fB);\fR
81 \fBchar *_nc_tracebits(void);\fR
83 \fBchar *_tracemouse(const MEVENT *\fP\fIevent\fP\fB);\fR
87 \fBvoid trace(const unsigned int \fP\fIparam\fP\fB);\fR
89 The \fIcurses trace\fR routines are used for debugging the ncurses libraries,
90 as well as applications which use the ncurses libraries.
91 Some limitations apply:
93 Aside from \fBcurses_trace\fP,
94 the other functions are normally available only with the debugging library
95 e.g., \fIlibncurses_g.a\fR.
97 All of the trace functions may be compiled into any model (shared, static,
98 profile) by defining the symbol \fBTRACE\fR.
100 Additionally, the functions which use \fBcchar_t\fP
101 are only available with the wide-character configuration of the libraries.
103 The principal parts of this interface are
105 \fBcurses_trace\fR, which selectively enables different tracing features, and
107 \fB_tracef\fR, which writes formatted data to the \fItrace\fR file.
109 The other functions either return a pointer to a string-area
110 (allocated by the corresponding function), or return no value
111 (such as \fB_tracedump\fP,
112 which implements the screen dump for \fBTRACE_UPDATE\fP).
113 The caller should not free these strings,
114 since the allocation is reused on successive calls.
115 To work around the problem of a single string-area per function,
116 some use a buffer-number parameter, telling the library to allocate
117 additional string-areas.
119 The \fBcurses_trace\fR function is always available,
120 whether or not the other trace functions are available:
122 If tracing is available,
123 calling \fBcurses_trace\fR with a nonzero parameter
124 updates the trace mask,
125 and returns the previous trace mask.
127 When the trace mask is nonzero,
128 ncurses creates the file \*(``trace\*('' in the current directory for output.
129 If the file already exists, no tracing is done.
131 If tracing is not available, \fBcurses_trace\fP returns zero (0).
133 The trace parameter is formed by OR'ing
134 values from the list of \fBTRACE_\fP\fIxxx\fR definitions in \fB<curses.h>\fR.
138 turn off tracing by passing a zero parameter.
140 The library flushes the output file,
141 but retains an open file-descriptor to the trace file
142 so that it can resume tracing later if a nonzero parameter is passed
143 to the \fBcurses_trace\fP function.
146 trace user and system times of updates.
149 trace \fBtputs\fP(3X) calls.
152 trace update actions, old & new screens.
155 trace cursor movement and scrolling.
158 trace all character outputs.
161 trace all update actions.
162 The old and new screen contents are written to the trace file
166 trace all curses calls.
167 The parameters for each call are traced, as well as return values.
170 trace virtual character puts, i.e., calls to \fBaddch\fR.
173 trace low-level input processing, including timeouts.
176 trace state of TTY control bits.
179 trace internal/nested calls.
182 trace per-character calls.
185 trace read/write of terminfo/termcap data.
188 trace changes to video attributes and colors.
191 maximum trace level, enables all of the separate trace features.
193 Some tracing features are enabled whenever the \fBcurses_trace\fR parameter
195 Some features overlap.
196 The specific names are used as a guideline.
198 These functions check the \fBNCURSES_TRACE\fP environment variable,
199 to set the tracing feature as if \fBcurses_trace\fP was called:
220 .SS Command-line Utilities
222 The command-line utilities such as \fBtic\fP(1) provide a verbose option
223 which extends the set of messages written using the \fBcurses_trace\fP function.
224 Both of these (\fB\-v\fP and \fBcurses_trace\fP)
225 use the same variable (\fB_nc_tracing\fP),
226 which determines the messages which are written.
228 Because the command-line utilities may call initialization functions
229 such as \fBsetupterm\fP, \fBtgetent\fP or \fBuse_extended_names\fP,
230 some of their debugging output may be directed to the \fItrace\fP file
231 if the \fBNCURSES_TRACE\fP environment variable is set:
233 messages produced in the utility are written to the standard error.
235 messages produced by the underlying library are written to \fItrace\fP.
237 If ncurses is built without tracing, none of the latter are produced,
238 and fewer diagnostics are provided by the command-line utilities.
240 Routines which return a value are designed to be used as parameters
241 to the \fB_tracef\fR routine.
243 These functions are not part of the XSI interface.
244 Some other curses implementations are known to
245 have similar features,
246 but they are not compatible with ncurses:
248 SVr4 provided \fBtraceon\fP and \fBtraceoff\fP,
249 to control whether debugging information was written
250 to the \*(``trace\*('' file.
251 While the functions were always available,
252 this feature was only enabled
253 if \fBDEBUG\fP was defined when building the library.
255 The SVr4 tracing feature is undocumented.
257 PDCurses provides \fBtraceon\fP and \fBtraceoff\fP,
258 which (like SVr4) are always available,
260 to the \*(``trace\*('' file
261 only when a debug-library is built.
263 PDCurses has a short description of these functions,
264 with a note that they are not present in X/Open Curses,
266 It does not mention SVr4,
267 but the functions' inclusion in a header file section
268 labeled \*(``Quasi-standard\*('' hints at the origin.
270 NetBSD does not provide functions for enabling/disabling traces.
271 It uses environment variables
272 \fBCURSES_TRACE_MASK\fP and
273 \fBCURSES_TRACE_FILE\fP to determine what is traced,
274 and where the results are written.
275 This is available only when a debug-library is built.
277 The NetBSD tracing feature is undocumented.
279 A few ncurses functions are not provided when symbol versioning is used:
287 The original \fBtrace\fP routine was deprecated because
288 it often conflicted with application names.