1 .\"***************************************************************************
2 .\" Copyright (c) 2000-2017,2019 Free Software Foundation, Inc. *
4 .\" Permission is hereby granted, free of charge, to any person obtaining a *
5 .\" copy of this software and associated documentation files (the *
6 .\" "Software"), to deal in the Software without restriction, including *
7 .\" without limitation the rights to use, copy, modify, merge, publish, *
8 .\" distribute, distribute with modifications, sublicense, and/or sell *
9 .\" copies of the Software, and to permit persons to whom the Software is *
10 .\" furnished to do so, subject to the following conditions: *
12 .\" The above copyright notice and this permission notice shall be included *
13 .\" in all copies or substantial portions of the Software. *
15 .\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
16 .\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
17 .\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
18 .\" IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
19 .\" DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
20 .\" OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
21 .\" THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
23 .\" Except as contained in this notice, the name(s) of the above copyright *
24 .\" holders shall not be used in advertising or otherwise to promote the *
25 .\" sale, use or other dealings in this Software without prior written *
27 .\"***************************************************************************
29 .\" $Id: curs_trace.3x,v 1.20 2019/12/07 18:55:02 tom Exp $
54 \fB_tracemouse\fR \- \fBcurses\fR debugging routines
58 \fB#include <curses.h>\fR
60 \fBunsigned curses_trace(const unsigned \fP\fIparam\fP\fB);\fR
62 \fBvoid _tracef(const char *\fP\fIformat\fP\fB, ...);\fR
64 \fBchar *_traceattr(attr_t \fP\fIattr\fP\fB);\fR
66 \fBchar *_traceattr2(int \fP\fIbuffer\fP\fB, chtype \fP\fIch\fP\fB);\fR
68 \fBchar *_tracecchar_t(const cchar_t *\fP\fIstring\fP\fB);\fR
70 \fBchar *_tracecchar_t2(int \fP\fIbuffer\fP\fB, const cchar_t *\fP\fIstring\fP\fB);\fR
72 \fBchar *_tracechar(int \fP\fIch\fP\fB);\fR
74 \fBchar *_tracechtype(chtype \fP\fIch\fP\fB);\fR
76 \fBchar *_tracechtype2(int \fP\fIbuffer\fP\fB, chtype \fP\fIch\fP\fB);\fR
78 \fBvoid _tracedump(const char *\fP\fIlabel\fP\fB, WINDOW *\fP\fIwin\fP\fB);\fR
80 \fBchar *_nc_tracebits(void);\fR
82 \fBchar *_tracemouse(const MEVENT *\fP\fIevent\fP\fB);\fR
86 \fBvoid trace(const unsigned int \fP\fIparam\fP\fB);\fR
88 The \fIcurses trace\fR routines are used for debugging the ncurses libraries,
89 as well as applications which use the ncurses libraries.
90 Some limitations apply:
92 Aside from \fBcurses_trace\fP,
93 the other functions are normally available only with the debugging library
94 e.g., \fIlibncurses_g.a\fR.
96 All of the trace functions may be compiled into any model (shared, static,
97 profile) by defining the symbol \fBTRACE\fR.
99 Additionally, the functions which use \fBcchar_t\fP
100 are only available with the wide-character configuration of the libraries.
102 The principal parts of this interface are
104 \fBcurses_trace\fR, which selectively enables different tracing features, and
106 \fB_tracef\fR, which writes formatted data to the \fItrace\fR file.
108 The other functions either return a pointer to a string-area
109 (allocated by the corresponding function), or return no value
110 (such as \fB_tracedump\fP,
111 which implements the screen dump for \fBTRACE_UPDATE\fP).
112 The caller should not free these strings,
113 since the allocation is reused on successive calls.
114 To work around the problem of a single string-area per function,
115 some use a buffer-number parameter, telling the library to allocate
116 additional string-areas.
118 The \fBcurses_trace\fR function is always available,
119 whether or not the other trace functions are available:
121 If tracing is available,
122 calling \fBcurses_trace\fR with a nonzero parameter
123 updates the trace mask,
124 and returns the previous trace mask.
126 When the trace mask is nonzero,
127 ncurses creates the file \*(``trace\*('' in the current directory for output.
128 If the file already exists, no tracing is done.
130 If tracing is not available, \fBcurses_trace\fP returns zero (0).
132 The trace parameter is formed by OR'ing
133 values from the list of \fBTRACE_\fP\fIxxx\fR definitions in \fB<curses.h>\fR.
137 turn off tracing by passing a zero parameter.
139 The library flushes the output file,
140 but retains an open file-descriptor to the trace file
141 so that it can resume tracing later if a nonzero parameter is passed
142 to the \fBcurses_trace\fP function.
145 trace user and system times of updates.
148 trace \fBtputs\fP(3X) calls.
151 trace update actions, old & new screens.
154 trace cursor movement and scrolling.
157 trace all character outputs.
160 trace all update actions.
161 The old and new screen contents are written to the trace file
165 trace all curses calls.
166 The parameters for each call are traced, as well as return values.
169 trace virtual character puts, i.e., calls to \fBaddch\fR.
172 trace low-level input processing, including timeouts.
175 trace state of TTY control bits.
178 trace internal/nested calls.
181 trace per-character calls.
184 trace read/write of terminfo/termcap data.
187 trace changes to video attributes and colors.
190 maximum trace level, enables all of the separate trace features.
192 Some tracing features are enabled whenever the \fBcurses_trace\fR parameter
194 Some features overlap.
195 The specific names are used as a guideline.
197 These functions check the \fBNCURSES_TRACE\fP environment variable,
198 to set the tracing feature as if \fBcurses_trace\fP was called:
219 .SS Command-line Utilities
221 The command-line utilities such as \fBtic\fP(1) provide a verbose option
222 which extends the set of messages written using the \fBcurses_trace\fP function.
223 Both of these (\fB\-v\fP and \fBcurses_trace\fP)
224 use the same variable (\fB_nc_tracing\fP),
225 which determines the messages which are written.
227 Because the command-line utilities may call initialization functions
228 such as \fBsetupterm\fP, \fBtgetent\fP or \fBuse_extended_names\fP,
229 some of their debugging output may be directed to the \fItrace\fP file
230 if the \fBNCURSES_TRACE\fP environment variable is set:
232 messages produced in the utility are written to the standard error.
234 messages produced by the underlying library are written to \fItrace\fP.
236 If ncurses is built without tracing, none of the latter are produced,
237 and fewer diagnostics are provided by the command-line utilities.
239 Routines which return a value are designed to be used as parameters
240 to the \fB_tracef\fR routine.
242 These functions are not part of the XSI interface.
243 Some other curses implementations are known to
244 have similar features,
245 but they are not compatible with ncurses:
247 SVr4 provided \fBtraceon\fP and \fBtraceoff\fP,
248 to control whether debugging information was written
249 to the \*(``trace\*('' file.
250 While the functions were always available,
251 this feature was only enabled
252 if \fBDEBUG\fP was defined when building the library.
254 The SVr4 tracing feature is undocumented.
256 PDCurses provides \fBtraceon\fP and \fBtraceoff\fP,
257 which (like SVr4) are always available,
259 to the \*(``trace\*('' file
260 only when a debug-library is built.
262 PDCurses has a short description of these functions,
263 with a note that they are not present in X/Open Curses,
265 It does not mention SVr4,
266 but the functions' inclusion in a header file section
267 labeled \*(``Quasi-standard\*('' hints at the origin.
269 NetBSD does not provide functions for enabling/disabling traces.
270 It uses environment variables
271 \fBCURSES_TRACE_MASK\fP and
272 \fBCURSES_TRACE_FILE\fP to determine what is traced,
273 and where the results are written.
274 This is available only when a debug-library is built.
276 The NetBSD tracing feature is undocumented.
278 A few ncurses functions are not provided when symbol versioning is used:
286 The original \fBtrace\fP routine was deprecated because
287 it often conflicted with application names.