]> ncurses.scripts.mit.edu Git - ncurses.git/blob - man/curs_trace.3x
ncurses 6.4 - patch 20231223
[ncurses.git] / man / curs_trace.3x
1 .\"***************************************************************************
2 .\" Copyright 2019-2022,2023 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.42 2023/12/23 16:08:25 tom Exp $
31 .TH curs_trace 3X 2023-12-23 "ncurses 6.4" "Library calls"
32 .ie \n(.g \{\
33 .ds `` \(lq
34 .ds '' \(rq
35 .\}
36 .el \{\
37 .ie t .ds `` ``
38 .el   .ds `` ""
39 .ie t .ds '' ''
40 .el   .ds '' ""
41 .\}
42 .
43 .de bP
44 .ie n  .IP \(bu 4
45 .el    .IP \(bu 2
46 ..
47 .SH NAME
48 \fB\%curses_trace\fP,
49 \fB\%trace\fP,
50 \fB\%_tracef\fP,
51 \fB\%_traceattr\fP,
52 \fB\%_traceattr2\fP,
53 \fB\%_tracecchar_t\fP,
54 \fB\%_tracecchar_t2\fP,
55 \fB\%_tracechar\fP,
56 \fB\%_tracechtype\fP,
57 \fB\%_tracechtype2\fP,
58 \fB\%_nc_tracebits\fP,
59 \fB\%_tracedump\fP,
60 \fB\%_tracemouse\fP \-
61 \fIcurses\fR debugging routines
62 .SH SYNOPSIS
63 .nf
64 \fB#include <curses.h>
65 .PP
66 \fBunsigned curses_trace(const unsigned \fIparam\fP);
67 .PP
68 \fBvoid _tracef(const char *\fIformat\fP, ...);
69 .PP
70 \fBchar *_traceattr(attr_t \fIattr\fP);
71 \fBchar *_traceattr2(int \fIbuffer\fP, chtype \fIch\fP);
72 \fBchar *_tracecchar_t(const cchar_t *\fIstring\fP);
73 \fBchar *_tracecchar_t2(int \fIbuffer\fP, const cchar_t *\fIstring\fP);
74 \fBchar *_tracechar(int \fIch\fP);
75 \fBchar *_tracechtype(chtype \fIch\fP);
76 \fBchar *_tracechtype2(int \fIbuffer\fP, chtype \fIch\fP);
77 .PP
78 \fBvoid _tracedump(const char *\fIlabel\fP, WINDOW *\fIwin\fP);
79 \fBchar *_nc_tracebits(void);
80 \fBchar *_tracemouse(const MEVENT *\fIevent\fP);
81 .PP
82 \fI/* deprecated */\fP
83 \fBvoid trace(const unsigned int \fIparam\fP);
84 .fi
85 .SH DESCRIPTION
86 The \fIcurses trace\fP routines are used for debugging the
87 \fI\%ncurses\fP libraries,
88 as well as applications which use the \fI\%ncurses\fP libraries.
89 Some limitations apply:
90 .bP
91 Aside from \fBcurses_trace\fP,
92 the other functions are normally available only with the debugging library
93 e.g., \fBlibncurses_g.a\fP.
94 .IP
95 All of the trace functions may be compiled into any model (shared, static,
96 profile) by defining the symbol \fBTRACE\fP.
97 .bP
98 Additionally, the functions which use \fBcchar_t\fP
99 are only available with the wide-character configuration of the libraries.
100 .SS Functions
101 The principal parts of this interface are
102 .bP
103 \fBcurses_trace\fP, which selectively enables different tracing features, and
104 .bP
105 \fB_tracef\fP, which writes formatted data to the \fItrace\fP file.
106 .IP
107 The other functions either return a pointer to a string-area
108 (allocated by the corresponding function), or return no value
109 (such as \fB_tracedump\fP,
110 which implements the screen dump for \fBTRACE_UPDATE\fP).
111 The caller should not free these strings,
112 since the allocation is reused on successive calls.
113 To work around the problem of a single string-area per function,
114 some use a buffer-number parameter, telling the library to allocate
115 additional string-areas.
116 .PP
117 The \fBcurses_trace\fP function is always available,
118 whether or not the other trace functions are available:
119 .bP
120 If tracing is available,
121 calling \fBcurses_trace\fP with a nonzero parameter
122 updates the trace mask,
123 and returns the previous trace mask.
124 .IP
125 When the trace mask is nonzero,
126 \fI\%ncurses\fP creates the file \*(``trace\*('' in the current directory for output.
127 If the file already exists, no tracing is done.
128 .bP
129 If tracing is not available, \fBcurses_trace\fP returns zero (0).
130 .SS "Trace Parameter"
131 The trace parameter is formed by OR'ing
132 values from the list of \fBTRACE_\fIxxx\fR definitions in \fB<curses.h>\fR.
133 These include:
134 .TP 5
135 .B TRACE_DISABLE
136 turn off tracing by passing a zero parameter.
137 .IP
138 The library flushes the output file,
139 but retains an open file-descriptor to the trace file
140 so that it can resume tracing later if a nonzero parameter is passed
141 to the \fBcurses_trace\fP function.
142 .TP 5
143 .B TRACE_TIMES
144 trace user and system times of updates.
145 .TP 5
146 .B TRACE_TPUTS
147 trace \fBtputs\fP(3X) calls.
148 .TP 5
149 .B TRACE_UPDATE
150 trace update actions, old & new screens.
151 .TP 5
152 .B TRACE_MOVE
153 trace cursor movement and scrolling.
154 .TP 5
155 .B TRACE_CHARPUT
156 trace all character outputs.
157 .TP 5
158 .B TRACE_ORDINARY
159 trace all update actions.
160 The old and new screen contents are written to the trace file
161 for each refresh.
162 .TP 5
163 .B TRACE_CALLS
164 trace all curses calls.
165 The parameters for each call are traced, as well as return values.
166 .TP 5
167 .B TRACE_VIRTPUT
168 trace virtual character puts, i.e., calls to \fBaddch\fP.
169 .TP 5
170 .B TRACE_IEVENT
171 trace low-level input processing, including timeouts.
172 .TP 5
173 .B TRACE_BITS
174 trace state of TTY control bits.
175 .TP 5
176 .B TRACE_ICALLS
177 trace internal/nested calls.
178 .TP 5
179 .B TRACE_CCALLS
180 trace per-character calls.
181 .TP 5
182 .B TRACE_DATABASE
183 trace read/write of terminfo/termcap data.
184 .TP 5
185 .B TRACE_ATTRS
186 trace changes to video attributes and colors.
187 .TP 5
188 .B TRACE_MAXIMUM
189 maximum trace level, enables all of the separate trace features.
190 .PP
191 Some tracing features are enabled whenever the \fBcurses_trace\fP parameter
192 is nonzero.
193 Some features overlap.
194 The specific names are used as a guideline.
195 .SS Initialization
196 These functions check the \fI\%NCURSES_TRACE\fP environment variable,
197 to set the tracing feature as if \fBcurses_trace\fP was called:
198 .RS 4
199 .PP
200 filter,
201 initscr,
202 new_prescr,
203 newterm,
204 nofilter,
205 restartterm,
206 ripoffline,
207 setupterm,
208 slk_init,
209 tgetent,
210 use_env,
211 use_extended_names,
212 use_tioctl
213 .RE
214 .SS "Command-line Utilities"
215 The command-line utilities such as \fBtic\fP(1) provide a verbose option
216 which extends the set of messages written using the \fBcurses_trace\fP function.
217 Both of these (\fB\-v\fP and \fBcurses_trace\fP)
218 use the same variable (\fB_nc_tracing\fP),
219 which determines the messages which are written.
220 .PP
221 Because the command-line utilities may call initialization functions
222 such as \fBsetupterm\fP, \fBtgetent\fP or \fBuse_extended_names\fP,
223 some of their debugging output may be directed to the \fItrace\fP file
224 if the \fI\%NCURSES_TRACE\fP environment variable is set:
225 .bP
226 messages produced in the utility are written to the standard error.
227 .bP
228 messages produced by the underlying library are written to \fItrace\fP.
229 .PP
230 If \fI\%ncurses\fP is built without tracing,
231 none of the latter are produced,
232 and fewer diagnostics are provided by the command-line utilities.
233 .SH RETURN VALUE
234 Routines which return a value are designed to be used as parameters
235 to the \fB_tracef\fP routine.
236 .SH PORTABILITY
237 These functions are not part of the XSI interface.
238 Some other curses implementations are known to
239 have similar features,
240 but they are not compatible with \fI\%ncurses\fP:
241 .bP
242 SVr4 provided \fBtraceon\fP and \fBtraceoff\fP,
243 to control whether debugging information was written
244 to the \*(``trace\*('' file.
245 While the functions were always available,
246 this feature was only enabled
247 if \fBDEBUG\fP was defined when building the library.
248 .IP
249 The SVr4 tracing feature is undocumented.
250 .bP
251 PDCurses provides \fBtraceon\fP and \fBtraceoff\fP,
252 which (like SVr4) are always available,
253 and enable tracing
254 to the \*(``trace\*('' file
255 only when a debug-library is built.
256 .IP
257 PDCurses has a short description of these functions,
258 with a note that they are not present in X/Open Curses,
259 \fI\%ncurses\fP or NetBSD.
260 It does not mention SVr4,
261 but the functions' inclusion in a header file section
262 labeled \*(``Quasi-standard\*('' hints at the origin.
263 .bP
264 NetBSD does not provide functions for enabling/disabling traces.
265 It uses environment variables
266 \fI\%CURSES_TRACE_MASK\fP and
267 \fI\%CURSES_TRACE_FILE\fP to determine what is traced,
268 and where the results are written.
269 This is available only when a debug-library is built.
270 .IP
271 The NetBSD tracing feature is undocumented.
272 .PP
273 A few \fI\%ncurses\fP functions are not provided when symbol versioning
274 is used:
275 .RS 4
276 .PP
277 _nc_tracebits,
278 _tracedump,
279 _tracemouse
280 .RE
281 .PP
282 The original \fBtrace\fP routine was deprecated because
283 it often conflicted with application names.
284 .SH SEE ALSO
285 \fB\%curses\fP(3X)