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