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