]> ncurses.scripts.mit.edu Git - ncurses.git/blob - man/curs_trace.3x
ncurses 6.4 - patch 20240224
[ncurses.git] / man / curs_trace.3x
1 .\"***************************************************************************
2 .\" Copyright 2019-2023,2024 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.44 2024/02/24 20:01:11 tom Exp $
31 .TH curs_trace 3X 2024-02-24 "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 .na
200 .PP
201 \fB\%filter\fP,
202 \fB\%initscr\fP,
203 \fB\%new_prescr\fP,
204 \fB\%newterm\fP,
205 \fB\%nofilter\fP,
206 \fB\%restartterm\fP,
207 \fB\%ripoffline\fP,
208 \fB\%setupterm\fP,
209 \fB\%slk_init\fP,
210 \fB\%tgetent\fP,
211 \fB\%use_env\fP,
212 \fB\%use_extended_names\fP,
213 \fB\%use_tioctl\fP
214 .RE
215 .ad
216 .SS "Command-line Utilities"
217 The command-line utilities such as \fBtic\fP(1) provide a verbose option
218 which extends the set of messages written using the \fBcurses_trace\fP function.
219 Both of these (\fB\-v\fP and \fBcurses_trace\fP)
220 use the same variable (\fB_nc_tracing\fP),
221 which determines the messages which are written.
222 .PP
223 Because the command-line utilities may call initialization functions
224 such as \fBsetupterm\fP, \fBtgetent\fP or \fBuse_extended_names\fP,
225 some of their debugging output may be directed to the \fItrace\fP file
226 if the \fI\%NCURSES_TRACE\fP environment variable is set:
227 .bP
228 messages produced in the utility are written to the standard error.
229 .bP
230 messages produced by the underlying library are written to \fItrace\fP.
231 .PP
232 If \fI\%ncurses\fP is built without tracing,
233 none of the latter are produced,
234 and fewer diagnostics are provided by the command-line utilities.
235 .SH RETURN VALUE
236 Routines which return a value are designed to be used as parameters
237 to the \fB_tracef\fP routine.
238 .SH PORTABILITY
239 These functions are not part of the XSI interface.
240 Some other curses implementations are known to
241 have similar features,
242 but they are not compatible with \fI\%ncurses\fP:
243 .bP
244 SVr4 provided \fBtraceon\fP and \fBtraceoff\fP,
245 to control whether debugging information was written
246 to the \*(``trace\*('' file.
247 While the functions were always available,
248 this feature was only enabled
249 if \fBDEBUG\fP was defined when building the library.
250 .IP
251 The SVr4 tracing feature is undocumented.
252 .bP
253 PDCurses provides \fBtraceon\fP and \fBtraceoff\fP,
254 which (like SVr4) are always available,
255 and enable tracing
256 to the \*(``trace\*('' file
257 only when a debug-library is built.
258 .IP
259 PDCurses has a short description of these functions,
260 with a note that they are not present in X/Open Curses,
261 \fI\%ncurses\fP or NetBSD.
262 It does not mention SVr4,
263 but the functions' inclusion in a header file section
264 labeled \*(``Quasi-standard\*('' hints at the origin.
265 .bP
266 NetBSD does not provide functions for enabling/disabling traces.
267 It uses environment variables
268 \fI\%CURSES_TRACE_MASK\fP and
269 \fI\%CURSES_TRACE_FILE\fP to determine what is traced,
270 and where the results are written.
271 This is available only when a debug-library is built.
272 .IP
273 The NetBSD tracing feature is undocumented.
274 .PP
275 A few \fI\%ncurses\fP functions are not provided when symbol versioning
276 is used:
277 .RS 4
278 .PP
279 _nc_tracebits,
280 _tracedump,
281 _tracemouse
282 .RE
283 .PP
284 The original \fBtrace\fP routine was deprecated because
285 it often conflicted with application names.
286 .SH SEE ALSO
287 \fB\%curses\fP(3X)