]> ncurses.scripts.mit.edu Git - ncurses.git/blob - man/curs_trace.3x
ncurses 6.2 - patch 20201212
[ncurses.git] / man / curs_trace.3x
1 .\"***************************************************************************
2 .\" Copyright 2019,2020 Thomas E. Dickey                                     *
3 .\" Copyright 2000-2016,2017 Free Software Foundation, Inc.                  *
4 .\"                                                                          *
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:                 *
12 .\"                                                                          *
13 .\" The above copyright notice and this permission notice shall be included  *
14 .\" in all copies or substantial portions of the Software.                   *
15 .\"                                                                          *
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.                               *
23 .\"                                                                          *
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       *
27 .\" authorization.                                                           *
28 .\"***************************************************************************
29 .\"
30 .\" $Id: curs_trace.3x,v 1.21 2020/02/02 23:34:34 tom Exp $
31 .ie \n(.g .ds `` \(lq
32 .el       .ds `` ``
33 .ie \n(.g .ds '' \(rq
34 .el       .ds '' ''
35 .de bP
36 .ie n  .IP \(bu 4
37 .el    .IP \(bu 2
38 ..
39 .TH curs_trace 3X ""
40 .na
41 .hy 0
42 .SH NAME
43 \fBcurses_trace\fR,
44 \fBtrace\fR,
45 \fB_tracef\fR,
46 \fB_traceattr\fR,
47 \fB_traceattr2\fR,
48 \fB_tracecchar_t\fR,
49 \fB_tracecchar_t2\fR,
50 \fB_tracechar\fR,
51 \fB_tracechtype\fR,
52 \fB_tracechtype2\fR,
53 \fB_nc_tracebits\fR,
54 \fB_tracedump\fR,
55 \fB_tracemouse\fR \- \fBcurses\fR debugging routines
56 .ad
57 .hy
58 .SH SYNOPSIS
59 \fB#include <curses.h>\fR
60 .sp
61 \fBunsigned curses_trace(const unsigned \fP\fIparam\fP\fB);\fR
62 .sp
63 \fBvoid _tracef(const char *\fP\fIformat\fP\fB, ...);\fR
64 .sp
65 \fBchar *_traceattr(attr_t \fP\fIattr\fP\fB);\fR
66 .br
67 \fBchar *_traceattr2(int \fP\fIbuffer\fP\fB, chtype \fP\fIch\fP\fB);\fR
68 .br
69 \fBchar *_tracecchar_t(const cchar_t *\fP\fIstring\fP\fB);\fR
70 .br
71 \fBchar *_tracecchar_t2(int \fP\fIbuffer\fP\fB, const cchar_t *\fP\fIstring\fP\fB);\fR
72 .br
73 \fBchar *_tracechar(int \fP\fIch\fP\fB);\fR
74 .br
75 \fBchar *_tracechtype(chtype \fP\fIch\fP\fB);\fR
76 .br
77 \fBchar *_tracechtype2(int \fP\fIbuffer\fP\fB, chtype \fP\fIch\fP\fB);\fR
78 .sp
79 \fBvoid _tracedump(const char *\fP\fIlabel\fP\fB, WINDOW *\fP\fIwin\fP\fB);\fR
80 .br
81 \fBchar *_nc_tracebits(void);\fR
82 .br
83 \fBchar *_tracemouse(const MEVENT *\fP\fIevent\fP\fB);\fR
84 .sp
85 /* deprecated */
86 .br
87 \fBvoid trace(const unsigned int \fP\fIparam\fP\fB);\fR
88 .SH DESCRIPTION
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:
92 .bP
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.
96 .IP
97 All of the trace functions may be compiled into any model (shared, static,
98 profile) by defining the symbol \fBTRACE\fR.
99 .bP
100 Additionally, the functions which use \fBcchar_t\fP
101 are only available with the wide-character configuration of the libraries.
102 .SS Functions
103 The principal parts of this interface are
104 .bP
105 \fBcurses_trace\fR, which selectively enables different tracing features, and
106 .bP
107 \fB_tracef\fR, which writes formatted data to the \fItrace\fR file.
108 .IP
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.
118 .PP
119 The \fBcurses_trace\fR function is always available,
120 whether or not the other trace functions are available:
121 .bP
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.
126 .IP
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.
130 .bP
131 If tracing is not available, \fBcurses_trace\fP returns zero (0).
132 .SS Trace Parameter
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.
135 These include:
136 .TP 5
137 .B TRACE_DISABLE
138 turn off tracing by passing a zero parameter.
139 .IP
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.
144 .TP 5
145 .B TRACE_TIMES
146 trace user and system times of updates.
147 .TP 5
148 .B TRACE_TPUTS
149 trace \fBtputs\fP(3X) calls.
150 .TP 5
151 .B TRACE_UPDATE
152 trace update actions, old & new screens.
153 .TP 5
154 .B TRACE_MOVE
155 trace cursor movement and scrolling.
156 .TP 5
157 .B TRACE_CHARPUT
158 trace all character outputs.
159 .TP 5
160 .B TRACE_ORDINARY
161 trace all update actions.
162 The old and new screen contents are written to the trace file
163 for each refresh.
164 .TP 5
165 .B TRACE_CALLS
166 trace all curses calls.
167 The parameters for each call are traced, as well as return values.
168 .TP 5
169 .B TRACE_VIRTPUT
170 trace virtual character puts, i.e., calls to \fBaddch\fR.
171 .TP 5
172 .B TRACE_IEVENT
173 trace low-level input processing, including timeouts.
174 .TP 5
175 .B TRACE_BITS
176 trace state of TTY control bits.
177 .TP 5
178 .B TRACE_ICALLS
179 trace internal/nested calls.
180 .TP 5
181 .B TRACE_CCALLS
182 trace per-character calls.
183 .TP 5
184 .B TRACE_DATABASE
185 trace read/write of terminfo/termcap data.
186 .TP 5
187 .B TRACE_ATTRS
188 trace changes to video attributes and colors.
189 .TP 5
190 .B TRACE_MAXIMUM
191 maximum trace level, enables all of the separate trace features.
192 .PP
193 Some tracing features are enabled whenever the \fBcurses_trace\fR parameter
194 is nonzero.
195 Some features overlap.
196 The specific names are used as a guideline.
197 .SS Initialization
198 These functions check the \fBNCURSES_TRACE\fP environment variable,
199 to set the tracing feature as if \fBcurses_trace\fP was called:
200 .RS 4
201 .PP
202 .na
203 .hy 0
204 filter,
205 initscr,
206 new_prescr,
207 newterm,
208 nofilter,
209 restartterm,
210 ripoffline,
211 setupterm,
212 slk_init,
213 tgetent,
214 use_env,
215 use_extended_names,
216 use_tioctl
217 .hy
218 .ad
219 .RE
220 .SS Command-line Utilities
221 .PP
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.
227 .PP
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:
232 .bP
233 messages produced in the utility are written to the standard error.
234 .bP
235 messages produced by the underlying library are written to \fItrace\fP.
236 .PP
237 If ncurses is built without tracing, none of the latter are produced,
238 and fewer diagnostics are provided by the command-line utilities.
239 .SH RETURN VALUE
240 Routines which return a value are designed to be used as parameters
241 to the \fB_tracef\fR routine.
242 .SH PORTABILITY
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:
247 .bP
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.
254 .IP
255 The SVr4 tracing feature is undocumented.
256 .bP
257 PDCurses provides \fBtraceon\fP and \fBtraceoff\fP,
258 which (like SVr4) are always available,
259 and enable tracing
260 to the \*(``trace\*('' file
261 only when a debug-library is built.
262 .IP
263 PDCurses has a short description of these functions,
264 with a note that they are not present in X/Open Curses,
265 ncurses or NetBSD.
266 It does not mention SVr4,
267 but the functions' inclusion in a header file section
268 labeled \*(``Quasi-standard\*('' hints at the origin.
269 .bP
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.
276 .IP
277 The NetBSD tracing feature is undocumented.
278 .PP
279 A few ncurses functions are not provided when symbol versioning is used:
280 .RS 4
281 .PP
282 _nc_tracebits,
283 _tracedump,
284 _tracemouse
285 .RE
286 .PP
287 The original \fBtrace\fP routine was deprecated because
288 it often conflicted with application names.
289 .SH SEE ALSO
290 \fBcurses\fR(3X).